0

我正在使用 StorageNotification 的配置连接器示例,但我不断收到以下错误(取自kubectl describe

storagenotification-controller 更新调用失败:应用所需状态时出错:项目:未设置必填字段

我遵循了设置配置连接器的默认命名空间,但没有任何乐趣。StorageNotification API 规范没有“项目”字段。我认为它必须在正确的命名空间中?

所有其他资源似乎都设置好。只是通知不起作用。这是我完整的 yaml

# Bucket Starts the chain of events
apiVersion: storage.cnrm.cloud.google.com/v1beta1
kind: StorageBucket
metadata:
  labels:
    app: something-processing
  name: example-something
  namespace: ${GCP_PROJECT_ID}
---
# Pub/Sub topic that bucket events will publish to
apiVersion: pubsub.cnrm.cloud.google.com/v1beta1
kind: PubSubTopic
metadata:
  name: my-pubsub-topic  
  labels:
    app: something-processing
  namespace: ${GCP_PROJECT_ID}
---
# Publisher IAM permissions
apiVersion: iam.cnrm.cloud.google.com/v1beta1
kind: IAMPolicy
metadata:
  name: my-pubsub-topic-iam
  namespace: ${GCP_PROJECT_ID}
  labels:
    app: something-processing
spec:
  resourceRef:
    apiVersion: pubsub.cnrm.cloud.google.com/v1beta1
    kind: PubSubTopic
    name: my-pubsub-topic
  bindings:
    - role: roles/pubsub.publisher
      members:
        - serviceAccount:service-${GCP_PROJECT_ID}@gs-project-accounts.iam.gserviceaccount.com  
---
# Trigger that connects the bucket to the pubsub topic
apiVersion: storage.cnrm.cloud.google.com/v1beta1
kind: StorageNotification
metadata:
  name: storage-notification
  namespace: ${GCP_PROJECT_ID}
  project: ${GCP_PROJECT_ID}
  labels:
    app: something-processing
spec:
  bucketRef:
    name: something
  payloadFormat: JSON_API_V1
  topicRef:
    name: my-pubsub-topic
  eventTypes:
    - "OBJECT_FINALIZE"
---
# subscription that gets events from the topic and PUSHes them 
# to the K8s Ingress endpoint
apiVersion: pubsub.cnrm.cloud.google.com/v1beta1
kind: PubSubSubscription
metadata:
  name: pubsub-subscription-topic
  namespace: ${GCP_PROJECT_ID}
  labels:
    app: something-processing
spec:
  pushConfig:
    # This should match the Ingress path
    pushEndpoint: https://example.zone/some-ingress-end-point/
  topicRef:
    name: my-pubsub-topic

注意:我用项目 IDenvsubt替换;)${GCP_PROJECT_ID}

4

1 回答 1

3

我遇到了同样的问题,并设法通过将 topicRef.name 更改为 topicRef.external 并使用REST API中预期的完全限定的主题名称来解决它。我的配置连接器安装是按照文档中描述的 Workload Identity 场景完成的。

---
apiVersion: storage.cnrm.cloud.google.com/v1beta1
kind: StorageNotification
metadata:
  name: storage-notification
spec:
  bucketRef:
    name: ${BUCKET}
  payloadFormat: JSON_API_V1
  topicRef:
    external: "//pubsub.googleapis.com/projects/${PROJECT_ID}/topics/${TOPIC}"
  eventType:
    - "OBJECT_FINALIZE"
于 2020-03-18T17:43:08.320 回答