argoproj / argo-cd

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

Deployment of ArgoEvents example sensor fails, but kubectl command does it without an issue #16428

Closed comtihon closed 11 months ago

comtihon commented 11 months ago

I package my workflows (sensor + event source) in helm package during ci/cd. In the argocd manifest I specified this package to be installed. I found it convenient as we have multiple workflows repo and a single infra repo where we mention it together with other apps. But the problem I faced is - when it tries to install it via ArgoCD - it installs event source without any problem, but it fails to install the sensor: admission webhook "webhook.argo-events.argoproj.io" denied the request: template pubsub-workflow-trigger is invalid, unknown operation type create If I run it manually via kubectl apply -n argo-events -f sensor.yaml it says created. And after it the sensor is even visible by ArgoCD and marked as healthy.

Checklist:

Describe the bug

ArgoCD can't install argo-event's sensor, although the same sensor (taken from argo examples) can be installed using kubectl command.

To Reproduce

  1. package example sensor and event source in helm chart
  2. add argocd app manifest using this helm

Expected behavior sensor installed via argo cd

Screenshots Screenshot_20231122_182142 source:

apiVersion: argoproj.io/v1alpha1
kind: EventSource
metadata:
  name: pubsub-event-source
  namespace: argo-events
spec:
  pubsub:
    example:
      # Your Pub/Sub configuration goes here
      projectID: my-gcp-project
      topic: my-topic
      subscriptionID: my-subscription

sensor:

apiVersion: argoproj.io/v1alpha1
kind: Sensor
metadata:
  name: pubsub-sensor
  namespace: argo-events
spec:
  dependencies:
    - name: pubsub-dep
      eventSourceName: pubsub-event-source
      eventName: example
  triggers:
    - template:
        name: pubsub-workflow-trigger
        k8s:
          operation: create
          source:
            resource:
              apiVersion: argoproj.io/v1alpha1
              kind: Workflow
              metadata:
                generateName: gcp-workflow-
              spec:
                entrypoint: whalesay
                arguments:
                  parameters:
                    - name: message
                      # value will get overridden by the event payload
                      value: hello world
                templates:
                  - name: whalesay
                    inputs:
                      parameters:
                        - name: message
                    container:
                      image: docker/whalesay:latest
                      command: [ cowsay ]
                      args: [ "{{inputs.parameters.message}}" ]
          parameters:
            - src:
                dependencyName: test-dep
                dataKey: body
              dest: spec.arguments.parameters.0.value

manifest:

apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: my-app
  namespace: argocd
spec:
  project: default
  source:
    repoURL: gcp_helm_repo
    targetRevision: 0.*.*
    chart: my-chart
    helm:
      values: |
        message: "Custom Message from Argo CD"
  destination:
    server: 'https://kubernetes.default.svc'
    namespace: default
  syncPolicy:
    automated:
      prune: false
      selfHeal: true 

Version

- argo cd: v2.9.1+58b04e5
- argo workflows: 3.5.1
- argo events: 1.8.1

Logs

Paste any relevant application logs here.
comtihon commented 11 months ago

Update: Looks like it is not an argocd issue, but helm. When I try to install helm package via helm I get the same error:

helm install name name-0.2.108.tgz -f values.yaml 
Error: INSTALLATION FAILED: 1 error occurred:
        * admission webhook "webhook.argo-events.argoproj.io" denied the request: template nam-trigger is invalid, unknown operation type create
comtihon commented 11 months ago

looks like the reason was in the incorrect yaml. I compared example with my code line by line and found it