Skip to content

Commit 38da3c0

Browse files
committed
Add subjectAltName to VPA webhook cert
1 parent 106a822 commit 38da3c0

File tree

1 file changed

+4
-3
lines changed
  • vertical-pod-autoscaler/pkg/admission-controller

1 file changed

+4
-3
lines changed

vertical-pod-autoscaler/pkg/admission-controller/gencerts.sh

100644100755
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,18 @@ distinguished_name = req_distinguished_name
3333
basicConstraints = CA:FALSE
3434
keyUsage = nonRepudiation, digitalSignature, keyEncipherment
3535
extendedKeyUsage = clientAuth, serverAuth
36+
subjectAltName = DNS:vpa-webhook.kube-system.svc
3637
EOF
3738

3839
# Create a certificate authority
3940
openssl genrsa -out ${TMP_DIR}/caKey.pem 2048
40-
openssl req -x509 -new -nodes -key ${TMP_DIR}/caKey.pem -days 100000 -out ${TMP_DIR}/caCert.pem -subj "/CN=${CN_BASE}_ca"
41+
openssl req -x509 -new -nodes -key ${TMP_DIR}/caKey.pem -days 100000 -out ${TMP_DIR}/caCert.pem -subj "/CN=${CN_BASE}_ca" -addext "subjectAltName = DNS:${CN_BASE}_ca"
4142

4243
# Create a server certiticate
4344
openssl genrsa -out ${TMP_DIR}/serverKey.pem 2048
4445
# Note the CN is the DNS name of the service of the webhook.
45-
openssl req -new -key ${TMP_DIR}/serverKey.pem -out ${TMP_DIR}/server.csr -subj "/CN=vpa-webhook.kube-system.svc" -config ${TMP_DIR}/server.conf
46-
openssl x509 -req -in ${TMP_DIR}/server.csr -CA ${TMP_DIR}/caCert.pem -CAkey ${TMP_DIR}/caKey.pem -CAcreateserial -out ${TMP_DIR}/serverCert.pem -days 100000 -extensions v3_req -extfile ${TMP_DIR}/server.conf
46+
openssl req -new -key ${TMP_DIR}/serverKey.pem -out ${TMP_DIR}/server.csr -subj "/CN=vpa-webhook.kube-system.svc" -config ${TMP_DIR}/server.conf -addext "subjectAltName = DNS:vpa-webhook.kube-system.svc"
47+
openssl x509 -req -in ${TMP_DIR}/server.csr -CA ${TMP_DIR}/caCert.pem -CAkey ${TMP_DIR}/caKey.pem -CAcreateserial -out ${TMP_DIR}/serverCert.pem -days 100000 -extensions SAN -extensions v3_req -extfile ${TMP_DIR}/server.conf
4748

4849
echo "Uploading certs to the cluster."
4950
kubectl create secret --namespace=kube-system generic vpa-tls-certs --from-file=${TMP_DIR}/caKey.pem --from-file=${TMP_DIR}/caCert.pem --from-file=${TMP_DIR}/serverKey.pem --from-file=${TMP_DIR}/serverCert.pem

0 commit comments

Comments
 (0)