argoproj-labs / argocd-vault-plugin

An Argo CD plugin to retrieve secrets from Secret Management tools and inject them into Kubernetes secrets
https://argocd-vault-plugin.readthedocs.io
Apache License 2.0
817 stars 189 forks source link

exec format error #538

Open barth12 opened 1 year ago

barth12 commented 1 year ago

Describe the bug "exec format error" when trying to run argocd-vault-plugin as a sidecar.

To Reproduce Steps to reproduce the behavior: Here's my Helm config values:

redis-ha:
  enabled: true

controller:
  replicas: 1

server:
  autoscaling:
    enabled: true
    minReplicas: 2

repoServer:
  autoscaling:
    enabled: true
    minReplicas: 2
  serviceAccount:
    automountServiceAccountToken: true
  volumes:
    - configMap:
        name: cmp-plugin
      name: cmp-plugin
    - name: custom-tools
      emptyDir: {}
    - name: vault-server-tls-secret
      secret:
        secretName: vault-server-tls-secret
  initContainers:
    - name: download-tools
      image: registry.access.redhat.com/ubi8
      env:
        - name: AVP_VERSION
          value: ${local.argo_cd_vault_plugin_version}
      command: [sh, -c]
      args:
        - >-
          curl -L https://github.com/argoproj-labs/argocd-vault-plugin/releases/download/v$(AVP_VERSION)/argocd-vault-plugin_$(AVP_VERSION)_linux_amd64 -o argocd-vault-plugin &&
          chmod +x argocd-vault-plugin &&
          mv argocd-vault-plugin /custom-tools/
      volumeMounts:
        - mountPath: /custom-tools
          name: custom-tools
  extraContainers:
    - name: avp
      command: [/var/run/argocd/argocd-cmp-server]
      image: quay.io/argoproj/argocd:v${local.argo_cd_version}
      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: avp.yaml
          name: cmp-plugin

        # Important: Mount tools into $PATH
        - name: custom-tools
          subPath: argocd-vault-plugin
          mountPath: /usr/local/bin/argocd-vault-plugin

        # mounted Vault TLS CA CERT
        - name: vault-server-tls-secret
          mountPath: "/vault/tls"
      envFrom:
       - secretRef:
           name: argocd-vault-plugin-credentials

applicationSet:
  replicaCount: 2

And my config map:

apiVersion: argoproj.io/v1alpha1
kind: ConfigManagementPlugin
metadata:
  name: argocd-vault-plugin
spec:
  allowConcurrency: true
  discover:
    find:
      command:
        - sh
        - "-c"
        - "find . -name '*.yaml' | xargs -I {} grep \"<path\\|avp\\.kubernetes\\.io\" {} | grep ."
  generate:
    command:
      - argocd-vault-plugin
      - generate
      - "."
  lockRepo: false

My Application:

apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: argocd
spec:
  destination:
    namespace: argocd
    server: https://kubernetes.default.svc
  project: test
  source:
    path: argocd
    repoURL: git@github.com:test/test.git
    targetRevision: master
    plugin:
      name: argocd-vault-plugin

Expected behavior It should not result in error:

rpc error: code = Unknown desc = Manifest generation error (cached): plugin sidecar failed. error generating manifests in cmp: rpc error: code = Unknown desc = error generating manifests: fork/exec /usr/local/bin/argocd-vault-plugin: exec format error

Additional context Version: 2.7.3

vadimzharov commented 1 year ago

I see this error if run Argo plugin AMD64 binary on ARM. In your helm configuration values you pull AMD64 binary from github releases, but are you sure you run this container on x86 machine and not on arm (like Raspberry PI)?

murand78 commented 11 months ago

Make sure curl -L https://github.com/argoproj-labs/argocd-vault-plugin/releases/download/v$(AVP_VERSION)/argocd-vault-plugin_$(AVP_VERSION)_linux_amd64 is correctly resolved. In my a case a text "Not Found" instead of the binary caused this error message. Replicing with https://github.com/argoproj-labs/argocd-vault-plugin/releases/download/v1.17.0/argocd-vault-plugin_1.17.0_linux_amd64 worked.