Skip to content

Commit

Permalink
kgo: add args and provide current defaults via env (#1058)
Browse files Browse the repository at this point in the history
  • Loading branch information
pmalek authored Apr 18, 2024
1 parent 76a8727 commit 3604b7f
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 19 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-args-values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
env:
# gateway controller
enable_controller_gateway: false

args:
- --zap-log-level=debug
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
13 changes: 8 additions & 5 deletions charts/gateway-operator/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,15 @@ spec:
{{- end }}
spec:
containers:
- args:
- --health-probe-bind-address=:8081
- --metrics-bind-address=127.0.0.1:8080
- name: manager
{{ with .Values.args -}}
args:
{{ range $val := . -}}
- {{ $val }}
{{ end }}
{{- end -}}
env:
{{- include "kong.env" . | nindent 8 }}
{{- include "kong.env" . | indent 8 }}
- name: POD_NAMESPACE
valueFrom:
fieldRef:
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 3604b7f

Please sign in to comment.