This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
This is the Managed Node Metadata Operator for OpenShift Dedicated - a Kubernetes operator written in Go that syncs metadata (labels and taints) from MachineSets to existing Nodes. The operator watches MachineSet objects and reconciles any labels or taints to corresponding Nodes within the pool, solving the limitation where machine-api-operator doesn't reconcile metadata to existing machines.
- Controller:
controllers/machineset_controller.go- Main controller that watches MachineSets and reconciles metadata to Machines and their referenced Nodes - Core Logic:
pkg/machine/machine.go- Contains the core reconciliation logic for syncing labels and taints - Metrics:
pkg/metrics/metrics.go- Prometheus metrics for operator monitoring - Main Entry:
main.go- Operator entry point using controller-runtime
The operator follows this reconciliation flow:
- Watch MachineSet changes
- Loop through all Machines in the MachineSet
- Sync label/taint changes from MachineSet to Machine
- Get referenced Node and sync changes from Machine to Node
This project uses OpenShift's golang-osd-operator boilerplate convention. Key commands:
# Run operator locally (uses your current kubeconfig)
go run .
# Run unit tests
make test
# Run integration tests (requires cluster and env vars)
go test -count=1 ./int/
# Run linting and static analysis
make lint
# Run code generation and validation
make validate
# Build the binary
make go-buildFor E2E/integration tests, these environment variables must be set:
OCM_TOKEN- OCM authentication tokenOCM_CLUSTER_ID- Target cluster IDOCM_ENV- Environment (stage|int)
# Build and push operator image
make docker-build docker-push
# Deploy to cluster (requires IMAGE_* env vars set)
make deploy
# Run tests in container environment (mirrors CI)
make container-test
make container-lint
make container-validateexport REGISTRY_TOKEN=... # quay.io encrypted password
export REGISTRY_USER=... # quay.io username
export IMG=quay.io/$REGISTRY_USER/managed-node-metadata-operator
export IMAGE_REPOSITORY=$REGISTRY_USERThis project has FIPS enabled (FIPS_ENABLED=true in Makefile). The fips.go file is auto-generated to ensure FIPS-compliant TLS configuration.
- Unit tests:
make test(excludes integration tests in./int/) - Integration tests:
go test ./int/(requires cluster access and OCM env vars) - E2E tests: Located in
test/e2e/with specific OCM requirements - Container tests:
make container-testfor CI-like environment
The project uses Ginkgo/Gomega for testing framework.