Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save etsangsplk/77be96699ec5a4c46c9bc09b6bdb6b2b to your computer and use it in GitHub Desktop.
Save etsangsplk/77be96699ec5a4c46c9bc09b6bdb6b2b to your computer and use it in GitHub Desktop.
Resources on creating a development environment for contributing to Kubernetes.

Environment for Developing Kubernetes

First and foremost, this is not a document on how to create an environment for developing applications targeting Kubernetes as its runtime. This document is to outline the steps required to create an environment for contributing to Kubernetes based on recently setting up both Linux and Mac development environments. This document is written as if you will be creating your development enivonment on OS X but just know that things are basically the same when on other OSes. Of course, the installation and configuration of these tools will changed based on which OS you're on, and possibly other things, but the gist is that in this guide when you see that tool X is required, you follow whatever steps to install tool X on your OS.

Let's get started.

Install Docker

brew cask install docker

Notice that brew cask install was used instead of brew install docker. The reason for this is we want to install Docker for Mac, which runs natively on OS X instead of through a virtualization environment like Virtualbox. This option also makes it possible to share your host disk with containers running on Docker, which is required.

Once you have Docker installed, just open /Applications/Docker.app and wait for the application's menu bar to indicate that Docker is in fact running.

Install Go

brew install golang

At this point, you need to set your GOROOT environment variable using whatever mechanism your shell dictates. For example, I threw export GOROOT=`brew --prefix`/opt/go/libexec into my ~/.zshrc. Regardless of how you do Go development, your GOROOT should never change.

As for setting your GOPATH environment variable, that is up to you so instead of telling you how to set it, I will point you to the Go documentation on the matter.

Once you do get your GOPATH and GOROOT set appropriately, you need to update your PATH environment variable to include ${GOPATH}/bin:${GOROOT}/bin. Again, this depends on your shell but for me, I threw export PATH="${GOPATH}/bin:${GOROOT}/bin:$PATH" into my ~/.zshrc.

Update BSD Tools (Mac Only)

Per the Kubernetes Development Guide, you need to update the BSD tools provided by OS X. This is documented here.

Note: You do not have to update all BSD tools for Kubernetes development but it wouldn't hurt. Feel free to skip some of the superfluous tools, like the editors.

Install Go Packages

Kubernetes uses a number of Go packages during its build/test process, and when running a local development cluster. These tools are mentioned below:

go get -u github.com/tools/godep
go get -u github.com/jteeuwen/go-bindata/go-bindata
go get -u github.com/cloudflare/cfssl/cmd/...

Install etcd

If you want to run a local development build of Kubernetes, you will need to install etcd. While you could potentially use brew install etcd, to avoid any versioning conflicts you can instead use ./hack/install-etcd.sh. This will install the appropriate version of etcd within the Kubernetes source base (so no conflicts with an external etcd) and the last step will be to update your PATH environment variable to have $GOPATH/src/k8s.io/kubernetes/third_party/etcd in it, as documented above.

Conclusion

At this point, you should be able to build (make), test (make test) and even run a local development build of Kubernetes (./hack/local-up-cluster.sh) using this environment. Of course, much of the details in this document can be found in the Kubernetes Development Guide.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment