1

我正在使用 argo 事件/传感器创建 Kubernetes 作业,传感器被正确触发,但它给了我错误“服务器找不到请求的资源”

这是我的 sensor.yaml

apiVersion: argoproj.io/v1alpha1
kind: Sensor
metadata:
  name: exp-webhook
spec:
  template:
    serviceAccountName: crypto-job-sa
  dependencies:
    - name: payload
      eventSourceName: webhook
      eventName: devops-toolkit
  triggers:
    - template:
        name: sample-job
        k8s:
          group: batch
          version: v1
          resource: Job
          operation: create
          source:
            resource:
              apiVersion: batch/v1
              kind: Job
              metadata:
                name: exp-job-crypto
#                annotations:
#                  argocd.argoproj.io/hook: PreSync
#                  argocd.argoproj.io/hook-delete-policy: HookSucceeded
              spec:
                ttlSecondsAfterFinished: 100
                template:
                  spec:
                    restartPolicy: OnFailure
                    containers:
                      - name: crypto-job
                        image: docker.artifactory.xyz.com/xyz/pqr:master-b1b347a

这是错误详细信息。

   {"level":"error","ts":1624900390.6760905,"logger":"argo-events.sensor","caller":"sensors/listener.go:271","msg":"failed to execute a trigger","sensorName":"exp-webhook","error":"failed to execute trigger: timed out waiting for the condition: the server could not find the requested resource",
            "errorVerbose":"timed out waiting for the condition: the server could not find the requested resource\nfailed to execute trigger\ngithub.com/argoproj/argo-events/sensors.
    (*SensorContext).triggerOne\n\t/home/jenkins/agent/workspace/argo-events_master/sensors/listener.go:328\ngithub.com/argoproj/argo-events/sensors.(*SensorContext).triggerActions\n\t/home/jenkins/agent/workspace/argo-events_master/sensors/listener.go:269\ngithub.com/argoproj/argo-events/sensors.(*SensorContext).listenEvents.func1.3\n\t/home/jenkins/agent/workspace/argo-events_master/sensors/listener.go:181\nruntime.goexit\n\t/usr/local/go/src/runtime/asm_amd64.s:1357","triggerName":"sample-job","triggeredBy":["payload"],"triggeredByEvents":["32396264373063382d306336312d343039322d616536652d623965383531346666373234"],"stacktrace":"github.com/argoproj/argo-events/sensors.
        
    (*SensorContext).triggerActions\n\t/home/jenkins/agent/workspace/argo-events_master/sensors/listener.go:271\ngithub.com/argoproj/argo-events/sensors.(*SensorContext).listenEvents.func1.3\n\t/home/jenkins/agent/workspace/argo-events_master/sensors/listener.go:181"}

但它并没有说明什么资源没有找到。有人可以帮忙吗?我不知道这里有什么错误。

4

1 回答 1

3

所以错误是,而不是

resource: Job

它应该是

resource: jobs

这解决了这个问题。

于 2021-06-29T08:17:25.517 回答