argoproj / argo-cd

Declarative Continuous Deployment for Kubernetes
https://argo-cd.readthedocs.io
Apache License 2.0
17.47k stars 5.31k forks source link

read different helm args in the plugin using sidecar way #13323

Open samar-elsayed opened 1 year ago

samar-elsayed commented 1 year ago

Checklist:

Describe the bug

I am trying to use the sidecar way for avp plugin but with no use using the old configmap way to add a plugin, I am able to define the plugin along with helm_args env and it has been working fine that way

part of Appset example

    spec:
      project: dxl-stagingref-gr
      source:
        path: .
        plugin:
          env:
          - name: helm_args
            value: -f configs/{{path.basename}}/values.yaml -f configs/{{path.basename}}/dxl-stagingref-gr/values.yaml
              --set ms_dir={{path.basename}}
          name: argocd-vault-plugin-helm
        repoURL: https://github.test.com/Microservices/helm-configurations

but when I try to use the new way to add the plugin as a sidecar, I dont know how can I pass the helm_args to the plugin and that make the plugin not able to render the values files

part of new Appset example ( removed the name of the plugin )

    spec:
      project: dxl-stagingref-gr
      source:
        path: .
        plugin:
          env:
          - name: helm_args
            value: -f configs/{{path.basename}}/values.yaml -f configs/{{path.basename}}/dxl-stagingref-gr/values.yaml
              --set ms_dir={{path.basename}}
        repoURL: https://github.test.com/Microservices/helm-configurations

**avp configmap :**

apiVersion: v1
kind: ConfigMap
metadata:
  name: argocd-plugin

data:
  argocd-vault-plugin-helm.yaml: |
    ---
    apiVersion: argoproj.io/v1alpha1
    kind: ConfigManagementPlugin
    metadata:
      name: argocd-vault-plugin-helm
    spec:
      # Note: this command is run _before_ any Helm templating is done, therefore the logic is to check
      # if this looks like a Helm chart
      discover:
        find:
          command:
            - sh
            - "-c"
            - "find . -name 'Chart.yaml' && find . -name 'values.yaml'"
      generate:
        command: ["sh", "-c"]
        args: ["helm template $ARGOCD_APP_NAME -n $ARGOCD_APP_NAMESPACE ${ARGOCD_ENV_helm_args} . | argocd-vault-plugin generate -"]

the sidecar in the repo server deployment :

      - name: argocd-vault-plugin-helm
        command: [/var/run/argocd/argocd-cmp-server]
        image: 728642754198.dkr.ecr.eu-central-1.amazonaws.com/dxl-gr-argocd:ga-avp-1.13.0
        resources:
          requests:
            memory: 250Mi
            cpu: 200m
          limits:
            memory: 250Mi
            cpu: 200m
        envFrom:
          - secretRef:
              name: vault-approle

        env:
          - name: VAULT_SKIP_VERIFY
            value: 'true'
          - name: VAULT_ADDR
            value: 'https://vault-active.dxl-vault-gr:8200'
          - name: AVP_TYPE
            value: vault
          - name: AVP_AUTH_TYPE
            value: approle
        securityContext:
          runAsNonRoot: true
          runAsUser: 999
        volumeMounts:
          - mountPath: /var/run/argocd
            name: var-files
          - mountPath: /home/argocd/cmp-server/plugins
            name: plugins
          - mountPath: /tmp
            name: tmp

          # Register plugins into sidecar
          - mountPath: /home/argocd/cmp-server/config/plugin.yaml
            subPath: argocd-vault-plugin-helm.yaml
            name: argocd-plugin      

To Reproduce

the helm structure for my MSs ( microservices ) is like the following ( described as minimal as I can ):

templates
Chart.yaml
configs 
      MS
          values.yaml
          stagingref 
                values.yaml
          stagingref2
                values.yaml

and try to apply the sidecar way as I have mentioned above

Expected behavior

the values files should be rendered successfully

Version

v2.5.8+bbe870f
pkalemba commented 1 year ago

Hi can you provide ,any logs from your sidecar POD?

samar-elsayed commented 1 year ago

@pkalemba Unfortunately I am not able to recover the logs for that event but what I can recall is that the plugin wasn't able to render the values correctly /at all and thus argocd was seeing empty manifests

I hope you can re produce this case from your side