Run oidc discovery provider as separate pod using workload api

Signed-off-by: Marco Franssen <[email protected]>
This commit is contained in:
Marco Franssen
2023-02-18 13:04:01 +01:00
committed by Marco Franssen
parent 31bce3b09e
commit f2d7aa1f62
5 changed files with 112 additions and 40 deletions
+20
View File
@@ -90,6 +90,26 @@ app.kubernetes.io/name: {{ include "spire.name" . }}-agent
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}
{{/*
Common oidc labels
*/}}
{{- define "spire.oidc.labels" -}}
helm.sh/chart: {{ include "spire.chart" . }}
{{ include "spire.oidc.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}
{{/*
Selector oidc labels
*/}}
{{- define "spire.oidc.selectorLabels" -}}
app.kubernetes.io/name: {{ include "spire.name" . }}-oidc
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}
{{/*
Create the name of the service account to use
*/}}
@@ -0,0 +1,86 @@
{{- if eq (.Values.oidc.enabled | toString) "true" }}
{{- $fullname := include "spire.fullname" . }}
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ printf "%s-oidc" $fullname }}
labels:
{{- include "spire.oidc.labels" . | nindent 4 }}
spec:
{{- if not .Values.autoscaling.enabled }}
replicas: {{ .Values.replicaCount }}
{{- end }}
selector:
matchLabels:
{{- include "spire.oidc.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "spire.oidc.selectorLabels" . | nindent 8 }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- range . }}
- name: {{ printf "%s-%s" $fullname .name }}
{{- end }}
{{- end }}
serviceAccountName: {{ include "spire.serviceAccountName" . }}-agent
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: spire-oidc
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.oidc.image.repository }}:{{ .Values.oidc.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.oidc.image.pullPolicy }}
args:
- -config
- /run/spire/oidc/config/oidc-discovery-provider.conf
ports:
- containerPort: {{ .Values.oidc.service.port }}
name: http
- containerPort: 443
name: https
volumeMounts:
- name: spire-agent-socket
mountPath: {{ include "spire.sockets" . }}
readOnly: true
- name: spire-oidc-config
mountPath: /run/spire/oidc/config/
readOnly: true
readinessProbe:
exec:
command: ["/bin/ps", "aux", " ||", "grep", "oidc-discovery-provider -config /run/spire/oidc/config/oidc-discovery-provider.conf"]
initialDelaySeconds: 5
periodSeconds: 5
livenessProbe:
httpGet:
path: /.well-known/openid-configuration
port: http
resources:
{{- toYaml .Values.resources | nindent 12 }}
volumes:
- name: spire-agent-socket
hostPath:
path: /run/spire/sockets
type: DirectoryOrCreate
- name: spire-oidc-config
configMap:
name: {{ include "spire.fullname" . }}-oidc-discovery-provider
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
{{ end }}
@@ -17,7 +17,8 @@ data:
tos_accepted = {{ .Values.oidc.acme.tosAccepted }}
email = "{{ .Values.oidc.acme.emailAddress }}"
}
server_api {
address = "unix://{{ include "spire.sockets" . }}/registration.sock"
workload_api {
socket_path = "{{ include "spire.sockets" . }}/agent.sock"
trust_domain = "{{ .Values.spire.trustDomain }}"
}
{{ end }}
+3 -3
View File
@@ -13,10 +13,10 @@ spec:
ports:
- name: http
port: {{ .Values.oidc.service.port }}
targetPort: oidc-http
targetPort: http
- name: https
port: 443
targetPort: oidc-https
targetPort: https
selector:
{{- include "spire.server.selectorLabels" . | nindent 4 }}
{{- include "spire.oidc.selectorLabels" . | nindent 4 }}
{{ end }}
@@ -91,36 +91,6 @@ spec:
- name: spire-workload-registrar-config
mountPath: /run/spire/k8s-workload-registrar/config
readOnly: true
{{- if eq (.Values.oidc.enabled | toString) "true" }}
- name: spire-oidc
image: "{{ .Values.oidc.image.repository }}:{{ .Values.oidc.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.oidc.image.pullPolicy }}
args:
- -config
- /run/spire/oidc/config/oidc-discovery-provider.conf
ports:
- containerPort: {{ .Values.oidc.service.port }}
name: oidc-http
- containerPort: 443
name: oidc-https
volumeMounts:
- name: spire-server-socket
mountPath: {{ include "spire.sockets" . }}
readOnly: true
- name: spire-oidc-config
mountPath: /run/spire/oidc/config/
readOnly: true
{{- if eq (.Values.server.dataStorage.enabled | toString) "true" }}
- name: spire-data
mountPath: /run/spire/data
readOnly: false
{{ end }}
readinessProbe:
exec:
command: ["/bin/ps", "aux", " ||", "grep", "oidc-discovery-provider -config /run/spire/oidc/config/oidc-discovery-provider.conf"]
initialDelaySeconds: 5
periodSeconds: 5
{{ end }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
@@ -140,11 +110,6 @@ spec:
- name: spire-config
configMap:
name: {{ include "spire.fullname" . }}-server
{{- if eq (.Values.oidc.enabled | toString) "true" }}
- name: spire-oidc-config
configMap:
name: {{ include "spire.fullname" . }}-oidc-discovery-provider
{{ end }}
- name: spire-server-socket
hostPath:
path: /run/spire/server-sockets