0

I'm trying to pass a JSON array into a Helm Chart. The chart's source code is here.

I'm passing the value like this:

helm upgrade  --install ingress-nginx ingress-nginx/ingress-nginx  \
   --repo https://kubernetes.github.io/ingress-nginx \
   --set controller.configAnnotations='{"mykey":"myval"}'

I've tried various forms of escaping the " and the curly brackets as recommended in several other SO answers but I have not been able to find the combination which makes it work. My shell is Bash.

I always end up with this error:

coalesce.go:220: warning: cannot overwrite table with non table 
for ingress-nginx.controller.configAnnotations (map[])

Error: UPGRADE FAILED: YAML parse error on ingress-nginx/templates/controller-configmap.yaml: 
error unmarshaling JSON: while decoding JSON: json: 
cannot unmarshal string into Go struct field .metadata.annotations of type map[string]string

Note that I'm using the Helm Chart for Kubernetes NGINX Controller from the Kubernetes project, not the equivalent from NGINX Inc. Not that I think it makes any difference to the question.

lbruun
  • 241
  • 1
  • 6
  • Please replace image with its text. – Cyrus Dec 09 '22 at 07:48
  • @Cyrus: I think the image is an advantage in this case as it does syntax highlighting. Stackoverflow cannot do this form of syntax highlighting. This ain't your normal YAML. The image is from [here](https://artifacthub.io/packages/helm/ingress-nginx/ingress-nginx?modal=template&template=controller-configmap.yaml) – lbruun Dec 09 '22 at 07:54
  • I can't copy and paste that example into a test chart. Also see [Please do not upload images of code/data/errors.](//meta.stackoverflow.com/q/285551) – David Maze Dec 09 '22 at 18:58
  • I've generally found the `helm install --set` syntax to be finicky, and I'm not sure you can use it to override an entire map like this. Can you write the alternate values into a YAML (or JSON) file and use 'helm install -f` instead? – David Maze Dec 09 '22 at 19:00
  • @DavidMaze. This is not my Chart, it is developed by the Kubernetes project, [here](https://github.com/kubernetes/ingress-nginx/blob/main/charts/ingress-nginx/). I haven't made too much out of that as I believe my question is more generic and would relate to _any_ Helm chart which does the same. – lbruun Dec 10 '22 at 08:28
  • Image has been removed in favor of a link to the GitHub source code for the Chart. – lbruun Dec 10 '22 at 08:31
  • I think I'll investigate use of a values file as an alternative to using `--set` command line option. – lbruun Dec 10 '22 at 09:53

0 Answers0