1

In Kubernetes, is it possible to use a Configmap for the value of an annotation? The reason I want to do this is to reuse an IP whitelist across multiple ingresses. Alternatively, is there another way to approach this problem?

ocf1
  • 45
  • 1
  • 7

1 Answers1

1

Unfortunately, no feature does it in Kubernetes. But as iomv wrote, you could try to use helm.

Helm allows you to use variables in your charts, for example:

metadata:
{{- if .Values.controller.service.annotations }}
  annotations:
{{ toYaml .Values.controller.service.annotations | indent 4 }}
{{- end }}
  labels:
{{- if .Values.controller.service.labels }}
{{ toYaml .Values.controller.service.labels | indent 4 }}
{{- end }}
    app: {{ template "nginx-ingress.name" . }}
    chart: {{ .Chart.Name }}-{{ .Chart.Version }}
    component: "{{ .Values.controller.name }}"
    heritage: {{ .Release.Service }}
    release: {{ .Release.Name }}
  name: {{ template "nginx-ingress.controller.fullname" . }}

This part of code is from the nginx-ingress chart. As you see, you can fetch this chart and update the values as you need.

Nick Rak
  • 2,629
  • 13
  • 19
  • Is it possible to use helm for templating locally, without needing to install helm on the cluster? – ocf1 Jun 25 '18 at 10:13
  • Unfortunately no, you need to install it inside the cluster too. – Nick Rak Jun 25 '18 at 10:38
  • I have a similar issue that I asked: https://stackoverflow.com/questions/65211284/populating-aws-alb-ingress-annotations-from-configmap I can understand how helm can be used to create the template, but how does the configmap populate the values in annotation section? – SSF Dec 09 '20 at 06:26