Skip to content

Commit e23acc3

Browse files
scotwellsclaude
andcommitted
Drop hardcoded namespaces, fix install via kubectl apply
Tested end-to-end against a local kind cluster and found several real issues that this commit cleans up: - Resources no longer hardcode "namespace: system"; the namespace is set in one place (the overlay) via kustomize's namespace transform. Consumers can override via Flux's targetNamespace or by editing the overlay. - The webhook serving cert mount moves into base/manager/manager.yaml with the secret marked optional, so consumers composing base/manager directly (e.g. a future cross-cluster overlay) get the mount for free and don't crash if they're running webhook-less. - A new base/webhook/kustomizeconfig.yaml teaches kustomize about the webhook clientConfig.service.{name,namespace} field paths, so the namespace transform handles them automatically rather than needing per-overlay replacements. - The Certificate's dnsNames now use SERVICE_NAME / SERVICE_NAMESPACE placeholders (the kubebuilder pattern) and the overlay substitutes them via replacements pulling from the webhook Service. - Drops a stale --metrics-bind-address arg patch that referenced a CLI flag the binary no longer accepts (metrics config moved into the WorkloadOperator config struct). - Drops an orphaned metrics_service.yaml from the overlay that wasn't referenced from kustomization.yaml. - The default config.yaml now includes a webhookServer block so the bundle deploys a working webhook out of the box. Consumers running hermetic without webhooks can omit it (the binary skips the webhook server entirely when the field is nil). Verified end-to-end: manager pod 1/1 Running, Certificate ready, admission webhook serving and being called by the apiserver. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent f97093b commit e23acc3

16 files changed

Lines changed: 132 additions & 108 deletions

config/base/certmanager/certificate.yaml

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,26 @@
1-
# The following manifests contain a self-signed issuer CR and a certificate CR.
2-
# More document can be found at https://docs.cert-manager.io
3-
# WARNING: Targets CertManager v1.0. Check https://cert-manager.io/docs/installation/upgrading/ for breaking changes.
41
apiVersion: cert-manager.io/v1
52
kind: Issuer
63
metadata:
74
labels:
85
app.kubernetes.io/name: compute
96
app.kubernetes.io/managed-by: kustomize
107
name: selfsigned-issuer
11-
namespace: system
128
spec:
139
selfSigned: {}
1410
---
1511
apiVersion: cert-manager.io/v1
1612
kind: Certificate
1713
metadata:
1814
labels:
19-
app.kubernetes.io/name: certificate
20-
app.kubernetes.io/instance: serving-cert
21-
app.kubernetes.io/component: certificate
22-
app.kubernetes.io/created-by: compute
23-
app.kubernetes.io/part-of: compute
15+
app.kubernetes.io/name: compute
2416
app.kubernetes.io/managed-by: kustomize
2517
name: compute-serving-cert
26-
namespace: system
2718
spec:
19+
# The Service name and namespace get substituted in by kustomize
20+
# replacements in the consuming overlay.
2821
dnsNames:
29-
- compute-webhook.system.svc
30-
- compute-webhook.system.svc.cluster.local
22+
- SERVICE_NAME.SERVICE_NAMESPACE.svc
23+
- SERVICE_NAME.SERVICE_NAMESPACE.svc.cluster.local
3124
issuerRef:
3225
kind: Issuer
3326
name: selfsigned-issuer

config/base/manager/config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ apiVersion: apiserver.config.datumapis.com/v1alpha1
22
kind: WorkloadOperator
33
metricsServer:
44
bindAddress: "0"
5+
webhookServer: {}

config/base/manager/manager.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ spec:
3030
- --server-config=/config/config.yaml
3131
image: ghcr.io/datum-cloud/compute:latest
3232
name: manager
33+
ports:
34+
- containerPort: 9443
35+
name: webhook-server
36+
protocol: TCP
3337
securityContext:
3438
allowPrivilegeEscalation: false
3539
capabilities:
@@ -57,9 +61,20 @@ spec:
5761
volumeMounts:
5862
- name: config
5963
mountPath: /config
64+
- name: webhook-cert
65+
mountPath: /tmp/k8s-webhook-server/serving-certs
66+
readOnly: true
6067
serviceAccountName: compute
6168
terminationGracePeriodSeconds: 10
6269
volumes:
6370
- name: config
6471
configMap:
6572
name: compute-config
73+
# Optional so the manager can run without admission webhooks: when
74+
# `webhookServer:` is omitted from the server config, the binary
75+
# skips the webhook server entirely and the missing Secret is fine.
76+
- name: webhook-cert
77+
secret:
78+
secretName: compute-webhook-cert
79+
defaultMode: 420
80+
optional: true

config/base/webhook/kustomization.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ resources:
77
# can use static `compute-*` references.
88
- manifests.yaml
99

10+
# Teach kustomize about the webhook clientConfig.service.{name,namespace}
11+
# field paths so the namespace transform handles them automatically.
12+
configurations:
13+
- kustomizeconfig.yaml
14+
1015
patches:
1116
- patch: |-
1217
- op: replace
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Teach kustomize that webhook clientConfig.service.namespace and .name
2+
# point at a Service, so the namespace transform and name reference handling
3+
# rewrite them automatically when an overlay sets `namespace:`.
4+
namespace:
5+
- path: webhooks/clientConfig/service/namespace
6+
kind: ValidatingWebhookConfiguration
7+
group: admissionregistration.k8s.io
8+
create: false
9+
- path: webhooks/clientConfig/service/namespace
10+
kind: MutatingWebhookConfiguration
11+
group: admissionregistration.k8s.io
12+
create: false
13+
14+
nameReference:
15+
- kind: Service
16+
version: v1
17+
fieldSpecs:
18+
- kind: ValidatingWebhookConfiguration
19+
group: admissionregistration.k8s.io
20+
path: webhooks/clientConfig/service/name
21+
- kind: MutatingWebhookConfiguration
22+
group: admissionregistration.k8s.io
23+
path: webhooks/clientConfig/service/name

config/components/controller_rbac/metrics_auth_role_binding.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,3 @@ roleRef:
99
subjects:
1010
- kind: ServiceAccount
1111
name: compute
12-
namespace: system

config/components/controller_rbac/role_binding.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,3 @@ roleRef:
1212
subjects:
1313
- kind: ServiceAccount
1414
name: compute
15-
namespace: system

config/components/leader_election/leader_election_role_binding.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,3 @@ roleRef:
1212
subjects:
1313
- kind: ServiceAccount
1414
name: compute
15-
namespace: system

config/components/network-policy/allow-metrics-traffic.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ metadata:
88
app.kubernetes.io/name: compute
99
app.kubernetes.io/managed-by: kustomize
1010
name: compute-allow-metrics-traffic
11-
namespace: system
1211
spec:
1312
podSelector:
1413
matchLabels:

config/components/network-policy/allow-webhook-traffic.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ metadata:
88
app.kubernetes.io/name: compute
99
app.kubernetes.io/managed-by: kustomize
1010
name: compute-allow-webhook-traffic
11-
namespace: system
1211
spec:
1312
podSelector:
1413
matchLabels:

0 commit comments

Comments
 (0)