From 296baef1969e34150efc4d57f144f5f773c1a0c3 Mon Sep 17 00:00:00 2001 From: Yaroslav Borbat Date: Tue, 5 Mar 2024 14:34:07 +0300 Subject: [PATCH] fix Signed-off-by: Yaroslav Borbat --- hooks/generate_certificates.py | 2 +- hooks/lib/certificate/parse.py | 10 +++++++--- templates/virtualization-api/cert-secret.yaml | 2 +- templates/virtualization-api/deployment.yaml | 6 +++--- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/hooks/generate_certificates.py b/hooks/generate_certificates.py index e5016dd93..3b59d3409 100755 --- a/hooks/generate_certificates.py +++ b/hooks/generate_certificates.py @@ -53,7 +53,7 @@ def main(): f"virtualization-api.{common.NAMESPACE}", f"virtualization-api.{common.NAMESPACE}.svc"], ), - tls_secret_name="virtualziation-api-tls", + tls_secret_name="virtualization-api-tls", values_path_prefix=f"{common.MODULE_NAME}.internal.apiserver.cert" ), diff --git a/hooks/lib/certificate/parse.py b/hooks/lib/certificate/parse.py index 9905655dd..be46fed9a 100644 --- a/hooks/lib/certificate/parse.py +++ b/hooks/lib/certificate/parse.py @@ -27,13 +27,17 @@ def parse_key(key: str) -> crypto.PKey: def get_certificate_san(crt: crypto.X509) -> list[str]: - san = '' + san = "" ext_count = crt.get_extension_count() for i in range(0, ext_count): ext = crt.get_extension(i) - if 'subjectAltName' in str(ext.get_short_name()): + if "subjectAltName"in str(ext.get_short_name()): san = ext.__str__() - return san.split(', ') + break + if len(san) > 0: + return san.split(', ') + return [] + def is_outdated_ca(ca: str, cert_outdated_duration: timedelta) -> bool: diff --git a/templates/virtualization-api/cert-secret.yaml b/templates/virtualization-api/cert-secret.yaml index 23ff72603..e503af3de 100644 --- a/templates/virtualization-api/cert-secret.yaml +++ b/templates/virtualization-api/cert-secret.yaml @@ -2,7 +2,7 @@ apiVersion: v1 kind: Secret metadata: - name: virtualziation-api-tls + name: virtualization-api-tls namespace: d8-{{ .Chart.Name }} {{- include "helm_lib_module_labels" (list . (dict "app" "virtualization-api")) | nindent 2 }} type: kubernetes.io/tls diff --git a/templates/virtualization-api/deployment.yaml b/templates/virtualization-api/deployment.yaml index 35959f08e..b2202a2a1 100644 --- a/templates/virtualization-api/deployment.yaml +++ b/templates/virtualization-api/deployment.yaml @@ -74,7 +74,7 @@ spec: imagePullPolicy: Always volumeMounts: - mountPath: /etc/virtualziation-api/certificates - name: virtualziation-api-tls + name: virtualization-api-tls readOnly: true - mountPath: /etc/virtualziation-api-proxy/certificates name: virtualziation-api-proxy-tls @@ -98,11 +98,11 @@ spec: {{- include "helm_lib_node_selector" (tuple . "master") | nindent 6 }} {{- include "helm_lib_tolerations" (tuple . "any-node") | nindent 6 }} volumes: - - name: virtualziation-api-tls + - name: virtualization-api-tls secret: defaultMode: 420 optional: true - secretName: virtualziation-api-tls + secretName: virtualization-api-tls - name: kubevirt-virt-api-certs secret: defaultMode: 420