配置Docker注册表通知

时间:2019-05-05 21:16:31

标签: docker kubernetes docker-registry

我在我的k8s集群上使用official helm chart设置了一个docker注册表。 我尝试按照the docs为注册表配置通知,如下所示:

apiVersion: v1
data:
  config.yml: |-
    health:
      storagedriver:
        enabled: true
        interval: 10s
        threshold: 3
    http:
      addr: :5000
      headers:
        X-Content-Type-Options:
        - nosniff
    notifications:
      endpoints:
        - name: keel
          url: http://keel.example.com/v1/webhooks/registry
          headers:
            Content-Type: application/json
          timeout: 500ms
          threshold: 5
          backoff: 1s
    log:
      fields:
        service: registry
    storage:
      cache:
        blobdescriptor: inmemory
    version: 0.1
kind: ConfigMap

将配置更改为包括通知后,注册表无法启动,因为它无法识别配置。我收到此错误:

configuration error: error parsing /etc/docker/registry/config.yml: yaml: unmarshal errors:
  line 16: cannot unmarshal !!str `applica...` into []string

Usage: 
  registry serve <config> [flags]
Flags:
  -h, --help=false: help for serve


Additional help topics:

1 个答案:

答案 0 :(得分:1)

您在他们的文档中错过了yaml字符[(我可以自由地承认这是一个糟糕的例子,因为[在文档中经常被用作“占位符到这里”),因为在yaml中是将项目变成列表的字符-就像JSON中一样,YAML从中汲取灵感

但是,除此之外,cannot unmarshal str into []string应该是一个死胡同,因为他们期望标题的字符串是 array

headers:
  Content-Type:
  - application/json

,或使用其糟糕示例的语法:

headers:
  Content-Type: [application/json]

要跟进,endpoints: reference docs 指出:

  

要添加到每个请求的静态标头列表。每个标头名称是标头下方的键,每个值是该标头名称的有效负载列表值必须始终是列表

(重点是我的)