Configure docker registry notifications

5/5/2019

I setup a docker registry using the official helm chart on my k8s cluster. I tried configuring notifications for my registry as per the docs, as follows:

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

After changing the config to include notifications, the registry fails to start as it does not recognize the configuration. I get this error:

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:
-- Badri
docker
docker-registry
kubernetes

1 Answer

5/6/2019

You missed the yaml character [ in their docs (which I freely admit is a terrible example, given that [ is often used in documentation as "placeholder goes here"), since in yaml it is the character that turns an item into a list -- just like in JSON, from which YAML draws its inspiration

But, that aside, the cannot unmarshal str into []string should have been a dead giveaway that they were expecting an array of strings for the header:

headers:
  Content-Type:
  - application/json

or, using the syntax of their terrible example:

headers:
  Content-Type: [application/json]

To follow up, the endpoints: reference docs also point out that:

A list of static headers to add to each request. Each header's name is a key beneath headers, and each value is a list of payloads for that header name. Values must always be lists.

(emphasis is mine)

-- mdaniel
Source: StackOverflow