Skip to content

Commit 56590b9

Browse files
alexbdeuic70395
andauthored
Make password key in Kubernetes secret configurable (#116)
* Make password key in Kubernetes secret configurable * Increase minor chart version Co-authored-by: uic70395 <[email protected]>
1 parent c0c15f8 commit 56590b9

File tree

5 files changed

+36
-20
lines changed

5 files changed

+36
-20
lines changed

helm/oauth2-proxy/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: oauth2-proxy
2-
version: 6.4.0
2+
version: 6.5.0
33
apiVersion: v2
44
appVersion: 7.3.0
55
home: https://oauth2-proxy.github.io/oauth2-proxy/

helm/oauth2-proxy/README.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ Parameter | Description | Default
107107
`alphaConfig.serverConfigData` | Arbitrary configuration data to append to the server section | `{}`
108108
`alphaConfig.metricsConfigData` | Arbitrary configuration data to append to the metrics section | `{}`
109109
`alphaConfig.configData` | Arbitrary configuration data to append | `{}`
110-
`alphaConfig.existingConfig` | existing Kubernetes configmap to use for the alpha configuration file. See [config template](https://github.com/oauth2-proxy/manifests/blob/master/helm/oauth2-proxy/templates/configmap-alpha.yaml) for the required values | `nil`
110+
`alphaConfig.existingConfig` | existing Kubernetes configmap to use for the alpha configuration file. See [config template](https://github.com/oauth2-proxy/manifests/blob/master/helm/oauth2-proxy/templates/configmap-alpha.yaml) for the required values | `nil`
111111
`customLabels` | Custom labels to add into metadata | `{}` |
112112
`config.google.adminEmail` | user impersonated by the google service account | `""`
113113
`config.google.serviceAccountJson` | google service account json contents | `""`
@@ -168,14 +168,17 @@ Parameter | Description | Default
168168
`securityContext.runAsNonRoot` | make sure that the container runs as a non-root user | `true`
169169
`proxyVarsAsSecrets` | choose between environment values or secrets for setting up OAUTH2_PROXY variables. When set to false, remember to add the variables OAUTH2_PROXY_CLIENT_ID, OAUTH2_PROXY_CLIENT_SECRET, OAUTH2_PROXY_COOKIE_SECRET in extraEnv | `true`
170170
`sessionStorage.type` | Session storage type which can be one of the following: cookie or redis | `cookie`
171-
`sessionStorage.redis.existingSecret` | existing Kubernetes secret to use for redis-password and redis-sentinel-password | `""`
171+
`sessionStorage.redis.existingSecret` | Name of the Kubernetes secret containing the redis & redis sentinel password values (see also `sessionStorage.redis.passwordKey`) | `""`
172172
`sessionStorage.redis.password` | Redis password. Applicable for all Redis configurations. Taken from redis subchart secret if not set. sessionStorage.redis.existingSecret takes precedence | `nil`
173+
`sessionStorage.redis.passwordKey` | Key of the Kubernetes secret data containing the redis password value | `redis-password`
173174
`sessionStorage.redis.clientType` | Allows the user to select which type of client will be used for redis instance. Possible options are: `sentinel`, `cluster` or `standalone` | `standalone`
174-
`sessionStorage.redis.standalone.connectionUrl` | URL of redis standalone server for redis session storage (e.g. redis://HOST[:PORT]). Automatically generated if not set. | `""`
175-
`sessionStorage.redis.cluster.connectionUrls` | List of Redis cluster connection URLs (e.g. redis://HOST[:PORT]) | `[]`
175+
`sessionStorage.redis.standalone.connectionUrl` | URL of redis standalone server for redis session storage (e.g. `redis://HOST[:PORT]`). Automatically generated if not set. | `""`
176+
`sessionStorage.redis.cluster.connectionUrls` | List of Redis cluster connection URLs (e.g. `["redis://127.0.0.1:8000", "redis://127.0.0.1:8000"]`) | `[]`
177+
`sessionStorage.redis.sentinel.existingSecret` | Name of the Kubernetes secret containing the redis sentinel password value (see also `sessionStorage.redis.sentinel.passwordKey`). Default: `sessionStorage.redis.existingSecret` | `""`
176178
`sessionStorage.redis.sentinel.password` | Redis sentinel password. Used only for sentinel connection; any redis node passwords need to use `sessionStorage.redis.password` | `nil`
179+
`sessionStorage.redis.sentinel.passwordKey` | Key of the Kubernetes secret data containing the redis sentinel password value | `redis-sentinel-password`
177180
`sessionStorage.redis.sentinel.masterName` | Redis sentinel master name | `nil`
178-
`sessionStorage.redis.sentinel.connectionUrls` | List of Redis sentinel connection URLs (e.g. redis://HOST[:PORT]) | `[]`
181+
`sessionStorage.redis.sentinel.connectionUrls` | List of Redis sentinel connection URLs (e.g. `["redis://127.0.0.1:8000", "redis://127.0.0.1:8000"]`) | `[]`
179182
`topologySpreadConstraints` | List of pod topology spread constraints | `[]`
180183
`redis.enabled` | Enable the redis subchart deployment | `false`
181184
`checkDeprecation` | Enable deprecation checks | `true`

helm/oauth2-proxy/templates/deployment.yaml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ spec:
130130
{{- else }}
131131
name: {{ include "oauth2-proxy.redis.fullname" . }}
132132
{{- end }}
133-
key: redis-password
133+
key: {{ .Values.sessionStorage.redis.passwordKey }}
134134
{{- end }}
135135
{{- if eq (default "" .Values.sessionStorage.redis.clientType) "standalone" }}
136136
- name: OAUTH2_PROXY_REDIS_CONNECTION_URL
@@ -147,12 +147,16 @@ spec:
147147
value: {{ .Values.sessionStorage.redis.sentinel.masterName }}
148148
- name: OAUTH2_PROXY_REDIS_SENTINEL_CONNECTION_URLS
149149
value: {{ .Values.sessionStorage.redis.sentinel.connectionUrls }}
150-
{{- if .Values.sessionStorage.redis.sentinel.password }}
150+
{{- if or .Values.sessionStorage.redis.sentinel.existingSecret .Values.sessionStorage.redis.existingSecret .Values.sessionStorage.redis.sentinel.password }}
151151
- name: OAUTH2_PROXY_REDIS_SENTINEL_PASSWORD
152152
valueFrom:
153153
secretKeyRef:
154-
name: {{ if .Values.sessionStorage.redis.existingSecret }} {{ .Values.sessionStorage.redis.existingSecret }}{{ else }} {{ template "oauth2-proxy.fullname" . }}-redis-access{{ end }}
155-
key: redis-sentinel-password
154+
{{- if or .Values.sessionStorage.redis.sentinel.existingSecret .Values.sessionStorage.redis.existingSecret }}
155+
name: {{ .Values.sessionStorage.redis.sentinel.existingSecret | default .Values.sessionStorage.redis.existingSecret }}
156+
{{- else }}
157+
name: {{ template "oauth2-proxy.fullname" . }}-redis-access
158+
{{- end }}
159+
key: {{ .Values.sessionStorage.redis.sentinel.passwordKey }}
156160
{{- end }}
157161
{{- end }}
158162
{{- end }}

helm/oauth2-proxy/templates/redis-secret.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ metadata:
1212
name: {{ $fullName }}-redis-access
1313
type: Opaque
1414
data:
15-
{{- with .redis.password }}
16-
redis-password: {{ . | b64enc | quote }}
15+
{{- if and .redis.password (not .redis.existingSecret) }}
16+
{{ .redis.passwordKey }}: {{ .redis.password | b64enc | quote }}
1717
{{- end }}
18-
{{- with .redis.sentinel.password }}
19-
redis-sentinel-password: {{ . | b64enc | quote }}
18+
{{- if and .redis.sentinel.password (not .redis.sentinel.existingSecret) (ne .redis.sentinel.passwordKey .redis.passwordKey) }}
19+
{{ .redis.sentinel.passwordKey }}: {{ .redis.sentinel.password | b64enc | quote }}
2020
{{- end }}
2121
{{- end }}
2222
{{- end }}

helm/oauth2-proxy/values.yaml

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -246,24 +246,33 @@ htpasswdFile:
246246

247247
# Configure the session storage type, between cookie and redis
248248
sessionStorage:
249-
# Can be one of the supported session storage cookie/redis
249+
# Can be one of the supported session storage cookie|redis
250250
type: cookie
251251
redis:
252-
# Secret name that holds the redis-password and redis-sentinel-password values
252+
# Name of the Kubernetes secret containing the redis & redis sentinel password values (see also `sessionStorage.redis.passwordKey`)
253253
existingSecret: ""
254+
# Redis password value. Applicable for all Redis configurations. Taken from redis subchart secret if not set. `sessionStorage.redis.existingSecret` takes precedence
254255
password: ""
255-
# Can be one of sentinel/cluster/standalone
256+
# Key of the Kubernetes secret data containing the redis password value
257+
passwordKey: "redis-password"
258+
# Can be one of standalone|cluster|sentinel
256259
clientType: "standalone"
257260
standalone:
258-
# If empty and sessionStorage type is redis, will automatically be generated.
261+
# URL of redis standalone server for redis session storage (e.g. `redis://HOST[:PORT]`). Automatically generated if not set
259262
connectionUrl: ""
260263
cluster:
261-
# connectionUrls: ["redis://127.0.0.1:8000", "redis://127.0.0.1:8000"]
264+
# List of Redis cluster connection URLs (e.g. `["redis://127.0.0.1:8000", "redis://127.0.0.1:8000"]`)
262265
connectionUrls: []
263266
sentinel:
267+
# Name of the Kubernetes secret containing the redis sentinel password value (see also `sessionStorage.redis.sentinel.passwordKey`). Default: `sessionStorage.redis.existingSecret`
268+
existingSecret: ""
269+
# Redis sentinel password. Used only for sentinel connection; any redis node passwords need to use `sessionStorage.redis.password`
264270
password: ""
271+
# Key of the Kubernetes secret data containing the redis sentinel password value
272+
passwordKey: "redis-sentinel-password"
273+
# Redis sentinel master name
265274
masterName: ""
266-
# connectionUrls: ["redis://127.0.0.1:8000", "redis://127.0.0.1:8000"]
275+
# List of Redis sentinel connection URLs (e.g. `["redis://127.0.0.1:8000", "redis://127.0.0.1:8000"]`)
267276
connectionUrls: []
268277

269278
# Enables and configure the automatic deployment of the redis subchart

0 commit comments

Comments
 (0)