1. Requirements
1) Linux
Not running Linux? Consider running Minikube, or on a cloud provider like Google Compute Engine.
It recommends Ubuntu16.04.
2) Go
You need go in your path (see here for supported versions), please make sure it is installed and in your $PATH.
It recommends Go1.9.2+.
$ wget https://golang.org/dl/go1.9.2.linux-amd64.tar.gz
$ tar -C /usr/local -xzf go1.9.2.linux-amd64.tar.gz
PS: It's better to set environments by adding the following sections into /etc/profile like this:
3) Docker
At least Docker 1.10+. Ensure the Docker daemon is running and can be contacted (try docker ps).
Some of the Kubernetes components need to run as root, which normally works fine with docker.
$ apt-get install docker.io
$ docker env
4) etcd
You need an etcd in your path, please make sure it is installed and in your $PATH.
It recommends etcd3.2.6+.
$ wget https://github.com/coreos/etcd/releases/download/v3.2.6/etcd-v3.2.6-linux-amd64.tar.gz
$ tar -C /usr/local -xzf etcd-v3.2.6-linux-amd64.tar.gz
5) OpenSSL
You need OpenSSL installed. If you do not have the openssl command available, the script will print an appropriate error.
$ apt-get install openssl
6) CFSSL
The CFSSL binaries (cfssl, cfssljson) must be installed and available on your $PATH.
The easiest way to get it is something similar to the following:
$ apt-get install build-essential
$ go get -u github.com/cloudflare/cfssl/cmd/...
PS: This command will download and build cfssl packages into $GOPATH/bin
2. Networking
Kubernetes is using CNI as the networking plugin, like flannel,dhcp,loopback and so forth.
1) Build CNI
$ go get github.com/containernetworking/plugins/...
PS: This command will download and build CNI packages into $GOPATH/bin
2) Add Conf
$ mkdir -p /etc/cni/net.d
3. Kubernetes
1) Download
$ git clone https://github.com/kubernetes/kubernetes.git
2) Build
$ cd kubernetes
$ make
3) Set Env
set environments by adding the following sections into /etc/profile like this:
4) Run
$ cd kubernetes
$ hack/local-up-cluster.sh # Build and Run
$ hack/local-up-cluster.sh -O # Already build and Run
5) Test
$ cluster/kubectl.sh get pods
$ cluster/kubectl.sh run my-nginx --image=nginx --replicas=2 --port=80
## begin wait for provision to complete, you can monitor the docker pull by opening a new terminal
$ docker images
## you should see it pulling the nginx image, once the above command returns it
$ docker ps
## you should see your container running!
exit
## end wait
## introspect Kubernetes!
$ cluster/kubectl.sh get pods
PS: The following docker images will be automatically download.
They can be shown by command "docker images".
Actually these containers will be run to provider the Kubernetes DNS Cluster Service.
gcr.io/google_containers/k8s-dns-sidecar-amd64
gcr.io/google_containers/k8s-dns-kube-dns-amd64
gcr.io/google_containers/k8s-dns-dnsmasq-nanny-amd64
gcr.io/google_containers/pause-amd64
4. Trouble Shooting
1) swap
-
- Error
Running with swap on is not supported, please disable swap!
-
- Solution
* Identify configured swap devices and files with cat /proc/swaps.
* Turn off all swap devices and files with swapoff -a.
* Remove any matching reference found in /etc/fstab.
* Optional: Destroy any swap devices or files found in step 1 to prevent their reuse.
* Due to your concerns about leaking sensitive information, you may wish to consider performing some sort of secure wipe.
2) Improvement
$ vi s.sh
~/go/src/kubernetes/hack/local-up-cluster.sh -O
$ source s.sh # simply to run kubernetes server
$ cp kubernetes/_output/bin/kubelet /usr/local/bin/
$ kubelet # simply to replace cluster/kubectl.sh into kubelet
$ alias k=kubectl
3) Improvement
# export SERVICE_ACCOUNT_LOOKUP=false
# export NET_PLUGIN=kubenet #just for gce
$ kubectl exec POD_NAME -it /bin/bash
$ kubectl logs
$ kubectl cluster-info dump