Using a Configmap to define whitelist annotations across multiple Ingresses

6/20/2018

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
kubernetes
kubernetes-ingress

1 Answer

6/22/2018

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
Source: StackOverflow