Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: if enabled - let cert-manager handle certs #82

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions charts/osiris/templates/endpoints-hijacker-certificate.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{{- if .Values.certmanager.enabled -}}
apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
name: {{ include "osiris.fullname" . }}-endpoints-hijacker-cert
labels:
app.kubernetes.io/name: {{ include "osiris.name" . }}-endpoints-hijacker
helm.sh/chart: {{ include "osiris.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
spec:
commonName: {{ include "osiris.fullname" . }}-endpoints-hijacker-cert
dnsNames:
- {{ include "osiris.fullname" . }}-endpoints-hijacker.{{ .Release.Namespace }}
- {{ include "osiris.fullname" . }}-endpoints-hijacker.{{ .Release.Namespace }}.svc
- {{ include "osiris.fullname" . }}-endpoints-hijacker.{{ .Release.Namespace }}.svc.cluster
- {{ include "osiris.fullname" . }}-endpoints-hijacker.{{ .Release.Namespace }}.svc.cluster.local
issuerRef:
kind: Issuer
name: {{ include "osiris.fullname" . }}-selfsigned-issuer
secretName: {{ include "osiris.fullname" . }}-endpoints-hijacker-cert
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
{{- $altName3 := printf "%s-endpoints-hijacker.%s.svc.cluster" (include "osiris.fullname" .) .Release.Namespace }}
{{- $altName4 := printf "%s-endpoints-hijacker.%s.svc.cluster.local" (include "osiris.fullname" .) .Release.Namespace }}
{{- $cert := genSignedCert $cn nil (list $altName1 $altName2 $altName3 $altName4) 3650 $ca }}

{{- if not (.Values.certmanager.enabled) -}}
apiVersion: v1
kind: Secret
metadata:
Expand All @@ -17,6 +19,7 @@ metadata:
data:
tls.crt: {{ b64enc $cert.Cert }}
tls.key: {{ b64enc $cert.Key }}
{{- end }}
---
apiVersion: admissionregistration.k8s.io/v1
kind: MutatingWebhookConfiguration
Expand All @@ -27,14 +30,20 @@ metadata:
helm.sh/chart: {{ include "osiris.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
annotations:
{{- if .Values.certmanager.enabled }}
cert-manager.io/inject-ca-from: {{ .Release.Namespace }}/{{ include "osiris.fullname" . }}-endpoints-hijacker-cert
{{- end }}
webhooks:
- name: endpoints-hijacker.osiris.dm.gg
clientConfig:
service:
namespace: {{ .Release.Namespace }}
name: {{ include "osiris.fullname" . }}-endpoints-hijacker
path: "/mutate"
{{- if not (.Values.certmanager.enabled) }}
caBundle: {{ b64enc $ca.Cert }}
{{- end }}
rules:
- apiGroups:
- ""
Expand Down
9 changes: 9 additions & 0 deletions charts/osiris/templates/issuer.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{{- if .Values.certmanager.enabled -}}
apiVersion: cert-manager.io/v1
kind: Issuer
metadata:
name: {{ include "osiris.fullname" . }}-selfsigned-issuer
namespace: {{ .Release.Namespace }}
spec:
selfSigned: {}
{{- end }}
22 changes: 22 additions & 0 deletions charts/osiris/templates/proxy-injector-certificate.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{{- if .Values.certmanager.enabled -}}
apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
name: {{ include "osiris.fullname" . }}-proxy-injector-cert
labels:
app.kubernetes.io/name: {{ include "osiris.name" . }}-proxy-injector
helm.sh/chart: {{ include "osiris.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
spec:
commonName: {{ include "osiris.fullname" . }}-proxy-injector-cert
dnsNames:
- {{ include "osiris.fullname" . }}-proxy-injector.{{ .Release.Namespace }}
- {{ include "osiris.fullname" . }}-proxy-injector.{{ .Release.Namespace }}.svc
- {{ include "osiris.fullname" . }}-proxy-injector.{{ .Release.Namespace }}.svc.cluster
- {{ include "osiris.fullname" . }}-proxy-injector.{{ .Release.Namespace }}.svc.cluster.local
issuerRef:
kind: Issuer
name: {{ include "osiris.fullname" . }}-selfsigned-issuer
secretName: {{ include "osiris.fullname" . }}-proxy-injector-cert
{{- end }}
9 changes: 9 additions & 0 deletions charts/osiris/templates/proxy-injector-webhook-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
{{- $altName3 := printf "%s-proxy-injector.%s.svc.cluster" (include "osiris.fullname" .) .Release.Namespace }}
{{- $altName4 := printf "%s-proxy-injector.%s.svc.cluster.local" (include "osiris.fullname" .) .Release.Namespace }}
{{- $cert := genSignedCert $cn nil (list $altName1 $altName2 $altName3 $altName4) 3650 $ca }}

{{- if not (.Values.certmanager.enabled) -}}
apiVersion: v1
kind: Secret
metadata:
Expand All @@ -17,6 +19,7 @@ metadata:
data:
tls.crt: {{ b64enc $cert.Cert }}
tls.key: {{ b64enc $cert.Key }}
{{- end }}
---
apiVersion: admissionregistration.k8s.io/v1
kind: MutatingWebhookConfiguration
Expand All @@ -27,14 +30,20 @@ metadata:
helm.sh/chart: {{ include "osiris.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
annotations:
{{- if .Values.certmanager.enabled }}
cert-manager.io/inject-ca-from: {{ .Release.Namespace }}/{{ include "osiris.fullname" . }}-proxy-injector-cert
{{- end }}
webhooks:
- name: proxy-injector.osiris.dm.gg
clientConfig:
service:
namespace: {{ .Release.Namespace }}
name: {{ include "osiris.fullname" . }}-proxy-injector
path: "/mutate"
{{- if not (.Values.certmanager.enabled) }}
caBundle: {{ b64enc $ca.Cert }}
{{- end }}
rules:
- apiGroups:
- ""
Expand Down
5 changes: 5 additions & 0 deletions charts/osiris/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,8 @@ endpointsHijacker:
nodeSelector: {}
tolerations: []
affinity: {}

certmanager:
# -- Enables cert-manager to automatically issue selfSigned certificates
# to proxyInjector and endpointsHijacker Webhooks
enabled: false