Search code examples
bashyamlgitlab-cikubernetes-helmnginx-ingress

GitLab CI/CD AutoDevOps customize Helm install escape ingress.annotation strings


I need to dynamically adjust ingress annotations based on variables in my pipeline yaml file. "Normal" property works perfectly fine, but the annotation has special characters and I cant seem to find a way to use it properly. Fine works the following:

    HELM_UPGRADE_EXTRA_ARGS: "
  --set application.secretName=$APPLICATION_SECRET_NAME \
  --set livenessProbe.path=$HEALTHCHECK_PATH \
  --set readinessProbe.path=$HEALTHCHECK_PATH \
  --set livenessProbe.scheme=$HTTPS_SCHEME \
  --set readinessProbe.scheme=$HTTPS_SCHEME \
  --set ingress.tls.enabled=$tlsEnabled \
  --set ingress.tls.secretName=$certName \
  --set service.externalPort=$SERVER_PORT \
  --set service.internalPort=$SERVER_PORT"

Now I want to add the property ssl paththrough which is nested like this in the final yaml:

metadata:
  name: my-service-ingress
  namespace: my-service
  annotations:
    nginx.ingress.kubernetes.io/ssl-passthrough: "true"

As you see the property has a long name with special characters . and / I already tried escaping them like I would in a direct bash environment, but this doesn't seem to work here, where I'm storing these parameters in a yaml variable which will be used by the pipeline to create the displayed yaml file. My try:

--set-string ingress.annotations."nginx\.ingress\.kubernetes\.io/ssl-passthrough"=$sslPaththrough \

Any ideas or tips are very appreciated!


Solution

  • The correct way (working for me now) seems to be double escaping the dots that are part of the property name and do not show hierarchy:

    --set-string ingress.annotations.nginx\\.ingress\\.kubernetes\\.io/ssl-passthrough=$sslPaththrough \