Open another terminal, configure kubectl and you're all set:
cd $GOPATH/src/k8s.io/kubernetes
export KUBECONFIG=/var/run/kubernetes/admin.kubeconfig
cluster/kubectl.sh
Unit Tests
Unit testing is an indispensable aspect of Kubernetes development. Code modifications generally come with corresponding unit tests update or addition. These tests can be run directly on different systems, such as OSX, Linux, etc.
For instance, after modifying the pkg/kubelet/kuberuntime code,
# Test with the Go package’s full path
go test -v k8s.io/kubernetes/pkg/kubelet/kuberuntime
# Or with the relative directory
go test -v ./pkg/kubelet/kuberuntime
End-To-End (e2e) Tests
End-to-end (e2e) tests require the launch of a Kubernetes cluster and can only be run on a Linux system.
Here's an example of how to launch the tests locally:
make WHAT='test/e2e/e2e.test'
make ginkgo
export KUBERNETES_PROVIDER=local
go run hack/e2e.go -v -test --test_args='--ginkgo.focus=Port\sforwarding'
go run hack/e2e.go -v -test --test_args='--ginkgo.focus=Feature:SecurityContext'
Note: Each PR in Kubernetes automatically triggers a series of e2e tests.
Node e2e Tests
Node e2e tests involve starting the Kubelet and can currently only be run on Linux systems.
export KUBERNETES_PROVIDER=local
make test-e2e-node FOCUS="InitContainer"
Note: Each PR in Kubernetes automatically triggers node e2e tests.
Useful git Commands
Many times, PRs need to be fetched locally for testing. To pull PR #365, for instance, you'd use
You can also configure .git/config to fetch all PRs using git fetch (be warned, however, that Kubernetes has a large PR count, thus this process may take a while):