简体   繁体   中英

How to set annotations for a helm install

I am trying to install the chart stable/efs-provisioner and I would like to apply an annotation so that the deployment is correctly tagged in datadog.

Datadog requires the annotation : ad.datadoghq.com/tags: '{"env": "staging"}'

I have tried various incantations of the following, but I keep getting the error below.

$ helm install efs-provisioner stable/efs-provisioner \
  --set efsProvisioner.efsFileSystemId=fs-a1b2c3d4 \ 
  --set efsProvisioner.awsRegion=us-east-1 \
  --set annotations."ad\.datadoghq\.com/tags"="{\'env\': \'staging\'}"

Error:

Error: YAML parse error on efs-provisioner/templates/storageclass.yaml: 
error unmarshaling JSON: while decoding JSON: 
json: cannot unmarshal array into Go struct field .metadata.annotations of type string

Assuming you'd like the output to look like the following:

$ helm template efs-provisioner stable/efs-provisioner <flags> \
  | grep -m 1 -C 4 datadog
    chart: efs-provisioner-0.10.0
    release: "efs-provisioner"
    heritage: "Helm"
  annotations:
    ad.datadoghq.com/tags: '{"env": "staging"}'

you need to escape the { and and use \\" instead of \\' :

$ helm template efs-provisioner stable/efs-provisioner \
  --set efsProvisioner.efsFileSystemId=fs-a1b2c3d4 \
  --set efsProvisioner.awsRegion=us-east-1 \
  --set annotations."ad\.datadoghq\.com/tags"="\{\"env\": \"staging\"\}" 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM