Public Repository

Last pushed: 7 months ago
Short Description
Environment for developing Kubernetes (the core project). Useful when developing on non-Linux hosts.
Full Description

Dockerfile

Why use this image

This image is for people who want to modify code belonging to the core Kubernetes project and compile and run a cluster locally on a non-Linux host through hack/local-up-cluster.sh. This is not a way to locally run a project that uses Kubernetes (for that use Minikube).

Using this image

First, make sure you have the Kubernetes source on your host. In this example I will put it in the GOPATH, but its location shouldn't matter:

mkdir $GOPATH/src/k8s.io/
git clone https://github.com/kubernetes/kubernetes.git $GOPATH/src/k8s.io/kubernetes

Then run this image, binding your local docker socket and Kubernetes directory:

docker run -v /var/run/docker.sock:/var/run/docker.sock \
  -v $GOPATH/src/k8s.io/kubernetes:/go/src/k8s.io/kubernetes \
  --name k8s-dev --rm -it alex-charlton/k8s-dev /bin/bash

You are then free to edit Kubernetes from your host and then compile and run a cluster from your k8s-dev image:

root@bcc2570ffab1:/go/src/k8s.io/kubernetes# ./hack/local-up-cluster.sh

...

Local Kubernetes cluster is running. Press Ctrl-C to shut it down.

Logs:
  /tmp/kube-apiserver.log
  /tmp/kube-controller-manager.log
  /tmp/kube-proxy.log
  /tmp/kube-scheduler.log
  /tmp/kubelet.log

To start using your cluster, open up another terminal/tab and run:

  export KUBERNETES_PROVIDER=local

  cluster/kubectl.sh config set-cluster local --server=https://localhost:6443 --certificate-authority=/var/run/kubernetes/apiserver.crt
  cluster/kubectl.sh config set-credentials myself --username=admin --password=admin
  cluster/kubectl.sh config set-context local --cluster=local --user=myself
  cluster/kubectl.sh config use-context local
  cluster/kubectl.sh

The local-up-cluster.sh script will output something similar to the above, when successful. To start using your cluster with kubectl, you can ssh into the container with docker exec -it k8s-dev /bin/bash and paste that last part.

Docker Pull Command
Owner
alexcharlton

Comments (0)