From 7509a7f78fba24845bc08f53f50e7c0d8c727708 Mon Sep 17 00:00:00 2001 From: Carsten Lenz Date: Thu, 26 Oct 2023 12:34:51 +0200 Subject: [PATCH] chore: refactor avp setup AVP setup has been refactored to get ENVs in sync again. STABLE Env had a different, simplified AVP setup to support the limitation introduced to the STABLE env. With this AVP setup the kustomize-helm avp plugin has been removed, as we're not using it anymore (although there seems to be a leftover, see also eclipse-tractusx/sig-infra#322). This AVP Setup has been tested 2 ways: ### Simple condition checking The condition checking was done using this simple sh script: ```shell #!/usr/bin/env sh cd ../kube-prometheus-stack # here we have kustomization.yaml and values.yaml pwd #ARGOCD_ENV_helm_args=" " #ARGOCD_ENV_HELM_VALUES=" " if [ -n "$(find . -name 'Chart.yaml')" ] && # if find output is nonzero [ -n "$(find . -name 'values.yaml')" ] && # if find output is nonzero [ -n "${ARGOCD_ENV_helm_args}" ]; # if var ARGOCD_ENV_helm_args is defined and nonzero then echo "ARGOCD_ENV_helm_args!" fi if [ -n "$(find . -name 'Chart.yaml')" ] && [ -n "$(find . -name 'values.yaml')" ] && [ -n "${ARGOCD_ENV_HELM_VALUES}" ]; then echo "ARGOCD_ENV_HELM_VALUES" fi if [ -n "$(find . -name 'kustomization.yaml')" ] && [ -z "$(find . -name 'Chart.yaml')" ] && [ -z "$(find . -name 'values.yaml')" ]; then echo "KUSTOMIZE" fi if [ -z "${ARGOCD_ENV_helm_args}" ] && [ -z "${ARGOCD_ENV_HELM_VALUES}" ] && [ -z "$(find . -name 'kustomization.yaml')" ] && [ -n "$(find . -name '*.yaml' -0 | xargs -I {} grep '- - helm template $ARGOCD_APP_NAME --include-crds -n $ARGOCD_APP_NAMESPACE ${ARGOCD_ENV_helm_args} . > manifest.yaml && - kustomize build | + - | + helm template $ARGOCD_APP_NAME --include-crds -n $ARGOCD_APP_NAMESPACE $ARGOCD_ENV_helm_args . | argocd-vault-plugin generate - -s $ARGOCD_APP_NAMESPACE:vault-secret lockRepo: false - avp-helm-args.yaml: | + avp-helm-values.yaml: | --- apiVersion: argoproj.io/v1alpha1 kind: ConfigManagementPlugin metadata: - name: argocd-vault-plugin-helm-args + name: argocd-vault-plugin-helm-values spec: allowConcurrency: true discover: @@ -61,54 +46,36 @@ data: command: - sh - "-c" - - >- - if [ -n "$(find . -name 'values.yaml' | head -1)" ] && - [ -z "$(find . -name 'kustomization.yaml')" ] && - [ -n "$(find . -name 'Chart.yaml' | head -1)" ] && - [ -n "${ARGOCD_ENV_helm_args}" ]; then - echo "Hit!" + - | + if [ -n "$(find . -name 'Chart.yaml')" ] && + [ -n "$(find . -name 'values.yaml')" ] && + [ -n "${ARGOCD_ENV_HELM_VALUES}" ]; + then + echo "ARGOCD_ENV_HELM_VALUES" fi init: - command: [sh, -c, "helm dependency update"] + command: [ sh, -c, "helm dependency update" ] generate: command: - bash - "-c" - - >- - helm template $ARGOCD_APP_NAME --include-crds -n $ARGOCD_APP_NAMESPACE $ARGOCD_ENV_helm_args . | + - | + helm template --include-crds $ARGOCD_APP_NAME -n $ARGOCD_APP_NAMESPACE -f <(echo "$ARGOCD_ENV_HELM_VALUES") . | argocd-vault-plugin generate - -s $ARGOCD_APP_NAMESPACE:vault-secret lockRepo: false - avp-helm-values.yaml: | + avp-kustomize.yaml: | --- apiVersion: argoproj.io/v1alpha1 kind: ConfigManagementPlugin metadata: - name: argocd-vault-plugin-helm + name: argocd-vault-plugin-kustomize spec: allowConcurrency: true discover: find: - command: - - sh - - "-c" - - >- - if [ -n "$(find . -name 'values.yaml' | head -1)" ] && - [ -n "$(find . -name 'Chart.yaml' | head -1)" ] && - [ -n "$(find . -name '*.yaml' | xargs -I {} grep '- - helm template $ARGOCD_APP_NAME -n $ARGOCD_APP_NAMESPACE -f <(echo "$ARGOCD_ENV_HELM_VALUES") . | - argocd-vault-plugin generate - -s $ARGOCD_APP_NAMESPACE:vault-secret + command: [ sh, -c, "kustomize build . | argocd-vault-plugin generate - -s $ARGOCD_APP_NAMESPACE:vault-secret" ] lockRepo: false avp.yaml: | apiVersion: argoproj.io/v1alpha1 @@ -123,12 +90,11 @@ data: - sh - "-c" - >- - if [ -z "$(find . -name 'Chart.yaml')" ] && - [ -z "$(find . -name 'kustomization.yaml')" ] && - [ -n "$(find . -name '*.yaml')" ] && + if [ -z "${ARGOCD_ENV_helm_args}" ] && + [ -z "${ARGOCD_ENV_HELM_VALUES}" ] && [ -n "$(find . -name '*.yaml' | xargs -I {} grep '