See the root AGENTS.md for repo-wide setup and PR guidelines. This file adds rules specific to operator/.
api/aistore/v1beta1/—AIStoreCRD types and validation.api/aisauth/v1alpha1/—AIStoreAuthandAIStoreAuthProfileCRD types and validation.internal/controller/— reconcile loops, one subdirectory per CRD group (aistore,aisauth).internal/resources/— builds the K8s objects the controllers apply:aistore/{proxy,target,adminclient,cmn},aisauth/(AuthN deployment, ConfigMap, services, volumes, plus itsconfig/types),certificates,ownerref.internal/services/— clients the operator uses at runtime: AIS API (aisapi.go), auth token exchange (auth_api.go,auth_profile.go), TLS client config.internal/webhook/— admission webhooks, one subdirectory per CRD group (aistore/v1beta1,aisauth/v1alpha1).internal/client/,internal/svcaddr/,internal/truststore/,internal/opinfo/— smaller shared helpers (K8s client wrapper, service address resolution, CA trust pool, cluster domain and operator identity).config/— kustomize manifests.make manifestswrites generated CRD, RBAC, and webhook YAML intoconfig/base/.config/overlays/holds thedefault,helm,certmanager,metrics, andtestoverlays.config/samples/holds example CRs, one per resource or scenario.cmd/main.go— entrypoint.tests/— E2E specs (e2e/), shared test helpers (tutils/), in-cluster CI runner (ci/).scripts/— shell helpers the Makefile calls for tests, lint, and tool installation.
cd operator
go mod download
Make targets:
make build # go build the manager binary
make run # run the controller against the cluster in ~/.kube/config
make manifests # regenerate CRD/RBAC/webhook YAML from kubebuilder markers
make generate # regenerate deepcopy/mock code
build, run, test, and test-e2e each depend on manifests and generate, so they rewrite generated files. build and run also depend on fmt and vet, so they reformat the tree. While you edit, call the Go tools directly instead, so unrelated generated files stay out of the diff:
go build ./... # compile check
go vet ./...
If you change types under api/, run make generate and make manifests, then regenerate the Helm chart. Pass the version the chart already declares:
make build-installer-helm VERSION=<current version in helm/ais-operator/Chart.yaml>
build-installer-helm rewrites .version and .appVersion in helm/ais-operator/Chart.yaml and the image tag in config/overlays/default/kustomization.yaml. Pass a different version only during a release. make build-installer writes dist/ais-operator.yaml, which is gitignored and needed only at release time.
- Add the field and its validation markers to the type under
api/. The doc comment on the field becomes the CRD description. - Add any cross-field or update-only rule to the matching package under
internal/webhook/. - If the field names a Secret, the webhook must enforce that the CR editor has access via
SubjectAccessReview. - Use the field where the operator builds the workload, under
internal/resources/. - Run
make generateandmake manifests, thenmake build-installer-helmas described above. - Add a one-line entry to
CHANGELOG.mdunderUnreleased.
Update the Helm chart in ../helm/ais/charts/ais-cluster/ and its values.schema.json only when the request asks for it. The chart passes the value through and sets no default.
Run from operator/. Full details: tests/README.md.
Unit tests live beside the code they cover, as one ginkgo suite per package (*_suite_test.go bootstraps the suite). A *_internal_test.go file uses the package under test for white-box coverage.
make test # unit tests
make kind-setup # create a local kind cluster for E2E
make test-e2e-bootstrap # install E2E test dependencies
make test-e2e-in-cluster # run E2E tests inside the cluster
AIS_TEST_API_MODE=public make test-e2e # run E2E tests from outside the cluster
TEST_E2E_MODE=manual make test-e2e-in-cluster # include ginkgo `manual`-labeled specs
make test-e2e-teardown # tear down E2E dependencies
make kind-teardown # delete the kind cluster
E2E test behavior is configurable via environment variables (test images, storage class, API mode) — see the table in tests/README.md.
To iterate on a single package or spec, call ginkgo directly instead of make test:
ginkgo ./internal/services # one package
ginkgo --focus "<spec text>" ./internal/services # one spec
Only the suites in internal/controller/aistore/ and api/aistore/v1beta1/ start envtest and need KUBEBUILDER_ASSETS; use make test for those. Every other unit package runs under a direct ginkgo or go test call.
Run the full suite when the change is broad, or before you commit. Do not start an E2E run or a kind cluster unless the request asks for it.
Run from operator/:
make lint # golangci-lint
make lint-fix # golangci-lint with autofix
make fmt-check # go mod tidy check, copyright headers, import block spacing
make fmt-fix # gofmt -s -w only
make check-gen # verify config/ and helm/ais-operator/ match the generators
make fmt-fix fixes nothing that make fmt-check reports. Fix those by hand: run go mod tidy, add the file header, or collapse the blank lines in the import block. See CONVENTIONS.md for the file-style and comment rules these commands check, and for the scope, API, deprecation, logging, and test rules this project applies.
make lint installs a pinned golangci-lint into bin/. After it runs once, call that binary on one package to check a single edit.
make check-gen diffs config/ and helm/ais-operator/ against HEAD, so commit regenerated manifests before you run it.
CI runs make lint, make fmt-check, and make check-gen on every operator change — run these locally before committing.
- CI pushes the
aistorage/ais-operatorimage on av*tag push and via manual workflow dispatch. ../pages/holds the published Helm chart repo.- Release process:
../docs/operator_release.md.VERSION=<x.y.z> make releasealso creates the release commit, so do not run it unless you intend that. - Changing the supported AIStore or Kubernetes versions also requires an update to
../docs/COMPATIBILITY.md.