-
Notifications
You must be signed in to change notification settings - Fork 0
[koptan] add cert-manager and webhook resources to helm chart #10
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| .claude/ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| {{- if .Values.certManager.enabled }} | ||
| {{- if .Values.webhook.enabled }} | ||
| --- | ||
| apiVersion: cert-manager.io/v1 | ||
| kind: Certificate | ||
| metadata: | ||
| name: {{ include "koptan.fullname" . }}-serving-cert | ||
| namespace: {{ .Release.Namespace }} | ||
| labels: | ||
| {{- include "koptan.labels" . | nindent 4 }} | ||
| spec: | ||
| dnsNames: | ||
| - {{ include "koptan.fullname" . }}-webhook-service.{{ .Release.Namespace }}.svc | ||
| - {{ include "koptan.fullname" . }}-webhook-service.{{ .Release.Namespace }}.svc.cluster.local | ||
| issuerRef: | ||
| kind: Issuer | ||
| name: {{ include "koptan.fullname" . }}-selfsigned-issuer | ||
| secretName: webhook-server-cert | ||
| {{- end }} | ||
| {{- if .Values.metrics.secure }} | ||
| --- | ||
| apiVersion: cert-manager.io/v1 | ||
| kind: Certificate | ||
| metadata: | ||
| name: {{ include "koptan.fullname" . }}-metrics-certs | ||
| namespace: {{ .Release.Namespace }} | ||
| labels: | ||
| {{- include "koptan.labels" . | nindent 4 }} | ||
| spec: | ||
| dnsNames: | ||
| - {{ include "koptan.fullname" . }}-metrics-service.{{ .Release.Namespace }}.svc | ||
| - {{ include "koptan.fullname" . }}-metrics-service.{{ .Release.Namespace }}.svc.cluster.local | ||
| issuerRef: | ||
| kind: Issuer | ||
| name: {{ include "koptan.fullname" . }}-selfsigned-issuer | ||
| secretName: metrics-server-cert | ||
| {{- end }} | ||
| {{- end }} | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,5 @@ | ||
| {{- $webhookCerts := and .Values.webhook.enabled .Values.certManager.enabled }} | ||
| {{- $metricsCerts := and .Values.metrics.secure .Values.certManager.enabled }} | ||
| apiVersion: apps/v1 | ||
| kind: Deployment | ||
| metadata: | ||
|
|
@@ -28,12 +30,31 @@ spec: | |
| args: | ||
| - --leader-elect | ||
| - --health-probe-bind-address=:8081 | ||
| {{- if .Values.metrics.secure }} | ||
| - --metrics-bind-address=:{{ .Values.metrics.port }} | ||
| {{- end }} | ||
| {{- if $webhookCerts }} | ||
| - --webhook-cert-path=/tmp/k8s-webhook-server/serving-certs | ||
| {{- end }} | ||
| {{- if $metricsCerts }} | ||
| - --metrics-cert-path=/tmp/k8s-metrics-server/metrics-certs | ||
| {{- end }} | ||
|
Comment on lines
1
to
+41
|
||
| image: "{{ .Values.controller.image.repository }}:{{ .Values.controller.image.tag | default .Chart.AppVersion }}" | ||
| imagePullPolicy: {{ .Values.controller.image.pullPolicy }} | ||
| ports: | ||
| - name: http | ||
| containerPort: 8080 | ||
| protocol: TCP | ||
| {{- if .Values.webhook.enabled }} | ||
| - name: webhook-server | ||
| containerPort: 9443 | ||
| protocol: TCP | ||
| {{- end }} | ||
| {{- if .Values.metrics.secure }} | ||
| - name: metrics | ||
| containerPort: {{ .Values.metrics.port }} | ||
| protocol: TCP | ||
|
Comment on lines
+33
to
+56
|
||
| {{- end }} | ||
| resources: | ||
| limits: | ||
| cpu: 500m | ||
|
|
@@ -59,4 +80,37 @@ spec: | |
| port: 8081 | ||
| initialDelaySeconds: 5 | ||
| periodSeconds: 10 | ||
| volumes: [] | ||
| {{- if or $webhookCerts $metricsCerts }} | ||
| volumeMounts: | ||
| {{- if $webhookCerts }} | ||
| - mountPath: /tmp/k8s-webhook-server/serving-certs | ||
| name: webhook-certs | ||
| readOnly: true | ||
| {{- end }} | ||
| {{- if $metricsCerts }} | ||
| - mountPath: /tmp/k8s-metrics-server/metrics-certs | ||
| name: metrics-certs | ||
| readOnly: true | ||
| {{- end }} | ||
| {{- end }} | ||
| {{- if or $webhookCerts $metricsCerts }} | ||
| volumes: | ||
| {{- if $webhookCerts }} | ||
| - name: webhook-certs | ||
| secret: | ||
| secretName: webhook-server-cert | ||
| {{- end }} | ||
| {{- if $metricsCerts }} | ||
| - name: metrics-certs | ||
| secret: | ||
| secretName: metrics-server-cert | ||
| optional: false | ||
| items: | ||
| - key: ca.crt | ||
| path: ca.crt | ||
| - key: tls.crt | ||
| path: tls.crt | ||
| - key: tls.key | ||
| path: tls.key | ||
| {{- end }} | ||
|
Comment on lines
+97
to
+115
|
||
| {{- end }} | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,11 @@ | ||||||
| {{- if .Values.certManager.enabled }} | ||||||
|
||||||
| {{- if .Values.certManager.enabled }} | |
| {{- if and .Values.certManager.enabled (or .Values.webhook.enabled .Values.metrics.secure) }} |
Copilot
AI
Apr 1, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issuer.yaml renders an Issuer whenever certManager.enabled is true, even if neither webhook.enabled nor metrics.secure are enabled (so no Certificates are created). Consider gating the Issuer on and .Values.certManager.enabled (or .Values.webhook.enabled .Values.metrics.secure) to avoid creating unused resources.
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,39 @@ | ||||||
| apiVersion: rbac.authorization.k8s.io/v1 | ||||||
| kind: Role | ||||||
| metadata: | ||||||
| name: {{ include "koptan.fullname" . }}-leader-election-role | ||||||
|
||||||
| name: {{ include "koptan.fullname" . }}-leader-election-role | |
| name: {{ printf "%s-leader-election-role" (include "koptan.fullname" .) | trunc 63 | trimSuffix "-" }} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| apiVersion: rbac.authorization.k8s.io/v1 | ||
| kind: RoleBinding | ||
| metadata: | ||
| name: {{ include "koptan.fullname" . }}-leader-election-rolebinding | ||
| namespace: {{ .Release.Namespace }} | ||
| labels: | ||
| {{- include "koptan.labels" . | nindent 4 }} | ||
| roleRef: | ||
| apiGroup: rbac.authorization.k8s.io | ||
| kind: Role | ||
| name: {{ include "koptan.fullname" . }}-leader-election-role | ||
| subjects: | ||
| - kind: ServiceAccount | ||
| name: {{ include "koptan.serviceAccountName" . }} | ||
| namespace: {{ .Release.Namespace }} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| {{- if and .Values.metrics.secure .Values.certManager.enabled }} | ||
| apiVersion: rbac.authorization.k8s.io/v1 | ||
| kind: ClusterRole | ||
| metadata: | ||
| name: {{ include "koptan.fullname" . }}-metrics-auth-role | ||
| labels: | ||
| {{- include "koptan.labels" . | nindent 4 }} | ||
| rules: | ||
| - apiGroups: | ||
| - authentication.k8s.io | ||
| resources: | ||
| - tokenreviews | ||
| verbs: | ||
| - create | ||
| - apiGroups: | ||
| - authorization.k8s.io | ||
| resources: | ||
| - subjectaccessreviews | ||
| verbs: | ||
| - create | ||
| --- | ||
| apiVersion: rbac.authorization.k8s.io/v1 | ||
| kind: ClusterRoleBinding | ||
| metadata: | ||
| name: {{ include "koptan.fullname" . }}-metrics-auth-rolebinding | ||
| labels: | ||
| {{- include "koptan.labels" . | nindent 4 }} | ||
| roleRef: | ||
| apiGroup: rbac.authorization.k8s.io | ||
| kind: ClusterRole | ||
| name: {{ include "koptan.fullname" . }}-metrics-auth-role | ||
| subjects: | ||
| - kind: ServiceAccount | ||
| name: {{ include "koptan.serviceAccountName" . }} | ||
| namespace: {{ .Release.Namespace }} | ||
| {{- end }} |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,17 @@ | ||||||
| {{- if and .Values.metrics.secure .Values.certManager.enabled }} | ||||||
| apiVersion: v1 | ||||||
| kind: Service | ||||||
| metadata: | ||||||
| name: {{ include "koptan.fullname" . }}-metrics-service | ||||||
|
||||||
| name: {{ include "koptan.fullname" . }}-metrics-service | |
| name: {{ include "koptan.fullname" . | trunc 47 | trimSuffix "-" }}-metrics-service |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,113 @@ | ||
| {{- if and .Values.webhook.enabled .Values.certManager.enabled }} | ||
| apiVersion: admissionregistration.k8s.io/v1 | ||
| kind: MutatingWebhookConfiguration | ||
| metadata: | ||
| name: {{ include "koptan.fullname" . }}-mutating-webhook-configuration | ||
| labels: | ||
| {{- include "koptan.labels" . | nindent 4 }} | ||
| {{- if .Values.certManager.enabled }} | ||
| annotations: | ||
| cert-manager.io/inject-ca-from: {{ .Release.Namespace }}/{{ include "koptan.fullname" . }}-serving-cert | ||
| {{- end }} | ||
|
Comment on lines
+1
to
+11
|
||
| webhooks: | ||
| - admissionReviewVersions: | ||
| - v1 | ||
| clientConfig: | ||
| service: | ||
| name: {{ include "koptan.fullname" . }}-webhook-service | ||
| namespace: {{ .Release.Namespace }} | ||
| path: /mutate-koptan-felukka-sh-v1alpha-goapp | ||
| failurePolicy: Fail | ||
| name: mgoapp-v1alpha.kb.io | ||
| rules: | ||
| - apiGroups: | ||
| - koptan.felukka.sh | ||
| apiVersions: | ||
| - v1alpha | ||
| operations: | ||
| - CREATE | ||
| - UPDATE | ||
| resources: | ||
| - goapps | ||
| sideEffects: None | ||
| - admissionReviewVersions: | ||
| - v1 | ||
| clientConfig: | ||
| service: | ||
| name: {{ include "koptan.fullname" . }}-webhook-service | ||
| namespace: {{ .Release.Namespace }} | ||
| path: /mutate-koptan-felukka-sh-v1alpha-javaapp | ||
| failurePolicy: Fail | ||
| name: mjavaapp-v1alpha.kb.io | ||
| rules: | ||
| - apiGroups: | ||
| - koptan.felukka.sh | ||
| apiVersions: | ||
| - v1alpha | ||
| operations: | ||
| - CREATE | ||
| - UPDATE | ||
| resources: | ||
| - javaapps | ||
| sideEffects: None | ||
| - admissionReviewVersions: | ||
| - v1 | ||
| clientConfig: | ||
| service: | ||
| name: {{ include "koptan.fullname" . }}-webhook-service | ||
| namespace: {{ .Release.Namespace }} | ||
| path: /mutate-koptan-felukka-sh-v1alpha-slipway | ||
| failurePolicy: Fail | ||
| name: mslipway-v1alpha.kb.io | ||
| rules: | ||
| - apiGroups: | ||
| - koptan.felukka.sh | ||
| apiVersions: | ||
| - v1alpha | ||
| operations: | ||
| - CREATE | ||
| - UPDATE | ||
| resources: | ||
| - slipways | ||
| sideEffects: None | ||
| - admissionReviewVersions: | ||
| - v1 | ||
| clientConfig: | ||
| service: | ||
| name: {{ include "koptan.fullname" . }}-webhook-service | ||
| namespace: {{ .Release.Namespace }} | ||
| path: /mutate-koptan-felukka-sh-v1alpha-voyage | ||
| failurePolicy: Fail | ||
| name: mvoyage-v1alpha.kb.io | ||
| rules: | ||
| - apiGroups: | ||
| - koptan.felukka.sh | ||
| apiVersions: | ||
| - v1alpha | ||
| operations: | ||
| - CREATE | ||
| - UPDATE | ||
| resources: | ||
| - voyages | ||
| sideEffects: None | ||
| - admissionReviewVersions: | ||
| - v1 | ||
| clientConfig: | ||
| service: | ||
| name: {{ include "koptan.fullname" . }}-webhook-service | ||
| namespace: {{ .Release.Namespace }} | ||
| path: /mutate-koptan-felukka-sh-v1alpha-dotnetapp | ||
| failurePolicy: Fail | ||
| name: mdotnetapp-v1alpha.kb.io | ||
| rules: | ||
| - apiGroups: | ||
| - koptan.felukka.sh | ||
| apiVersions: | ||
| - v1alpha | ||
| operations: | ||
| - CREATE | ||
| - UPDATE | ||
| resources: | ||
| - dotnetapps | ||
| sideEffects: None | ||
| {{- end }} | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The metrics
Certificateis rendered whenevercertManager.enabledis true, even ifmetrics.secureis false (andmetrics-service/ metrics TLS mounts may not be rendered). Gate the metrics certificate onmetrics.secure(or render the metricsService/mounts whenever this certificate is created) to avoid creating unused resources and potential confusion.