Add goldilocks values

This commit is contained in:
2023-09-04 23:01:58 +08:00
parent 4f5d1f3fab
commit 61aca25863
96 changed files with 10679 additions and 0 deletions
+3
View File
@@ -0,0 +1,3 @@
To verify that oauth2-proxy has started, run:
kubectl --namespace={{ template "oauth2-proxy.namespace" $ }} get pods -l "app={{ template "oauth2-proxy.name" . }}"
+23
View File
@@ -0,0 +1,23 @@
{{/*
Returns the appropriate apiVersion for podDisruptionBudget object.
*/}}
{{- define "capabilities.podDisruptionBudget.apiVersion" -}}
{{- if semverCompare ">=1.21-0" ( .Values.kubeVersion | default .Capabilities.KubeVersion.Version ) -}}
{{- print "policy/v1" -}}
{{- else -}}
{{- print "policy/v1beta1" -}}
{{- end -}}
{{- end -}}
{{/*
Return the appropriate apiVersion for ingress object.
*/}}
{{- define "capabilities.ingress.apiVersion" -}}
{{- if semverCompare "<1.14-0" ( .Values.kubeVersion | default .Capabilities.KubeVersion.Version ) -}}
{{- print "extensions/v1beta1" -}}
{{- else if semverCompare "<1.19-0" ( .Values.kubeVersion | default .Capabilities.KubeVersion.Version ) -}}
{{- print "networking.k8s.io/v1beta1" -}}
{{- else -}}
{{- print "networking.k8s.io/v1" -}}
{{- end -}}
{{- end -}}
+133
View File
@@ -0,0 +1,133 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "oauth2-proxy.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "oauth2-proxy.fullname" -}}
{{- if .Values.fullnameOverride -}}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- $name := default .Chart.Name .Values.nameOverride -}}
{{- if contains $name .Release.Name -}}
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "oauth2-proxy.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{/*
Generate basic labels
*/}}
{{- define "oauth2-proxy.labels" }}
helm.sh/chart: {{ include "oauth2-proxy.chart" . }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/component: authentication-proxy
app.kubernetes.io/part-of: {{ template "oauth2-proxy.name" . }}
{{- include "oauth2-proxy.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
{{- if .Values.customLabels }}
{{ toYaml .Values.customLabels }}
{{- end }}
{{- end }}
{{/*
Selector labels
*/}}
{{- define "oauth2-proxy.selectorLabels" }}
app.kubernetes.io/name: {{ include "oauth2-proxy.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}
{{/*
Get the secret name.
*/}}
{{- define "oauth2-proxy.secretName" -}}
{{- if .Values.config.existingSecret -}}
{{- printf "%s" .Values.config.existingSecret -}}
{{- else -}}
{{- printf "%s" (include "oauth2-proxy.fullname" .) -}}
{{- end -}}
{{- end -}}
{{/*
Create the name of the service account to use
*/}}
{{- define "oauth2-proxy.serviceAccountName" -}}
{{- if .Values.serviceAccount.enabled -}}
{{ default (include "oauth2-proxy.fullname" .) .Values.serviceAccount.name }}
{{- else -}}
{{ default "default" .Values.serviceAccount.name }}
{{- end -}}
{{- end -}}
{{/*
Allow the release namespace to be overridden for multi-namespace deployments in combined charts
*/}}
{{- define "oauth2-proxy.namespace" -}}
{{- if .Values.namespaceOverride -}}
{{- .Values.namespaceOverride -}}
{{- else -}}
{{- .Release.Namespace -}}
{{- end -}}
{{- end -}}
{{/*
Redis subcharts fullname
*/}}
{{- define "oauth2-proxy.redis.fullname" -}}
{{- if .Values.redis.enabled -}}
{{- include "common.names.fullname" (dict "Chart" (dict "Name" "redis") "Release" .Release "Values" .Values.redis) -}}
{{- else -}}
{{ fail "attempting to use redis subcharts fullname, even though the subchart is not enabled. This will lead to misconfiguration" }}
{{- end -}}
{{- end -}}
{{/*
Compute the redis url if not set explicitly.
*/}}
{{- define "oauth2-proxy.redis.StandaloneUrl" -}}
{{- if .Values.sessionStorage.redis.standalone.connectionUrl -}}
{{ .Values.sessionStorage.redis.standalone.connectionUrl }}
{{- else if .Values.redis.enabled -}}
{{- printf "redis://%s-master:%.0f" (include "oauth2-proxy.redis.fullname" .) .Values.redis.master.service.ports.redis -}}
{{- else -}}
{{ fail "please set sessionStorage.redis.standalone.connectionUrl or enable the redis subchart via redis.enabled" }}
{{- end -}}
{{- end -}}
{{/*
Returns the version
*/}}
{{- define "oauth2-proxy.version" -}}
{{ trimPrefix "v" (lower (.Values.image.tag | default (printf "v%s" .Chart.AppVersion))) }}
{{- end -}}
{{/*
Returns the kubectl version
Workaround for EKS https://github.com/aws/eks-distro/issues/1128
*/}}
{{- define "kubectl.version" -}}
{{- if .Values.initContainers.waitForRedis.kubectlVersion -}}
{{ .Values.initContainers.waitForRedis.kubectlVersion }}
{{- else -}}
{{- printf "%s.%s" .Capabilities.KubeVersion.Major (.Capabilities.KubeVersion.Minor | replace "+" "") -}}
{{- end -}}
{{- end -}}
+46
View File
@@ -0,0 +1,46 @@
{{/*
Returns `true` if the API `ingressClassName` field is supported and `false` otherwise
*/}}
{{- define "ingress.supportsIngressClassName" -}}
{{- if ( semverCompare "<1.18-0" ( .Values.kubeVersion | default .Capabilities.KubeVersion.Version ) ) -}}
{{- print "false" -}}
{{- else -}}
{{- print "true" -}}
{{- end -}}
{{- end -}}
{{/*
Returns `true` if the API `pathType` field is supported and `false` otherwise
*/}}
{{- define "ingress.supportsPathType" -}}
{{- if ( semverCompare "<1.18-0" ( .Values.kubeVersion | default .Capabilities.KubeVersion.Version ) ) -}}
{{- print "false" -}}
{{- else -}}
{{- print "true" -}}
{{- end -}}
{{- end -}}
{{/*
Returns the appropriate ingress `backend` fields depending on the Kubernetes API version.
e.g.: `{{ include "common.ingress.backend" (dict "serviceName" "backendName" "servicePort" "backendPort" "context" $) }}`
Where the dict must contain the following entries:
- `serviceName` {String} - Name of an existing service backend
- `servicePort` {String|Number} - Port name or port number of the service.
- `context` {Dict} - (Parent) Context for the template evaluation required for the API version detection.
*/}}
{{- define "ingress.backend" -}}
{{- $apiVersion := ( include "capabilities.ingress.apiVersion" .context ) -}}
{{- if or ( eq $apiVersion "extensions/v1beta1" ) ( eq $apiVersion "networking.k8s.io/v1beta1" ) -}}
serviceName: {{ .serviceName }}
servicePort: {{ .servicePort }}
{{- else -}}
service:
name: {{ .serviceName }}
port:
{{- if typeIs "string" .servicePort }}
name: {{ .servicePort }}
{{- else if or ( typeIs "int" .servicePort ) ( typeIs "float64" .servicePort ) }}
number: {{ .servicePort }}
{{- end }}
{{- end -}}
{{- end -}}
@@ -0,0 +1,18 @@
{{- if .Values.authenticatedEmailsFile.enabled }}
{{- if and (.Values.authenticatedEmailsFile.restricted_access) (eq .Values.authenticatedEmailsFile.persistence "configmap") }}
apiVersion: v1
kind: ConfigMap
metadata:
labels:
app: {{ template "oauth2-proxy.name" . }}
{{- include "oauth2-proxy.labels" . | indent 4 }}
{{- if .Values.authenticatedEmailsFile.annotations }}
annotations:
{{ toYaml .Values.authenticatedEmailsFile.annotations | indent 4 }}
{{- end }}
name: {{ template "oauth2-proxy.fullname" . }}-accesslist
namespace: {{ template "oauth2-proxy.namespace" $ }}
data:
{{ default "restricted_user_access" .Values.authenticatedEmailsFile.restrictedUserAccessKey }}: {{ .Values.authenticatedEmailsFile.restricted_access | quote }}
{{- end }}
{{- end }}
+18
View File
@@ -0,0 +1,18 @@
{{- if not .Values.config.existingConfig }}
{{- if .Values.config.configFile }}
apiVersion: v1
kind: ConfigMap
metadata:
{{- if .Values.config.annotations }}
annotations:
{{ toYaml .Values.config.annotations | indent 4 }}
{{- end }}
labels:
app: {{ template "oauth2-proxy.name" . }}
{{- include "oauth2-proxy.labels" . | indent 4 }}
name: {{ template "oauth2-proxy.fullname" . }}
namespace: {{ template "oauth2-proxy.namespace" $ }}
data:
oauth2_proxy.cfg: {{ tpl .Values.config.configFile $ | quote }}
{{- end }}
{{- end }}
+367
View File
@@ -0,0 +1,367 @@
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: {{ template "oauth2-proxy.name" . }}
{{- include "oauth2-proxy.labels" . | indent 4 }}
{{- if .Values.deploymentAnnotations }}
annotations:
{{ toYaml .Values.deploymentAnnotations | indent 8 }}
{{- end }}
name: {{ template "oauth2-proxy.fullname" . }}
namespace: {{ template "oauth2-proxy.namespace" $ }}
spec:
replicas: {{ .Values.replicaCount }}
{{- if .Values.revisionHistoryLimit }}
revisionHistoryLimit: {{ .Values.revisionHistoryLimit }}
{{- end }}
selector:
matchLabels:
{{- include "oauth2-proxy.selectorLabels" . | indent 6 }}
template:
metadata:
annotations:
checksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}
{{- if .Values.alphaConfig.enabled }}
checksum/alpha-config: {{ include (print $.Template.BasePath "/secret-alpha.yaml") . | sha256sum }}
{{- end }}
checksum/config-emails: {{ include (print $.Template.BasePath "/configmap-authenticated-emails-file.yaml") . | sha256sum }}
checksum/secret: {{ include (print $.Template.BasePath "/secret.yaml") . | sha256sum }}
checksum/google-secret: {{ include (print $.Template.BasePath "/google-secret.yaml") . | sha256sum }}
checksum/redis-secret: {{ include (print $.Template.BasePath "/redis-secret.yaml") . | sha256sum }}
{{- if .Values.htpasswdFile.enabled }}
checksum/htpasswd: {{ include (print $.Template.BasePath "/secret-htpasswd-file.yaml") . | sha256sum }}
{{- end }}
{{- if .Values.podAnnotations }}
{{ toYaml .Values.podAnnotations | indent 8 }}
{{- end }}
labels:
app: {{ template "oauth2-proxy.name" . }}
{{- include "oauth2-proxy.labels" . | indent 8 }}
{{- if .Values.podLabels }}
{{ toYaml .Values.podLabels | indent 8 }}
{{- end }}
spec:
{{- if .Values.priorityClassName }}
priorityClassName: "{{ .Values.priorityClassName }}"
{{- end }}
{{- with .Values.podSecurityContext }}
securityContext:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ template "oauth2-proxy.serviceAccountName" . }}
automountServiceAccountToken : {{ .Values.serviceAccount.automountServiceAccountToken }}
{{- if .Values.hostAlias.enabled }}
hostAliases:
- ip: {{ .Values.hostAlias.ip }}
hostnames:
- {{ .Values.hostAlias.hostname }}
{{- end }}
{{- if and .Values.redis.enabled .Values.initContainers.waitForRedis.enabled }}
initContainers:
- name: wait-for-redis
image: "docker.io/bitnami/kubectl:{{ include "kubectl.version" . }}"
args:
- wait
- pod/{{ include "oauth2-proxy.redis.fullname" . }}-master-0
- --for=condition=ready
- --timeout={{ .Values.initContainers.waitForRedis.timeout }}s
{{- if .Values.initContainers.waitForRedis.securityContext.enabled }}
{{- $securityContext := unset .Values.initContainers.waitForRedis.securityContext "enabled" }}
securityContext:
{{- toYaml $securityContext | nindent 10 }}
{{- end }}
{{- end }}
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:v{{ include "oauth2-proxy.version" . }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
args:
{{- if .Values.alphaConfig.enabled }}
- --alpha-config=/etc/oauth2_proxy/oauth2_proxy.yml
{{- else }}
- --http-address=0.0.0.0:4180
- --https-address=0.0.0.0:4443
{{- if .Values.metrics.enabled }}
- --metrics-address=0.0.0.0:44180
{{- end }}
{{- end }}
{{- if .Values.config.cookieName }}
- --cookie-name={{ .Values.config.cookieName }}
{{- end }}
{{- if kindIs "map" .Values.extraArgs }}
{{- range $key, $value := .Values.extraArgs }}
{{- if not (kindIs "invalid" $value) }}
- --{{ $key }}={{ tpl ($value | toString) $ }}
{{- else }}
- --{{ $key }}
{{- end }}
{{- end }}
{{- end }}
{{- if kindIs "slice" .Values.extraArgs }}
{{- with .Values.extraArgs }}
{{- toYaml . | nindent 10 }}
{{- end }}
{{- end }}
{{- if or .Values.config.existingConfig .Values.config.configFile }}
- --config=/etc/oauth2_proxy/oauth2_proxy.cfg
{{- end }}
{{- if .Values.authenticatedEmailsFile.enabled }}
{{- if .Values.authenticatedEmailsFile.template }}
- --authenticated-emails-file=/etc/oauth2-proxy/{{ .Values.authenticatedEmailsFile.template }}
{{- else }}
- --authenticated-emails-file=/etc/oauth2-proxy/authenticated-emails-list
{{- end }}
{{- end }}
{{- with .Values.config.google }}
{{- if and .adminEmail (or .serviceAccountJson .existingSecret .useApplicationDefaultCredentials) }}
- --google-admin-email={{ .adminEmail }}
{{- if .useApplicationDefaultCredentials }}
- --google-use-application-default-credentials=true
{{- else }}
- --google-service-account-json=/google/service-account.json
{{- end }}
{{- if .targetPrincipal }}
- --google-target-principal={{ .targetPrincipal }}
{{- end }}
{{- end }}
{{- if .groups }}
{{- range $group := .groups }}
- --google-group={{ $group }}
{{- end }}
{{- end }}
{{- end }}
{{- if .Values.htpasswdFile.enabled }}
- --htpasswd-file=/etc/oauth2_proxy/htpasswd/users.txt
{{- end }}
env:
{{- if .Values.proxyVarsAsSecrets }}
- name: OAUTH2_PROXY_CLIENT_ID
valueFrom:
secretKeyRef:
name: {{ template "oauth2-proxy.secretName" . }}
key: client-id
- name: OAUTH2_PROXY_CLIENT_SECRET
valueFrom:
secretKeyRef:
name: {{ template "oauth2-proxy.secretName" . }}
key: client-secret
- name: OAUTH2_PROXY_COOKIE_SECRET
valueFrom:
secretKeyRef:
name: {{ template "oauth2-proxy.secretName" . }}
key: cookie-secret
{{- end }}
{{- if eq (default "cookie" .Values.sessionStorage.type) "redis" }}
- name: OAUTH2_PROXY_SESSION_STORE_TYPE
value: "redis"
{{- if or .Values.sessionStorage.redis.existingSecret .Values.sessionStorage.redis.password (and .Values.redis.enabled (.Values.redis.auth).enabled )}}
- name: OAUTH2_PROXY_REDIS_PASSWORD
valueFrom:
secretKeyRef:
{{- if .Values.sessionStorage.redis.existingSecret }}
name: {{ .Values.sessionStorage.redis.existingSecret }}
{{- else if .Values.sessionStorage.redis.password }}
name: {{ template "oauth2-proxy.fullname" . }}-redis-access
{{- else }}
name: {{ include "oauth2-proxy.redis.fullname" . }}
{{- end }}
key: {{ .Values.sessionStorage.redis.passwordKey }}
{{- end }}
{{- if eq (default "" .Values.sessionStorage.redis.clientType) "standalone" }}
- name: OAUTH2_PROXY_REDIS_CONNECTION_URL
value: {{ include "oauth2-proxy.redis.StandaloneUrl" . }}
{{- else if eq (default "" .Values.sessionStorage.redis.clientType) "cluster" }}
- name: OAUTH2_PROXY_REDIS_USE_CLUSTER
value: "true"
- name: OAUTH2_PROXY_REDIS_CLUSTER_CONNECTION_URLS
value: {{ .Values.sessionStorage.redis.cluster.connectionUrls }}
{{- else if eq (default "" .Values.sessionStorage.redis.clientType) "sentinel" }}
- name: OAUTH2_PROXY_REDIS_USE_SENTINEL
value: "true"
- name: OAUTH2_PROXY_REDIS_SENTINEL_MASTER_NAME
value: {{ .Values.sessionStorage.redis.sentinel.masterName }}
- name: OAUTH2_PROXY_REDIS_SENTINEL_CONNECTION_URLS
value: {{ .Values.sessionStorage.redis.sentinel.connectionUrls }}
{{- if or .Values.sessionStorage.redis.sentinel.existingSecret .Values.sessionStorage.redis.existingSecret .Values.sessionStorage.redis.sentinel.password }}
- name: OAUTH2_PROXY_REDIS_SENTINEL_PASSWORD
valueFrom:
secretKeyRef:
{{- if or .Values.sessionStorage.redis.sentinel.existingSecret .Values.sessionStorage.redis.existingSecret }}
name: {{ .Values.sessionStorage.redis.sentinel.existingSecret | default .Values.sessionStorage.redis.existingSecret }}
{{- else }}
name: {{ template "oauth2-proxy.fullname" . }}-redis-access
{{- end }}
key: {{ .Values.sessionStorage.redis.sentinel.passwordKey }}
{{- end }}
{{- end }}
{{- end }}
{{- if .Values.extraEnv }}
{{ tpl (toYaml .Values.extraEnv) . | indent 8 }}
{{- end }}
ports:
{{- if .Values.containerPort }}
- containerPort: {{ .Values.containerPort }}
{{- else if (and (eq .Values.httpScheme "http") (empty .Values.containerPort)) }}
- containerPort: 4180
{{- else if (and (eq .Values.httpScheme "https") (empty .Values.containerPort)) }}
- containerPort: 4443
{{- else }}
{{- end}}
name: {{ .Values.httpScheme }}
protocol: TCP
{{- if .Values.metrics.enabled }}
- containerPort: 44180
protocol: TCP
name: metrics
{{- end }}
{{- if .Values.livenessProbe.enabled }}
livenessProbe:
httpGet:
path: /ping
port: {{ .Values.httpScheme }}
scheme: {{ .Values.httpScheme | upper }}
initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds }}
timeoutSeconds: {{ .Values.livenessProbe.timeoutSeconds }}
{{- end }}
{{- if .Values.readinessProbe.enabled }}
readinessProbe:
httpGet:
path: {{ if gt (include "oauth2-proxy.version" .) "7.4.0" }}/ready{{ else }}/ping{{ end }}
port: {{ .Values.httpScheme }}
scheme: {{ .Values.httpScheme | upper }}
initialDelaySeconds: {{ .Values.readinessProbe.initialDelaySeconds }}
timeoutSeconds: {{ .Values.readinessProbe.timeoutSeconds }}
successThreshold: {{ .Values.readinessProbe.successThreshold }}
periodSeconds: {{ .Values.readinessProbe.periodSeconds }}
{{- end }}
resources:
{{ toYaml .Values.resources | indent 10 }}
volumeMounts:
{{- with .Values.config.google }}
{{- if and .adminEmail (or .serviceAccountJson .existingSecret) }}
- name: google-secret
mountPath: /google
readOnly: true
{{- end }}
{{- end }}
{{- if or .Values.config.existingConfig .Values.config.configFile }}
- mountPath: /etc/oauth2_proxy/oauth2_proxy.cfg
name: configmain
subPath: oauth2_proxy.cfg
{{- end }}
{{- if .Values.alphaConfig.enabled }}
- mountPath: /etc/oauth2_proxy/oauth2_proxy.yml
name: configalpha
subPath: oauth2_proxy.yml
{{- end }}
{{- if .Values.authenticatedEmailsFile.enabled }}
- mountPath: /etc/oauth2-proxy
name: configaccesslist
readOnly: true
{{- end }}
{{- if .Values.htpasswdFile.enabled }}
- mountPath: /etc/oauth2_proxy/htpasswd
name: {{ template "oauth2-proxy.fullname" . }}-htpasswd-file
readOnly: true
{{- end }}
{{- if ne (len .Values.extraVolumeMounts) 0 }}
{{ toYaml .Values.extraVolumeMounts | indent 8 }}
{{- end }}
{{- if .Values.securityContext.enabled }}
{{- $securityContext := unset .Values.securityContext "enabled" }}
securityContext:
{{- toYaml $securityContext | nindent 10 }}
{{- end }}
{{- if .Values.extraContainers }}
{{- toYaml .Values.extraContainers | nindent 6 }}
{{- end }}
volumes:
{{- with .Values.config.google }}
{{- if and .adminEmail (or .serviceAccountJson .existingSecret) }}
- name: google-secret
secret:
secretName: {{ if .existingSecret }}{{ .existingSecret }}{{ else }} {{ template "oauth2-proxy.secretName" $ }}-google{{ end }}
{{- end }}
{{- end }}
{{- if .Values.htpasswdFile.enabled }}
- name: {{ template "oauth2-proxy.fullname" . }}-htpasswd-file
secret:
secretName: {{ if .Values.htpasswdFile.existingSecret }}{{ .Values.htpasswdFile.existingSecret }}{{ else }} {{ template "oauth2-proxy.fullname" . }}-htpasswd-file {{ end }}
{{- end }}
{{- if and (.Values.authenticatedEmailsFile.enabled) (eq .Values.authenticatedEmailsFile.persistence "secret") }}
- name: configaccesslist
secret:
items:
- key: {{ default "restricted_user_access" .Values.authenticatedEmailsFile.restrictedUserAccessKey }}
{{- if .Values.authenticatedEmailsFile.template }}
path: {{ .Values.authenticatedEmailsFile.template }}
{{- else }}
path: authenticated-emails-list
{{- end }}
{{- if .Values.authenticatedEmailsFile.template }}
secretName: {{ .Values.authenticatedEmailsFile.template }}
{{- else }}
secretName: {{ template "oauth2-proxy.fullname" . }}-accesslist
{{- end }}
{{- end }}
{{- if or .Values.config.existingConfig .Values.config.configFile }}
- configMap:
defaultMode: 420
name: {{ if .Values.config.existingConfig }}{{ .Values.config.existingConfig }}{{ else }}{{ template "oauth2-proxy.fullname" . }}{{ end }}
name: configmain
{{- end }}
{{- if .Values.alphaConfig.enabled }}
{{- if .Values.alphaConfig.existingConfig }}
- configMap:
defaultMode: 420
name: {{ .Values.alphaConfig.existingConfig }}
name: configalpha
{{- else }}
- secret:
defaultMode: 420
secretName: {{ if .Values.alphaConfig.existingSecret }}{{ .Values.alphaConfig.existingSecret }}{{ else }}{{ template "oauth2-proxy.fullname" . }}-alpha{{ end }}
name: configalpha
{{- end }}
{{- end }}
{{- if ne (len .Values.extraVolumes) 0 }}
{{ toYaml .Values.extraVolumes | indent 6 }}
{{- end }}
{{- if and (.Values.authenticatedEmailsFile.enabled) (eq .Values.authenticatedEmailsFile.persistence "configmap") }}
- configMap:
{{- if .Values.authenticatedEmailsFile.template }}
name: {{ .Values.authenticatedEmailsFile.template }}
{{- else }}
name: {{ template "oauth2-proxy.fullname" . }}-accesslist
{{- end }}
items:
- key: {{ default "restricted_user_access" .Values.authenticatedEmailsFile.restrictedUserAccessKey }}
{{- if .Values.authenticatedEmailsFile.template }}
path: {{ .Values.authenticatedEmailsFile.template }}
{{- else }}
path: authenticated-emails-list
{{- end }}
name: configaccesslist
{{- end }}
{{- if .Values.imagePullSecrets }}
imagePullSecrets:
{{ toYaml .Values.imagePullSecrets | indent 8 }}
{{- end }}
{{- if .Values.affinity }}
affinity:
{{ toYaml .Values.affinity | indent 8 }}
{{- end }}
{{- if .Values.nodeSelector }}
nodeSelector:
{{ toYaml .Values.nodeSelector | indent 8 }}
{{- end }}
tolerations:
{{ toYaml .Values.tolerations | indent 8 }}
{{- with .Values.topologySpreadConstraints }}
topologySpreadConstraints:
{{- toYaml . | nindent 8 }}
{{- end }}
+12
View File
@@ -0,0 +1,12 @@
{{- if .Values.checkDeprecation }}
{{- if .Values.service.port }}
{{ fail "`service.port` does no longer exist. It has been renamed to `service.portNumber`" }}
{{- end }}
{{- if eq ( include "capabilities.ingress.apiVersion" . ) "networking.k8s.io/v1" -}}
{{- range .Values.ingress.extraPaths }}
{{- if or (.backend.serviceName) (.backend.servicePort) }}
{{ fail "Please update the format of your `ingress.extraPaths` to the new ingress apiVersion `networking.k8s.io/v1` format" }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
@@ -0,0 +1,4 @@
{{ range .Values.extraObjects }}
---
{{ tpl (toYaml .) $ }}
{{ end }}
+13
View File
@@ -0,0 +1,13 @@
{{- if and .Values.config.google (and (not .Values.config.google.existingSecret) (not .Values.config.google.useApplicationDefaultCredentials)) }}
apiVersion: v1
kind: Secret
metadata:
labels:
app: {{ template "oauth2-proxy.name" . }}
{{- include "oauth2-proxy.labels" . | indent 4 }}
name: {{ template "oauth2-proxy.fullname" . }}-google
namespace: {{ template "oauth2-proxy.namespace" $ }}
type: Opaque
data:
service-account.json: {{ .Values.config.google.serviceAccountJson | b64enc | quote }}
{{- end -}}
+44
View File
@@ -0,0 +1,44 @@
{{- if .Values.ingress.enabled -}}
{{- $serviceName := include "oauth2-proxy.fullname" . -}}
{{- $servicePort := .Values.service.portNumber -}}
{{- $ingressPath := .Values.ingress.path -}}
{{- $ingressPathType := .Values.ingress.pathType -}}
{{- $extraPaths := .Values.ingress.extraPaths -}}
apiVersion: {{ include "capabilities.ingress.apiVersion" . }}
kind: Ingress
metadata:
labels:
app: {{ template "oauth2-proxy.name" . }}
{{- include "oauth2-proxy.labels" . | indent 4 }}
{{- if .Values.ingress.labels }}
{{ toYaml .Values.ingress.labels | indent 4 }}
{{- end }}
name: {{ template "oauth2-proxy.fullname" . }}
namespace: {{ template "oauth2-proxy.namespace" $ }}
{{- with .Values.ingress.annotations }}
annotations:
{{ toYaml . | indent 4 }}
{{- end }}
spec:
{{- if and .Values.ingress.className ( eq "true" ( include "ingress.supportsIngressClassName" . ) ) }}
ingressClassName: {{ .Values.ingress.className | quote }}
{{- end }}
rules:
{{- range $host := .Values.ingress.hosts }}
- host: {{ tpl $host $ | quote }}
http:
paths:
{{- if $extraPaths }}
{{ toYaml $extraPaths | indent 10 }}
{{- end }}
- path: {{ $ingressPath }}
{{- if eq "true" ( include "ingress.supportsPathType" $ ) }}
pathType: {{ $ingressPathType }}
{{- end }}
backend: {{- include "ingress.backend" ( dict "serviceName" $serviceName "servicePort" $servicePort "context" $ ) | nindent 14 }}
{{- end -}}
{{- if .Values.ingress.tls }}
tls:
{{ tpl (toYaml .Values.ingress.tls) $ | indent 4 }}
{{- end -}}
{{- end -}}
@@ -0,0 +1,15 @@
{{- if and .Values.podDisruptionBudget.enabled (gt (.Values.replicaCount | int) 1) }}
apiVersion: {{ include "capabilities.podDisruptionBudget.apiVersion" . }}
kind: PodDisruptionBudget
metadata:
labels:
app: {{ template "oauth2-proxy.name" . }}
{{- include "oauth2-proxy.labels" . | indent 4 }}
name: {{ template "oauth2-proxy.fullname" . }}
namespace: {{ template "oauth2-proxy.namespace" $ }}
spec:
selector:
matchLabels:
{{- include "oauth2-proxy.selectorLabels" . | indent 6 }}
minAvailable: {{ .Values.podDisruptionBudget.minAvailable }}
{{- end }}
+23
View File
@@ -0,0 +1,23 @@
{{- $name := include "oauth2-proxy.name" . -}}
{{- $fullName := include "oauth2-proxy.fullname" . -}}
{{- $labels := include "oauth2-proxy.labels" . -}}
{{- with .Values.sessionStorage }}
{{- if and (eq .type "redis") (not .redis.existingSecret) (or .redis.password .redis.sentinel.password) }}
apiVersion: v1
kind: Secret
metadata:
labels:
app: {{ $name }}
{{- $labels | indent 4 }}
name: {{ $fullName }}-redis-access
namespace: {{ template "oauth2-proxy.namespace" $ }}
type: Opaque
data:
{{- if and .redis.password (not .redis.existingSecret) }}
{{ .redis.passwordKey }}: {{ .redis.password | b64enc | quote }}
{{- end }}
{{- if and .redis.sentinel.password (not .redis.sentinel.existingSecret) (ne .redis.sentinel.passwordKey .redis.passwordKey) }}
{{ .redis.sentinel.passwordKey }}: {{ .redis.sentinel.password | b64enc | quote }}
{{- end }}
{{- end }}
{{- end }}
+39
View File
@@ -0,0 +1,39 @@
{{-
if and
.Values.alphaConfig.enabled
(not .Values.alphaConfig.existingConfig)
(not .Values.alphaConfig.existingSecret)
}}
apiVersion: v1
kind: Secret
metadata:
{{- if .Values.alphaConfig.annotations }}
annotations: {{- toYaml .Values.alphaConfig.annotations | nindent 4 }}
{{- end }}
labels:
app: {{ template "oauth2-proxy.name" . }}
{{- include "oauth2-proxy.labels" . | indent 4 }}
name: {{ template "oauth2-proxy.fullname" . }}-alpha
namespace: {{ template "oauth2-proxy.namespace" $ }}
stringData:
oauth2_proxy.yml: |
---
server:
BindAddress: '0.0.0.0:4180'
{{- if .Values.alphaConfig.serverConfigData }}
{{- toYaml .Values.alphaConfig.serverConfigData | nindent 6 }}
{{- end }}
{{- if .Values.metrics.enabled }}
metricsServer:
BindAddress: '0.0.0.0:44180'
{{- if .Values.alphaConfig.metricsConfigData }}
{{- toYaml .Values.alphaConfig.metricsConfigData | nindent 6 }}
{{- end }}
{{- end }}
{{- if .Values.alphaConfig.configData }}
{{- toYaml .Values.alphaConfig.configData | nindent 4 }}
{{- end }}
{{- if .Values.alphaConfig.configFile }}
{{- tpl .Values.alphaConfig.configFile $ | nindent 4 }}
{{- end }}
{{- end }}
@@ -0,0 +1,19 @@
{{- if .Values.authenticatedEmailsFile.enabled }}
{{- if and (.Values.authenticatedEmailsFile.restricted_access) (eq .Values.authenticatedEmailsFile.persistence "secret") }}
apiVersion: v1
kind: Secret
type: Opaque
metadata:
labels:
app: {{ template "oauth2-proxy.name" . }}
{{- include "oauth2-proxy.labels" . | indent 4 }}
{{- if .Values.authenticatedEmailsFile.annotations }}
annotations:
{{ toYaml .Values.authenticatedEmailsFile.annotations | indent 4 }}
{{- end }}
name: {{ template "oauth2-proxy.fullname" . }}-accesslist
namespace: {{ template "oauth2-proxy.namespace" $ }}
data:
{{ default "restricted_user_access" .Values.authenticatedEmailsFile.restrictedUserAccessKey }}: {{ .Values.authenticatedEmailsFile.restricted_access | b64enc }}
{{- end }}
{{- end }}
@@ -0,0 +1,16 @@
{{- if and .Values.htpasswdFile.enabled (not .Values.htpasswdFile.existingSecret) }}
apiVersion: v1
kind: Secret
metadata:
labels:
app: {{ template "oauth2-proxy.name" . }}
{{- include "oauth2-proxy.labels" . | indent 4 }}
name: {{ template "oauth2-proxy.fullname" . }}-htpasswd-file
namespace: {{ template "oauth2-proxy.namespace" $ }}
type: Opaque
stringData:
users.txt: |-
{{- range $entries := .Values.htpasswdFile.entries }}
{{ $entries }}
{{- end -}}
{{- end }}
+19
View File
@@ -0,0 +1,19 @@
{{- if and (not .Values.config.existingSecret) (.Values.proxyVarsAsSecrets) }}
apiVersion: v1
kind: Secret
metadata:
{{- if .Values.config.annotations }}
annotations:
{{ toYaml .Values.config.annotations | indent 4 }}
{{- end }}
labels:
app: {{ template "oauth2-proxy.name" . }}
{{- include "oauth2-proxy.labels" . | indent 4 }}
name: {{ template "oauth2-proxy.fullname" . }}
namespace: {{ template "oauth2-proxy.namespace" $ }}
type: Opaque
data:
cookie-secret: {{ tpl .Values.config.cookieSecret $ | b64enc | quote }}
client-secret: {{ tpl .Values.config.clientSecret $ | b64enc | quote }}
client-id: {{ tpl .Values.config.clientID $ | b64enc | quote }}
{{- end -}}
+55
View File
@@ -0,0 +1,55 @@
apiVersion: v1
kind: Service
metadata:
labels:
app: {{ template "oauth2-proxy.name" . }}
{{- include "oauth2-proxy.labels" . | indent 4 }}
name: {{ template "oauth2-proxy.fullname" . }}
namespace: {{ template "oauth2-proxy.namespace" $ }}
{{- if .Values.service.annotations }}
annotations:
{{ toYaml .Values.service.annotations | indent 4 }}
{{- end }}
spec:
{{- if (or (eq .Values.service.type "ClusterIP") (empty .Values.service.type)) }}
type: ClusterIP
{{- if .Values.service.clusterIP }}
clusterIP: {{ .Values.service.clusterIP }}
{{end}}
{{- else if eq .Values.service.type "LoadBalancer" }}
type: {{ .Values.service.type }}
{{- if .Values.service.loadBalancerIP }}
loadBalancerIP: {{ .Values.service.loadBalancerIP }}
{{- end }}
{{- if .Values.service.loadBalancerSourceRanges }}
loadBalancerSourceRanges:
{{ toYaml .Values.service.loadBalancerSourceRanges | indent 4 }}
{{- end -}}
{{- else }}
type: {{ .Values.service.type }}
{{- end }}
ports:
- port: {{ .Values.service.portNumber }}
targetPort: {{ .Values.httpScheme }}
{{- if (and (eq .Values.service.type "NodePort") (not (empty .Values.service.nodePort))) }}
nodePort: {{ .Values.service.nodePort }}
{{- end }}
protocol: TCP
{{- with .Values.service.appProtocol }}
appProtocol: {{ . }}
{{- end }}
name: {{ .Values.httpScheme }}
{{- if and .Values.metrics.enabled .Values.metrics.port }}
- port: {{ .Values.metrics.port }}
protocol: TCP
{{- with .Values.metrics.service.appProtocol }}
appProtocol: {{ . }}
{{- end }}
targetPort: metrics
{{- if (and (eq .Values.service.type "NodePort") (not (empty .Values.metrics.nodePort))) }}
nodePort: {{ .Values.metrics.nodePort }}
{{- end }}
name: metrics
{{- end }}
selector:
{{- include "oauth2-proxy.selectorLabels" . | indent 4 }}
@@ -0,0 +1,58 @@
{{- if or .Values.serviceAccount.enabled -}}
{{- $fullName := include "oauth2-proxy.fullname" . -}}
{{- $saName := include "oauth2-proxy.serviceAccountName" . -}}
{{- $name := include "oauth2-proxy.name" . -}}
{{- $namespace := include "oauth2-proxy.namespace" $ -}}
{{- $labels := include "oauth2-proxy.labels" . -}}
---
apiVersion: v1
kind: ServiceAccount
metadata:
{{- with .Values.serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
labels:
app: {{ $name }}
{{- $labels | indent 4 }}
name: {{ $saName }}
namespace: {{ $namespace }}
automountServiceAccountToken : {{ .Values.serviceAccount.automountServiceAccountToken }}
{{- if and .Values.redis.enabled .Values.initContainers.waitForRedis.enabled }}
---
kind: Role
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: {{ $fullName }}-watch-redis
labels:
app: {{ $name }}
{{- $labels | nindent 4 }}
rules:
- apiGroups:
- ""
resources:
- pods
resourceNames:
- "{{ include "oauth2-proxy.redis.fullname" . }}-master-0"
verbs:
- get
- list
- watch
---
kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: {{ $saName }}-watch-redis
labels:
app: {{ $name }}
{{- $labels | nindent 4 }}
subjects:
- kind: ServiceAccount
name: {{ $saName }}
apiGroup: ""
roleRef:
kind: Role
name: {{ $fullName }}-watch-redis
apiGroup: ""
{{- end -}}
{{- end -}}
@@ -0,0 +1,31 @@
{{- if and .Values.metrics.enabled .Values.metrics.servicemonitor.enabled }}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: {{ template "oauth2-proxy.fullname" . }}
{{- if .Values.metrics.servicemonitor.namespace }}
namespace: {{ .Values.metrics.servicemonitor.namespace }}
{{- else }}
namespace: {{ template "oauth2-proxy.namespace" $ }}
{{- end }}
labels:
prometheus: {{ .Values.metrics.servicemonitor.prometheusInstance }}
app: {{ template "oauth2-proxy.name" . }}
{{- include "oauth2-proxy.labels" . | indent 4 }}
{{- if .Values.metrics.servicemonitor.labels }}
{{ toYaml .Values.metrics.servicemonitor.labels | indent 4}}
{{- end }}
spec:
jobLabel: {{ template "oauth2-proxy.fullname" . }}
selector:
matchLabels:
{{- include "oauth2-proxy.selectorLabels" . | indent 6 }}
namespaceSelector:
matchNames:
- {{ template "oauth2-proxy.namespace" $ }}
endpoints:
- port: metrics
path: "/metrics"
interval: {{ .Values.metrics.servicemonitor.interval }}
scrapeTimeout: {{ .Values.metrics.servicemonitor.scrapeTimeout }}
{{- end }}