Skip to content

Commit b8ccb24

Browse files
committed
refactor(controller): render the release CRDs from the controller chart
The nvke-crds chart existed so the NVKE controller and Cluster Service could share one set of CRDs. They no longer do: the controller owns MachineImage, ClusterRelease and NodePoolRelease in internal.nvke.nvidia.com and management-engine owns its own in service.nvke.nvidia.com. What the split still cost was a local chart dependency, which has to be built before the controller chart can be linted, rendered or packaged, and it was only ever published bundled inside nvke-controller. Fold the CRDs back into the controller chart: - controller-gen writes them to controller/files/crds, one file per kind. - templates/crds.yaml renders them when releaseCRDs.install is true, with the same retention annotations as before (helm.sh/resource-policy: keep and the Argo CD sync-wave and Prune=false options). They stay in templates/ rather than Helm's crds/ directory, so a schema change still upgrades. A chart with no CRD files fails to render instead of installing without them. - Remove the nvke-crds chart, the Chart.yaml dependency and Chart.lock. Drop what only the dependency needed: chart-deps and its six prerequisite targets, the unused chart-crds target, the helm dependency build step in both chart publish workflows, the file:// carve-out in nvke-deploy.sh, the special case and narrowed go:embed in charts.Extract, Tilt's build_dependencies and the watch_settings workaround for the redeploy loop it caused, and the two .gitignore entries. Tilt applies the CRD files directly with kubectl. The rendered CRDs and the rest of the chart are unchanged: the CRD files are renamed without edits, and helm template output is identical to main for the default values and for releaseCRDs.install=false, apart from one fewer comment-only block. releaseCRDs.install keeps its meaning. Signed-off-by: Miancheng Lin <mianchengl@nvidia.com>
1 parent 2f31480 commit b8ccb24

37 files changed

Lines changed: 109 additions & 491 deletions

‎.claude/skills/regenerate/SKILL.md‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,8 @@ source + output together.
1414
| `controller/api/openapi.yaml` | `make generate` in `controller/` | spec + `api/*.gen.go` |
1515
| `agent/pkg/agent/proto/node_agent.proto` | `make protos` in `agent/` | `.proto` + `*.pb.go` |
1616
| CAPI types/markers in `cluster-api-provider-provisioned/` | `make generate manifests` there | types + deepcopy, CRDs, `config/rbac/role.yaml` |
17-
| `MachineImage`, `ClusterRelease` or `NodePoolRelease` types/markers in `controller/k8s-apis/v1/` | `make -C controller/k8s-apis generate manifests`, then `make chart-crds-check` at the root | types + `zz_generated.deepcopy.go` + the `nvke-crds` chart's `bases/*.yaml` |
17+
| `MachineImage`, `ClusterRelease` or `NodePoolRelease` types/markers in `controller/k8s-apis/v1/` | `make -C controller/k8s-apis generate manifests`, then `make chart-crds-check` at the root | types + `zz_generated.deepcopy.go` + the controller chart's `files/crds/*.yaml` |
1818
| `NVKECluster`, `ControlPlaneClass`, `ClusterReleaseChannel`, `MachineImage`, `ClusterRelease` or `NodePoolRelease` types/markers in `management-engine/apis/v1/` | `make -C management-engine manifests-state` | types + `zz_generated.deepcopy.go` + `config/crd/bases` |
19-
| `controller/deploy/release-crds/kustomization.yaml` | `make chart-crds` at the root | overlay + `files/crds.yaml` |
2019
| any module `go.mod`/`go.sum` | `make work-sync`, then `make notices`, at the root | `go.work` + `go.work.sum` + every changed `THIRD_PARTY_NOTICES.md` |
2120

2221
Rules that trip people up:

‎.github/workflows/chart-publish-nvcr.yml‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,6 @@ jobs:
181181
grep -q "^ - name: ${IMAGE_PULL_SECRET}\$" "${CHART}/values.yaml" \
182182
|| { echo "::error::pull-secret rewrite did not apply"; exit 1; }
183183
184-
helm dependency build "${CHART}" --skip-refresh
185184
helm package "${CHART}" \
186185
--version "${CHART_VERSION}" \
187186
--app-version "${APP_VERSION}" \

‎.github/workflows/chart-publish.yml‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,6 @@ jobs:
186186
APP_VERSION: ${{ steps.meta.outputs.app_version }}
187187
run: |
188188
set -euo pipefail
189-
helm dependency build "${CHART}" --skip-refresh
190189
helm package "${CHART}" \
191190
--version "${VERSION}" \
192191
--app-version "${APP_VERSION}" \

‎.github/workflows/generate-check.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ jobs:
145145
- name: Verify the embedded provisioned provider manifest is up to date
146146
run: make -C cli provider-manifest-check
147147

148-
# Regenerates the CRDs of the NVKE controller (the nvke-crds chart) and of
148+
# Regenerates the CRDs of the NVKE controller (the controller chart's files/crds) and of
149149
# management-engine (config/crd/bases). Verify both sets of committed CRDs.
150150
- name: Verify the generated CRDs are up to date
151151
run: make chart-crds-check

‎.gitignore‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,3 @@ controller/test/e2e/site-bundle*
110110
# hack/coverage.sh reads the directory. Nothing in it is committed: a profile
111111
# describes one run on one machine, and CI uploads it as an artifact instead.
112112
/coverage/
113-
114-
# Built Helm dependencies and compatibility render output.
115-
/controller/deploy/charts/controller/charts/
116-
/dist/

‎AGENTS.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ checkout, and do not stub a dependency to make the build pass.
110110
| `controller/api/*.gen.go` | oapi-codegen output | **No — regenerate** |
111111
| `cluster-api-provider-provisioned/api/v1alpha1/zz_generated.deepcopy.go` | controller-gen output | **No — regenerate** |
112112
| `controller/k8s-apis/v1/zz_generated.deepcopy.go` | controller-gen output | **No — regenerate** |
113-
| `controller/deploy/charts/nvke-crds/bases/*.yaml` | controller-gen output from `controller/k8s-apis/v1` | **No — regenerate** |
113+
| `controller/deploy/charts/controller/files/crds/*.yaml` | controller-gen output from `controller/k8s-apis/v1` | **No — regenerate** |
114114
| `cluster-api-provider-provisioned/config/crd/bases/*.yaml` | controller-gen output | **No — regenerate** |
115115
| `cluster-api-provider-provisioned/config/rbac/role.yaml` | controller-gen output | **No — regenerate** |
116116
| `management-engine/config/crd/bases/*.yaml` | `management-engine` controller-gen output | **No — regenerate** |

‎Makefile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ PRIVATE_MODULES :=
133133
#
134134
# The chart copies existed before this and nothing maintained them -- they were
135135
# committed by hand and happened to match. `licenses-check` now enforces it.
136-
LICENSE_DESTS := controller/deploy/charts/controller controller/deploy/charts/nvke-crds management-engine/chart
136+
LICENSE_DESTS := controller/deploy/charts/controller management-engine/chart
137137

138138
# Redistributed binaries with generated third-party attribution.
139139
NOTICE_MODULES := agent controller cli os-image

‎controller/Makefile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ lint: ## Lint source files. (run by the merge gate)
7474
# custom resources. Argo CD applies the fleet's; the manifests under
7575
# test/fixtures/releases are this repository's own set, maintained by hand.
7676

77-
RELEASE_CRD_DIR ?= $(REPO_ROOT)/controller/deploy/charts/nvke-crds/bases
77+
RELEASE_CRD_DIR ?= $(REPO_ROOT)/controller/deploy/charts/controller/files/crds
7878
RELEASE_CRD_NAMES ?= machineimages clusterreleases nodepoolreleases
7979
RELEASES_DIR ?= $(CURDIR)/test/fixtures/releases
8080

‎controller/Tiltfile‎

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1305,24 +1305,21 @@ if not CONTROLLER_IMAGE and not _controller_local_debug_active:
13051305
],
13061306
)
13071307

1308-
# The nvke-crds chart's release schemas are applied before the controller, which has its dependency turned
1309-
# off with releaseCRDs.install=false: a local resource that waits for the chart to
1310-
# install them holds every unparallelizable build behind it, including the chart's.
1308+
# The controller chart's release CRDs (deploy/charts/controller/files/crds) are applied before the
1309+
# controller, which has its own install turned off with releaseCRDs.install=false: a local resource
1310+
# that waits for the chart to install them holds every unparallelizable build behind it, including
1311+
# the chart's.
13111312
local_resource(
13121313
"machine-engine-crds",
13131314
cmd=["bash", "-c", """
13141315
set -euo pipefail
1315-
# Rendered here rather than through `make -C .. chart-crds`: CI runs this
1316-
# Tiltfile inside a container that has helm but no make, and whose source
1317-
# tree is the controller directory alone, with no repository root above it.
1318-
helm template nvke-crds deploy/charts/nvke-crds |
1319-
kubectl apply --server-side --field-manager=tilt-release-crds -f -
1316+
kubectl apply --server-side --field-manager=tilt-release-crds -f deploy/charts/controller/files/crds/
13201317
for crd in machineimages clusterreleases nodepoolreleases; do
13211318
kubectl wait --for=condition=Established --timeout=120s "crd/${crd}.internal.nvke.nvidia.com"
13221319
done
13231320
"""],
13241321
labels=["3-nvke-controller"],
1325-
deps=["deploy/charts/nvke-crds"],
1322+
deps=["deploy/charts/controller/files/crds"],
13261323
resource_deps=["check-management-cluster"],
13271324
)
13281325

@@ -1349,18 +1346,9 @@ local_resource(
13491346
allow_parallel=True,
13501347
)
13511348

1352-
# build_dependencies packages nvke-crds into the chart directory nvke-controller
1353-
# watches. Tilt does not read .gitignore, so without this every deploy's
1354-
# `helm dependency build` triggers the next deploy, and `tilt up` never settles.
1355-
watch_settings(ignore=[
1356-
"deploy/charts/controller/charts",
1357-
"deploy/charts/controller/tmpcharts-*",
1358-
])
1359-
13601349
helm_resource(
13611350
"nvke-controller",
13621351
chart="deploy/charts/controller",
1363-
build_dependencies=True,
13641352
labels=["3-nvke-controller"],
13651353
release_name="nvke-controller",
13661354
namespace=CONTROLLER_NAMESPACE,
@@ -1372,7 +1360,6 @@ helm_resource(
13721360
"hack/tilt-controller-chart-values.yaml",
13731361
"hack/tilt-controller-api-auth-values.yaml",
13741362
"deploy/charts/controller",
1375-
"deploy/charts/nvke-crds",
13761363
],
13771364
flags=_controller_chart_flags,
13781365
resource_deps=_controller_resource_deps,

‎controller/deploy/charts/charts.go‎

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,13 @@ import (
2626
const (
2727
NVKEController = "controller"
2828
Postgresql = "postgresql"
29-
NVKECRDs = "nvke-crds"
3029
)
3130

3231
// all: so that templates/_helpers.tpl is included; plain go:embed skips files
3332
// whose names start with "_" or ".", and a chart without its helpers renders
3433
// nothing useful.
3534
//
36-
//go:embed all:controller/Chart.yaml all:controller/Chart.lock all:controller/values.yaml
37-
//go:embed all:controller/LICENSE all:controller/NOTICE all:controller/README.md
38-
//go:embed all:controller/files all:controller/templates all:postgresql all:nvke-crds
35+
//go:embed all:controller all:postgresql
3936
var files embed.FS
4037

4138
// Names returns every embedded chart, sorted. These are directory names, which
@@ -66,7 +63,7 @@ func Has(name string) bool {
6663
return err == nil && info.IsDir()
6764
}
6865

69-
// FS returns the embedded source chart directory for name, or an error naming the
66+
// FS returns the embedded chart directory for name, or an error naming the
7067
// charts that exist.
7168
func FS(name string) (fs.FS, error) {
7269
if !Has(name) {
@@ -77,7 +74,6 @@ func FS(name string) (fs.FS, error) {
7774

7875
// Extract writes the embedded chart name into dir, which must not exist or
7976
// must be empty, so the result is exactly the chart and nothing else. The
80-
// controller dependency is assembled from its canonical embedded chart. The
8177
// directory can then be handed to helm as a chart path. Files are 0600 and
8278
// directories 0700: only the process that extracted the chart reads it.
8379
//
@@ -109,17 +105,6 @@ func Extract(name, dir string) error {
109105
clearDir(dir)
110106
return err
111107
}
112-
if name == NVKEController {
113-
dependency, depErr := FS(NVKECRDs)
114-
if depErr != nil {
115-
clearDir(dir)
116-
return depErr
117-
}
118-
if depErr := writeChart(dependency, filepath.Join(dir, "charts", NVKECRDs)); depErr != nil {
119-
clearDir(dir)
120-
return depErr
121-
}
122-
}
123108
// After the walk, not before: MkdirAll leaves an existing directory's mode
124109
// alone, so this is what makes the 0700 above true of dir itself.
125110
if err := os.Chmod(dir, 0o700); err != nil {

0 commit comments

Comments
 (0)