kubernetes/kubernetes
Getting started
This page is the fastest path from a fresh clone to a running build, a passing test suite, and a local cluster you can poke at with kubectl.
Prerequisites
- Go matching
.go-version(currently1.26.x). Confirm withgo version. The build will reject older toolchains. - Make (the GNU variant). The repo's
Makefileis a symlink tobuild/root/Makefile. - etcd for integration and node tests.
hack/install-etcd.shdownloads the version the project pins. - Docker if you want to use the dockerized build (
make quick-release) or run e2e againstkind/minikube. - rsync, jq, curl — required by various
hack/scripts. - Container runtime if you want to run kubelet locally (
containerdis the default onlocal-up-cluster.sh).
The repository's CI runs Linux. macOS and Windows are best-effort for development.
Build
The fastest way to compile every binary:
makeThis calls hack/make-rules/build.sh and produces binaries under _output/bin/ (kube-apiserver, kube-controller-manager, kube-scheduler, kubelet, kube-proxy, kubectl, kubeadm, and the gen* doc tools).
Build a single binary:
make WHAT=cmd/kubectl
make WHAT=cmd/kube-apiserverTo produce a release tarball with hashed manifests, container images, and platform-specific archives:
make quick-release # uses Docker, slower but matches CI
make release-images # build container images onlyThe release tooling lives under build/ and is driven by build/release.sh, build/lib/release.sh, and friends.
Run
For a one-shot local cluster on your laptop, the canonical script is:
hack/local-up-cluster.shIt launches etcd, kube-apiserver, kube-controller-manager, kube-scheduler, kubelet, and kube-proxy on the host, with all components talking to each other over loopback. By default it expects a CRI runtime to be available (containerd is the default; CONTAINER_RUNTIME_ENDPOINT overrides). On exit it tears everything down. Re-run with KUBELET_HOST= and API_HOST= to bind to a different IP.
A second option is kind (Kubernetes IN Docker) for multi-node simulation. Build images with kind build node-image from the repo root.
Test
Unit tests:
make test # runs the entire pkg/... and cmd/... unit suite
make test WHAT=./pkg/scheduler/... # narrow scopeThe driver script is hack/test-go.sh. The test suite uses standard go test; make test KUBE_RACE=-race enables the race detector.
Integration tests (require etcd):
make test-integration WHAT=./test/integration/schedulerEnd-to-end tests are organized under test/e2e/ (cluster-level) and test/e2e_node/ (single-node kubelet). They are written against Ginkgo and require a running cluster:
hack/ginkgo-e2e.sh --ginkgo.focus="Conformance"
hack/e2e-node-test.shThe conformance subset is in test/conformance/. Fuzz suites (test/fuzz/) cover API serialization, validation, and conversion code.
Lint and typecheck
hack/verify-all.sh # one-stop "did I break anything?" runner
make verify # same, via the Makefile
make verify WHAT=spelling # narrow to a single checkThe Go static analysis is golangci-lint driven by hack/golangci.yaml. The linter is wrapped in hack/verify-golangci-lint.sh.
Code generation
A great deal of the source tree is generated. Whenever you change types.go files in pkg/apis/, staging/src/k8s.io/api/, or any CRI/CSI proto, run:
make update # the umbrella regenerator
hack/update-codegen.sh # API codegen (deepcopy/conversion/clientset/informer/lister/openapi)
hack/update-vendor.sh # refresh vendor/ from go.modGenerated files are named zz_generated_*.go and are committed to the repo. The pre-submit verify jobs reject PRs that have stale generated output.
Common pitfalls
- Building outside
$GOPATH. The build now uses Go modules and works anywhere on disk; older docs that mention$GOPATH/src/k8s.io/kubernetesare out of date. - Stale generated code. After editing API types, you must rerun codegen. The
make verifystep catches this in CI. - etcd not on PATH.
hack/install-etcd.shputs it underthird_party/etcdand setsPATHautomatically when scripts sourcehack/lib/. - CRI runtime missing.
local-up-cluster.shassumescontainerdis reachable on the system. On a fresh VM, install it first. - Leftover state. After
local-up-cluster.shexits, leftover files live under/var/run/kubernetesand/tmp/local-up-cluster.sh.*. Delete them between runs if you change flags.
For the full contributor experience — branching, PR rules, sign-off, review expectations — see how-to-contribute.
Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.