Skip to content

Commit

Permalink
kgo: add args and provide current defaults via env
Browse files Browse the repository at this point in the history
  • Loading branch information
pmalek committed Apr 18, 2024
1 parent b4a9c8d commit 9378d64
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 18 deletions.
2 changes: 1 addition & 1 deletion charts/gateway-operator/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ maintainers:
name: gateway-operator
sources:
- https://github.com/Kong/charts/tree/main/charts/gateway-operator
version: 0.1.5
version: 0.1.6
appVersion: "1.2"
annotations:
artifacthub.io/prerelease: "false"
Expand Down
6 changes: 6 additions & 0 deletions charts/gateway-operator/ci/env-and-customenv-values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
env:
# gateway controller
enable_controller_gateway: false

customEnv:
TZ: "Europe/Berlin"
35 changes: 22 additions & 13 deletions charts/gateway-operator/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -48,25 +48,34 @@ app.kubernetes.io/component: kgo
app.kubernetes.io/instance: "{{ .Release.Name }}"
{{- end -}}

{{/*
Create a list of env vars based on the values of the `env` and `customEnv` maps.
*/}}
{{- define "kong.env" -}}

{{- $userEnv := dict -}}
{{- range $key, $val := .Values.env }}
{{- $upper := upper $key -}}
{{- $var := printf "GATEWAY_OPERATOR_%s" $upper -}}
{{- $_ := set $userEnv $var $val -}}
{{- end -}}
{{- range $key, $val := $userEnv }}
- name: {{ $key }}
{{- $defaultEnv := dict -}}
{{- $_ := set $defaultEnv "GATEWAY_OPERATOR_HEALTH_PROBE_BIND_ADDRESS" ":8081" -}}
{{- $_ := set $defaultEnv "GATEWAY_OPERATOR_METRICS_BIND_ADDRESS" "127.0.0.1:8080" -}}

{{ range $key, $val := .Values.env }}
{{- $var := printf "GATEWAY_OPERATOR_%s" ( upper $key ) -}}
{{- if hasKey $defaultEnv $var -}}
{{- $defaultEnv = unset $defaultEnv $var -}}
{{- end }}
- name: {{ $var }}
value: {{ $val | quote }}
{{- end -}}

{{- $customEnv := dict -}}
{{- range $key, $val := .Values.customEnv }}
{{- $upper := upper $key -}}
{{- $_ := set $customEnv $upper $val -}}
{{ range $key, $val := .Values.customEnv }}
{{- $var := upper $key -}}
{{- if hasKey $defaultEnv $var -}}
{{- $defaultEnv = unset $defaultEnv $var -}}
{{- end }}
- name: {{ $var }}
value: {{ $val | quote }}
{{- end -}}
{{- range $key, $val := $customEnv }}

{{ range $key, $val := $defaultEnv }}
- name: {{ $key }}
value: {{ $val | quote }}
{{- end -}}
Expand Down
11 changes: 7 additions & 4 deletions charts/gateway-operator/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,13 @@ spec:
{{- end }}
spec:
containers:
- args:
- --health-probe-bind-address=:8081
- --metrics-bind-address=127.0.0.1:8080
- name: manager
{{- if .Values.args -}}
args:
{{- range $val := .Values.args -}}
- {{ $val }}
{{- end }}
{{- end }}
env:
{{- include "kong.env" . | nindent 8 }}
- name: POD_NAMESPACE
Expand All @@ -44,7 +48,6 @@ spec:
port: 8081
initialDelaySeconds: 15
periodSeconds: 20
name: manager
readinessProbe:
httpGet:
path: /readyz
Expand Down
8 changes: 8 additions & 0 deletions charts/gateway-operator/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ resources:
memory: 128Mi

# Use this section to add environment variables to operator's container
# NOTE: This is mutually exclusive with the args sections.
# When both an env and a corresponding arg are provided, the arg will take precedence.
env: {}
# # gateway controller
# enable_controller_gateway: true
Expand All @@ -79,6 +81,12 @@ env: {}
# customEnv:
# TZ: "Europe/Berlin"

# Use this section to add extra args to the operator's container.
# NOTE: This is a list of strings, so each arg should be a separate item in the list.
# NOTE: This is mutually exclusive with the env and customEnv sections.
# When both an env and a corresponding arg are provided, the arg will take precedence.
args: []

# Use this section to change the certs-dir emptyDir size
certsDir:
sizeLimit: 256Mi

0 comments on commit 9378d64

Please sign in to comment.