From fd6c7c43bc975ec138f8ce5d9c5f52a28c8aedc3 Mon Sep 17 00:00:00 2001 From: Vihang Mehta Date: Wed, 23 Mar 2022 14:51:39 -0700 Subject: [PATCH] Fix the CR yamls and make customDeployKeySecret optional Summary: This fixes the problem at the root and ensures that the value isn't in the custom resource if it's optional. Revert "Remove deploySecret YAML" This reverts commit 4d9db3df2b1d291223f87ec23d17934df7c54df3. Test Plan: Extract the templates and ensure that `customDeployKeySecret: ` does not show up. Reviewers: michelle Reviewed By: michelle Signed-off-by: Vihang Mehta Differential Revision: https://phab.corp.pixielabs.ai/D11034 GitOrigin-RevId: 60c4b847504b5c3731882e236e78fc045974cf7b --- k8s/operator/helm/templates/04_vizier.yaml | 2 ++ src/utils/template_generator/vizier_yamls/vizier_yamls.go | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/k8s/operator/helm/templates/04_vizier.yaml b/k8s/operator/helm/templates/04_vizier.yaml index 31c107820dc..be07fe4aff6 100644 --- a/k8s/operator/helm/templates/04_vizier.yaml +++ b/k8s/operator/helm/templates/04_vizier.yaml @@ -8,7 +8,9 @@ spec: version: {{ .Values.version }} {{- end }} deployKey: {{ .Values.deployKey }} + {{- if .Values.customDeployKeySecret }} customDeployKeySecret: {{ .Values.customDeployKeySecret }} + {{- end }} cloudAddr: {{ .Values.cloudAddr }} disableAutoUpdate: {{ .Values.disableAutoUpdate }} useEtcdOperator: {{ .Values.useEtcdOperator }} diff --git a/src/utils/template_generator/vizier_yamls/vizier_yamls.go b/src/utils/template_generator/vizier_yamls/vizier_yamls.go index 24f60d422fb..8d5efc010bb 100644 --- a/src/utils/template_generator/vizier_yamls/vizier_yamls.go +++ b/src/utils/template_generator/vizier_yamls/vizier_yamls.go @@ -441,6 +441,12 @@ func generateVzYAMLs(clientset *kubernetes.Clientset, yamlMap map[string]string) value: "{{$value}}" {{- end}}`, }, + { + TemplateMatcher: yamls.GenerateResourceNameMatcherFn("vizier-cloud-connector"), + Patch: `{"spec": {"template": {"spec": {"containers": [{"name": "app", "env": [{"name": "PL_DEPLOY_KEY", "valueFrom": { "secretKeyRef": { "key": "deploy-key", "name": "__PX_DEPLOY_KEY_SECRET_NAME__", "optional": true} } }]}] } } } }`, + Placeholder: "__PX_DEPLOY_KEY_SECRET_NAME__", + TemplateValue: `{{ if .Values.customDeployKeySecret }}"{{ .Values.customDeployKeySecret }}"{{else}}"pl-deploy-secrets"{{end}}`, + }, }...) persistentYAML, err := yamls.TemplatizeK8sYAML(clientset, yamlMap[vizierMetadataPersistYAMLPath], tmplOptions)