Skip to content

Commit 939c739

Browse files
authored
🤖 fix: stop generating aggregation CRDs in manifests (#68)
## Summary Stop generating `aggregation.coder.com` CRDs into `config/crd/bases`, delete the previously generated aggregation CRD manifests, and keep demo flows fail-fast when stale APIService/CRD conflicts exist. ## Background For APIService-backed aggregated resources (`codertemplates`, `coderworkspaces`), same-group CRDs in `config/crd/bases` caused unreliable read/discovery behavior in demos when both mechanisms were present. We want `kubectl apply -f config/crd/bases/` to remain simple and safe. ## Implementation - Updated `hack/update-manifests.sh`: - CRD generation now runs only against `./api/v1alpha1` (operator-owned `coder.com/*` APIs) - RBAC generation remains repo-wide (`./...`) - Removed generated aggregation CRDs: - `config/crd/bases/aggregation.coder.com_codertemplates.yaml` - `config/crd/bases/aggregation.coder.com_coderworkspaces.yaml` - Kept a defensive guard in `hack/kind-dev.sh`: - Detects `APIService v1alpha1.aggregation.coder.com` + aggregation CRD coexistence - Fails with explicit cleanup command - Simplified docs back to approachable CRD command usage (`kubectl apply -f config/crd/bases/`) while keeping a focused troubleshooting note for stale conflict cleanup. ## Validation - `make verify-vendor` - `make test` - `make build` - `make lint` - `make docs-check` - `make manifests` - `bash -n ./hack/kind-dev.sh` - `CLUSTER_NAME=coder-k8s-smoke-20260212 ./hack/kind-dev.sh up` ## Risks Low-to-moderate: - Behavior of generated CRDs intentionally narrows to controller-owned APIs only. - Any external workflow that relied on generated aggregation CRD files in `config/crd/bases` will need to use the APIService path instead (which is the intended model). --- _Generated with `mux` • Model: `openai:gpt-5.3-codex` • Thinking: `xhigh` • Cost: `$0.00`_ <!-- mux-attribution: model=openai:gpt-5.3-codex thinking=xhigh costs=0.00 -->
1 parent 450fb4e commit 939c739

5 files changed

Lines changed: 56 additions & 183 deletions

File tree

‎config/crd/bases/aggregation.coder.com_codertemplates.yaml‎

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

‎config/crd/bases/aggregation.coder.com_coderworkspaces.yaml‎

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

‎docs/how-to/troubleshooting.md‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,30 @@ kubectl apply -f config/crd/bases/
4040
kubectl get clusterrolebinding coder-k8s-controller
4141
```
4242

43+
## Aggregated `codertemplates` / `coderworkspaces` reads are empty or inconsistent
44+
45+
If `kubectl get codertemplates.aggregation.coder.com` or `kubectl get coderworkspaces.aggregation.coder.com` returns empty data unexpectedly, check for CRD/APIService conflicts.
46+
47+
When both of these exist at once:
48+
49+
- `APIService` `v1alpha1.aggregation.coder.com`
50+
- CRDs `codertemplates.aggregation.coder.com` and/or `coderworkspaces.aggregation.coder.com`
51+
52+
Kubernetes may not route reads the way you expect for demos.
53+
54+
```bash
55+
kubectl get apiservice v1alpha1.aggregation.coder.com
56+
kubectl get crd codertemplates.aggregation.coder.com coderworkspaces.aggregation.coder.com
57+
```
58+
59+
For APIService-based demos, remove the conflicting aggregation CRDs:
60+
61+
```bash
62+
kubectl delete crd codertemplates.aggregation.coder.com coderworkspaces.aggregation.coder.com
63+
kubectl apply -f deploy/apiserver-apiservice.yaml
64+
kubectl wait --for=condition=Available apiservice/v1alpha1.aggregation.coder.com --timeout=120s
65+
```
66+
4367
## Aggregated APIService shows `False` / `Unavailable`
4468

4569
- Ensure the deployment and service exist:

‎hack/kind-dev.sh‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,29 @@ ensure_cluster_node_image_matches() {
7676
exit 1
7777
}
7878

79+
assert_no_aggregation_resource_conflict() {
80+
local has_apiservice="false"
81+
local has_template_crd="false"
82+
local has_workspace_crd="false"
83+
84+
if kubectl_ctx get apiservice v1alpha1.aggregation.coder.com >/dev/null 2>&1; then
85+
has_apiservice="true"
86+
fi
87+
if kubectl_ctx get crd codertemplates.aggregation.coder.com >/dev/null 2>&1; then
88+
has_template_crd="true"
89+
fi
90+
if kubectl_ctx get crd coderworkspaces.aggregation.coder.com >/dev/null 2>&1; then
91+
has_workspace_crd="true"
92+
fi
93+
94+
if [[ "${has_apiservice}" == "true" && ( "${has_template_crd}" == "true" || "${has_workspace_crd}" == "true" ) ]]; then
95+
echo "assertion failed: detected aggregation API conflict in ${KUBE_CONTEXT}: APIService v1alpha1.aggregation.coder.com and aggregation.coder.com CRDs are both installed." >&2
96+
echo "Delete conflicting CRDs before aggregated API demos:" >&2
97+
echo " kubectl --context ${KUBE_CONTEXT} delete crd codertemplates.aggregation.coder.com coderworkspaces.aggregation.coder.com" >&2
98+
exit 1
99+
fi
100+
}
101+
79102
build_binary() {
80103
local resolved_goarch="${GOARCH}"
81104
if [[ -z "${resolved_goarch}" ]]; then
@@ -115,8 +138,10 @@ cmd_up() {
115138
kubectl config use-context "${KUBE_CONTEXT}" >/dev/null
116139

117140
kubectl_ctx wait --for=condition=Ready node --all --timeout="${NODE_READY_TIMEOUT}"
141+
assert_no_aggregation_resource_conflict
118142

119143
kubectl_ctx apply -f config/e2e/namespace.yaml
144+
# config/crd/bases intentionally contains only operator-owned coder.com CRDs.
120145
kubectl_ctx apply -f config/crd/bases/
121146
kubectl_ctx apply -f config/rbac/
122147

‎hack/update-manifests.sh‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,15 @@ if [[ ! -d "${SCRIPT_ROOT}/internal/controller" ]]; then
1414
fi
1515

1616
cd "${SCRIPT_ROOT}"
17+
18+
# Generate CRDs for operator-owned coder.com APIs only.
1719
GOFLAGS=-mod=vendor go run ./vendor/sigs.k8s.io/controller-tools/cmd/controller-gen \
1820
crd:crdVersions=v1 \
21+
paths=./api/v1alpha1 \
22+
output:crd:artifacts:config=config/crd/bases
23+
24+
# Generate RBAC across the repo.
25+
GOFLAGS=-mod=vendor go run ./vendor/sigs.k8s.io/controller-tools/cmd/controller-gen \
1926
rbac:roleName=manager-role \
2027
paths=./... \
21-
output:crd:artifacts:config=config/crd/bases \
2228
output:rbac:artifacts:config=config/rbac

0 commit comments

Comments
 (0)