diff --git a/deploy/cert-manager-sync/templates/deployment.yaml b/deploy/cert-manager-sync/templates/deployment.yaml index 5c25043..dc338dd 100644 --- a/deploy/cert-manager-sync/templates/deployment.yaml +++ b/deploy/cert-manager-sync/templates/deployment.yaml @@ -13,13 +13,17 @@ spec: {{- include "cert-manager-sync.selectorLabels" . | nindent 6 }} template: metadata: - {{- with .Values.podAnnotations }} + {{- $annotations := dict }} + {{- if and .Values.metrics .Values.metrics.enabled }} + {{- $_ := set $annotations "prometheus.io/scrape" "true" }} + {{- $_ := set $annotations "prometheus.io/port" (.Values.metrics.port | toString) }} + {{- end }} + {{- if .Values.podAnnotations }} + {{- $annotations = merge $annotations .Values.podAnnotations }} + {{- end }} + {{- if $annotations }} annotations: - {{- if .Values.Metrics.enabled }} - prometheus.io/scrape: "true" - prometheus.io/port: "{{ .Values.Metrics.port }}" - {{- end }} - {{- toYaml . | nindent 8 }} + {{- toYaml $annotations | nindent 8 }} {{- end }} labels: {{- include "cert-manager-sync.selectorLabels" . | nindent 8 }} @@ -55,13 +59,13 @@ spec: - name: CACHE_DISABLE value: "{{ .Values.config.disableCache }}" - name: ENABLE_METRICS - value: "{{ .Values.metrics.enabled }}" + value: "{{ if and .Values.metrics .Values.metrics.enabled }}{{ .Values.metrics.enabled }}{{ else }}false{{ end }}" - name: METRICS_PORT - value: "{{ .Values.metrics.port }}" + value: "{{ if and .Values.metrics .Values.metrics.port }}{{ .Values.metrics.port }}{{ else }}9090{{ end }}" {{- with .Values.env }} {{- toYaml . | nindent 10 }} {{- end }} - {{- if .Values.metrics.enabled }} + {{- if and .Values.metrics .Values.metrics.enabled }} ports: - name: metrics containerPort: {{ .Values.metrics.port }}