Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions charts/lifecycle-controller/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,25 @@ Create the name of the service account to use
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}

{{/*
Extract a numeric container port from a listener address.
*/}}
{{- define "lifecycle-controller.bindPort" -}}
{{- if not (kindIs "string" .address) -}}
{{- fail (printf "%s must be a string" .key) -}}
{{- end -}}
{{- if not (regexMatch `^(\[[^\[\][:space:]]+\]|[^:\[\][:space:]]*):[0-9]+$` .address) -}}
{{- fail (printf "%s must use :port, host:port, or [IPv6]:port with a numeric port" .key) -}}
{{- end -}}
{{- $digits := regexFind `[0-9]+$` .address -}}
{{- $digits = regexReplaceAll `^0+` $digits "" -}}
{{- if gt (len $digits) 5 -}}
{{- fail (printf "%s port must be between 1 and 65535" .key) -}}
{{- end -}}
{{- $port := int $digits -}}
{{- if or (lt $port 1) (gt $port 65535) -}}
{{- fail (printf "%s port must be between 1 and 65535" .key) -}}
{{- end -}}
{{- $port -}}
{{- end -}}
4 changes: 2 additions & 2 deletions charts/lifecycle-controller/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@ spec:
- --ignore-namespace={{ . }}
{{- end }}
ports:
- containerPort: 8081
- containerPort: {{ include "lifecycle-controller.bindPort" (dict "address" .Values.controllerManager.healthProbeBindAddress "key" "controllerManager.healthProbeBindAddress") }}
name: healthz
protocol: TCP
{{- if .Values.metrics.enabled }}
- containerPort: {{ trimPrefix ":" .Values.metrics.bindAddress }}
- containerPort: {{ include "lifecycle-controller.bindPort" (dict "address" .Values.metrics.bindAddress "key" "metrics.bindAddress") }}
name: metrics
protocol: TCP
{{- end }}
Expand Down
4 changes: 4 additions & 0 deletions charts/lifecycle-controller/templates/servicemonitor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,14 @@ spec:
endpoints:
- path: /metrics
port: https
{{- if .Values.metrics.secure }}
scheme: https
bearerTokenFile: /var/run/secrets/kubernetes.io/serviceaccount/token
tlsConfig:
insecureSkipVerify: {{ .Values.metrics.serviceMonitor.insecureSkipVerify }}
{{- else }}
scheme: http
{{- end }}
namespaceSelector:
matchNames:
- {{ .Release.Namespace }}
Expand Down
Loading