Skip to content

Commit 8fed7d9

Browse files
zmotsoSergK
authored andcommitted
EPMDEDP-16582: feat: replace self-signed cert generation with cert-manager
Remove the custom TLS certificate lifecycle logic (CertService, PopulateCertificates) that regenerated self-signed certs on every restart. Delegate certificate issuance and CA injection to cert-manager via a Helm-managed Issuer and Certificate, and the cert-manager.io/inject-ca-from annotation on ValidatingWebhookConfiguration. Drop cluster-scoped RBAC rules that were required solely for cert generation (ValidatingWebhookConfiguration patch, Secrets create/update). Gate all webhook resources behind the new enableWebhooks Helm value.
1 parent 02c0a45 commit 8fed7d9

19 files changed

Lines changed: 99 additions & 522 deletions

cmd/main.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package main
22

33
import (
4-
"context"
54
"crypto/tls"
65
"flag"
76
"os"
@@ -101,8 +100,6 @@ func main() {
101100

102101
v := buildInfo.Get()
103102

104-
ctrl.SetLogger(zap.New(zap.UseFlagOptions(&opts)))
105-
106103
// if the enable-http2 flag is false (the default), http/2 should be disabled
107104
// due to its vulnerabilities. More specifically, disabling http/2 will
108105
// prevent from being vulnerable to the HTTP/2 Stream Cancellation and
@@ -287,7 +284,7 @@ func main() {
287284
}
288285

289286
if os.Getenv("ENABLE_WEBHOOKS") != "false" {
290-
if err = webhook.RegisterValidationWebHook(context.Background(), mgr, ns); err != nil {
287+
if err = webhook.RegisterValidationWebHook(mgr); err != nil {
291288
setupLog.Error(err, "failed to create webhook", "webhook", "Codebase")
292289
os.Exit(1)
293290
}

deploy-templates/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ A Helm chart for KubeRocketCI Codebase Operator
2323
|-----|------|---------|-------------|
2424
| affinity | object | `{}` | |
2525
| annotations | object | `{}` | |
26+
| enableWebhooks | bool | `true` | Enable webhook and cert-manager certificate resources. Webhooks require cert-manager to be installed in the cluster. |
2627
| envs[0].name | string | `"RECONCILATION_PERIOD"` | |
2728
| envs[0].value | string | `"360"` | |
2829
| envs[1] | object | `{"name":"CODEBASE_BRANCH_MAX_CONCURRENT_RECONCILES","value":"3"}` | Maximum number of parallel reconciliation codebasebranches |

deploy-templates/templates/cert_secret.yaml

Lines changed: 0 additions & 6 deletions
This file was deleted.

deploy-templates/templates/clusterrole_kubernetes.yaml

Lines changed: 0 additions & 17 deletions
This file was deleted.

deploy-templates/templates/clusterrole_openshift.yaml

Lines changed: 0 additions & 17 deletions
This file was deleted.

deploy-templates/templates/clusterrolebinding_kubernetes.yaml

Lines changed: 0 additions & 16 deletions
This file was deleted.

deploy-templates/templates/clusterrolebinding_openshift.yaml

Lines changed: 0 additions & 16 deletions
This file was deleted.

deploy-templates/templates/deployment.yaml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ spec:
3434
containers:
3535
- name: {{ .Values.name }}
3636
image: {{ if .Values.image.registry }}{{ .Values.image.registry }}/{{ end }}{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}
37+
{{- if .Values.enableWebhooks }}
38+
args:
39+
- --webhook-cert-path=/tmp/k8s-webhook-server/serving-certs
3740
ports:
3841
- containerPort: 9443
3942
name: webhook-server
@@ -42,6 +45,7 @@ spec:
4245
- mountPath: /tmp/k8s-webhook-server/serving-certs
4346
name: cert
4447
readOnly: true
48+
{{- end }}
4549
imagePullPolicy: "{{ .Values.imagePullPolicy }}"
4650
{{- if .Values.securityContext }}
4751
securityContext: {{ toYaml .Values.securityContext | nindent 12 }}
@@ -61,6 +65,8 @@ spec:
6165
value: "{{ .Values.global.platform }}"
6266
- name: TELEMETRY_ENABLED
6367
value: "{{ .Values.telemetryEnabled }}"
68+
- name: ENABLE_WEBHOOKS
69+
value: {{ .Values.enableWebhooks | quote }}
6470
{{ toYaml .Values.envs | indent 12 }}
6571
resources:
6672
{{ toYaml .Values.resources | indent 12 }}
@@ -76,8 +82,10 @@ spec:
7682
tolerations:
7783
{{- toYaml . | nindent 8 }}
7884
{{- end }}
85+
{{- if .Values.enableWebhooks }}
7986
volumes:
8087
- name: cert
8188
secret:
8289
defaultMode: 420
83-
secretName: edp-codebase-operator-webhook-certs
90+
secretName: {{ .Values.name }}-webhook-certs
91+
{{- end }}

deploy-templates/templates/role_kubernetes.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@ rules:
8787
- list
8888
- patch
8989
- update
90-
- create
9190
resources:
9291
- secrets
9392
- apiGroups:

deploy-templates/templates/service.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{{- if .Values.enableWebhooks }}
12
apiVersion: v1
23
kind: Service
34
metadata:
@@ -10,4 +11,5 @@ spec:
1011
protocol: TCP
1112
targetPort: 9443
1213
selector:
13-
name: {{ .Values.name }}
14+
name: {{ .Values.name }}
15+
{{- end }}

0 commit comments

Comments
 (0)