Skip to content

Commit 6ae2210

Browse files
stubbiclaude
andauthored
fix(chart): ship the karpenter core CRDs so the controller can start (#44)
The chart only shipped HCloudNodeClass, so a clean install per the README left the controller crash-looping on its own watches: "if kind is a CRD, it should be installed before calling Start" kind=NodeClaim.karpenter.sh error=no matches for kind "NodeClaim" in version "karpenter.sh/v1" controllers.NewControllers() watches NodePool and NodeClaim unconditionally, so neither is optional. Vendor both from the pinned sigs.k8s.io/karpenter v1.14.0; each serves v1, matching the version the controller requests. Copy them in `make generate` rather than checking in a hand-copied snapshot, so a sigs.k8s.io/karpenter bump that changes either schema fails the existing `make generate-verify` gate in CI instead of silently shipping a stale CRD. NodeOverlay and CapacityBuffer are deliberately not vendored: both sit behind feature gates defaulting to false, and the chart does not expose them. README: correct the claim that a single CRD ships, and document that Helm never upgrades resources in crds/, with the server-side apply to run before `helm upgrade`. Fixes #43 Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent af31b61 commit 6ae2210

4 files changed

Lines changed: 980 additions & 3 deletions

File tree

Makefile

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.PHONY: build test lint generate generate-verify docker-build test-envtest
1+
.PHONY: build test lint generate generate-verify vendor-core-crds docker-build test-envtest
22

33
BINARY := karpenter-provider-hetzner
44
IMAGE := ghcr.io/paperclipinc/karpenter-provider-hetzner
@@ -16,10 +16,26 @@ test:
1616
lint:
1717
golangci-lint run ./...
1818

19-
generate:
19+
generate: vendor-core-crds
2020
$(CONTROLLER_GEN) object paths="./pkg/apis/..."
2121
$(CONTROLLER_GEN) crd paths="./pkg/apis/..." output:crd:dir=charts/karpenter-provider-hetzner/crds
2222

23+
# Copy the karpenter core CRDs (NodePool, NodeClaim) out of the pinned
24+
# sigs.k8s.io/karpenter module and into the chart. The controller watches both,
25+
# so the chart is unusable without them. Sourcing them from the module rather
26+
# than checking in a hand-copied snapshot means a version bump that changes the
27+
# schema is caught by `make generate-verify` in CI.
28+
#
29+
# NodeOverlay and CapacityBuffer are deliberately not vendored: both sit behind
30+
# feature gates that default to false, and this chart does not expose them.
31+
vendor-core-crds:
32+
@set -eu; \
33+
dir="$$(go list -m -f '{{.Dir}}' sigs.k8s.io/karpenter)"; \
34+
for crd in karpenter.sh_nodepools.yaml karpenter.sh_nodeclaims.yaml; do \
35+
cp "$$dir/pkg/apis/crds/$$crd" charts/karpenter-provider-hetzner/crds/$$crd; \
36+
chmod u+w charts/karpenter-provider-hetzner/crds/$$crd; \
37+
done
38+
2339
generate-verify: generate
2440
@if [ -n "$$(git status --porcelain pkg/apis charts/karpenter-provider-hetzner/crds)" ]; then \
2541
echo "generated files are out of date; run 'make generate' and commit"; \

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,13 @@ helm install karpenter-provider-hetzner \
6767

6868
`clusterName` is **required** — it scopes which servers this controller manages. The controller fails fast if it is unset.
6969

70-
The CRD ships in the chart's `crds/` directory and is installed automatically by Helm.
70+
Three CRDs ship in the chart's `crds/` directory and are installed automatically by Helm: `HCloudNodeClass` (this provider) plus the `NodePool` and `NodeClaim` core CRDs from `karpenter.sh`, which the controller watches. No separate CRD install step is needed.
71+
72+
> **Upgrading:** Helm only ever *installs* resources from `crds/`; it never updates them. When upgrading to a chart whose karpenter core version changed, apply the CRDs yourself before `helm upgrade`:
73+
>
74+
> ```bash
75+
> kubectl apply --server-side -f https://raw.githubusercontent.com/paperclipinc/karpenter-provider-hetzner/main/charts/karpenter-provider-hetzner/crds/
76+
> ```
7177
7278
## Usage
7379

0 commit comments

Comments
 (0)