github.com/enmand/kubernetes@v1.2.0-alpha.0/docs/getting-started-guides/docker-multinode/master.md (about) 1 <!-- BEGIN MUNGE: UNVERSIONED_WARNING --> 2 3 <!-- BEGIN STRIP_FOR_RELEASE --> 4 5 <img src="http://kubernetes.io/img/warning.png" alt="WARNING" 6 width="25" height="25"> 7 <img src="http://kubernetes.io/img/warning.png" alt="WARNING" 8 width="25" height="25"> 9 <img src="http://kubernetes.io/img/warning.png" alt="WARNING" 10 width="25" height="25"> 11 <img src="http://kubernetes.io/img/warning.png" alt="WARNING" 12 width="25" height="25"> 13 <img src="http://kubernetes.io/img/warning.png" alt="WARNING" 14 width="25" height="25"> 15 16 <h2>PLEASE NOTE: This document applies to the HEAD of the source tree</h2> 17 18 If you are using a released version of Kubernetes, you should 19 refer to the docs that go with that version. 20 21 <strong> 22 The latest 1.0.x release of this document can be found 23 [here](http://releases.k8s.io/release-1.0/docs/getting-started-guides/docker-multinode/master.md). 24 25 Documentation for other releases can be found at 26 [releases.k8s.io](http://releases.k8s.io). 27 </strong> 28 -- 29 30 <!-- END STRIP_FOR_RELEASE --> 31 32 <!-- END MUNGE: UNVERSIONED_WARNING --> 33 34 ## Installing a Kubernetes Master Node via Docker 35 36 We'll begin by setting up the master node. For the purposes of illustration, we'll assume that the IP of this machine is `${MASTER_IP}` 37 38 There are two main phases to installing the master: 39 * [Setting up `flanneld` and `etcd`](#setting-up-flanneld-and-etcd) 40 * [Starting the Kubernetes master components](#starting-the-kubernetes-master) 41 42 43 ## Setting up flanneld and etcd 44 45 _Note_: 46 There is a [bug](https://github.com/docker/docker/issues/14106) in Docker 1.7.0 that prevents this from working correctly. 47 Please install Docker 1.6.2 or Docker 1.7.1. 48 49 ### Setup Docker-Bootstrap 50 51 We're going to use `flannel` to set up networking between Docker daemons. Flannel itself (and etcd on which it relies) will run inside of 52 Docker containers themselves. To achieve this, we need a separate "bootstrap" instance of the Docker daemon. This daemon will be started with 53 `--iptables=false` so that it can only run containers with `--net=host`. That's sufficient to bootstrap our system. 54 55 Run: 56 57 ```sh 58 sudo sh -c 'docker -d -H unix:///var/run/docker-bootstrap.sock -p /var/run/docker-bootstrap.pid --iptables=false --ip-masq=false --bridge=none --graph=/var/lib/docker-bootstrap 2> /var/log/docker-bootstrap.log 1> /dev/null &' 59 ``` 60 61 _Important Note_: 62 If you are running this on a long running system, rather than experimenting, you should run the bootstrap Docker instance under something like SysV init, upstart or systemd so that it is restarted 63 across reboots and failures. 64 65 66 ### Startup etcd for flannel and the API server to use 67 68 Run: 69 70 ```sh 71 sudo docker -H unix:///var/run/docker-bootstrap.sock run --net=host -d gcr.io/google_containers/etcd:2.0.12 /usr/local/bin/etcd --addr=127.0.0.1:4001 --bind-addr=0.0.0.0:4001 --data-dir=/var/etcd/data 72 ``` 73 74 Next, you need to set a CIDR range for flannel. This CIDR should be chosen to be non-overlapping with any existing network you are using: 75 76 ```sh 77 sudo docker -H unix:///var/run/docker-bootstrap.sock run --net=host gcr.io/google_containers/etcd:2.0.12 etcdctl set /coreos.com/network/config '{ "Network": "10.1.0.0/16" }' 78 ``` 79 80 81 ### Set up Flannel on the master node 82 83 Flannel is a network abstraction layer build by CoreOS, we will use it to provide simplified networking between our Pods of containers. 84 85 Flannel re-configures the bridge that Docker uses for networking. As a result we need to stop Docker, reconfigure its networking, and then restart Docker. 86 87 #### Bring down Docker 88 89 To re-configure Docker to use flannel, we need to take docker down, run flannel and then restart Docker. 90 91 Turning down Docker is system dependent, it may be: 92 93 ```sh 94 sudo /etc/init.d/docker stop 95 ``` 96 97 or 98 99 ```sh 100 sudo systemctl stop docker 101 ``` 102 103 or it may be something else. 104 105 #### Run flannel 106 107 Now run flanneld itself: 108 109 ```sh 110 sudo docker -H unix:///var/run/docker-bootstrap.sock run -d --net=host --privileged -v /dev/net:/dev/net quay.io/coreos/flannel:0.5.0 111 ``` 112 113 The previous command should have printed a really long hash, copy this hash. 114 115 Now get the subnet settings from flannel: 116 117 ```sh 118 sudo docker -H unix:///var/run/docker-bootstrap.sock exec <really-long-hash-from-above-here> cat /run/flannel/subnet.env 119 ``` 120 121 #### Edit the docker configuration 122 123 You now need to edit the docker configuration to activate new flags. Again, this is system specific. 124 125 This may be in `/etc/default/docker` or `/etc/systemd/service/docker.service` or it may be elsewhere. 126 127 Regardless, you need to add the following to the docker command line: 128 129 ```sh 130 --bip=${FLANNEL_SUBNET} --mtu=${FLANNEL_MTU} 131 ``` 132 133 #### Remove the existing Docker bridge 134 135 Docker creates a bridge named `docker0` by default. You need to remove this: 136 137 ```sh 138 sudo /sbin/ifconfig docker0 down 139 sudo brctl delbr docker0 140 ``` 141 142 You may need to install the `bridge-utils` package for the `brctl` binary. 143 144 #### Restart Docker 145 146 Again this is system dependent, it may be: 147 148 ```sh 149 sudo /etc/init.d/docker start 150 ``` 151 152 it may be: 153 154 ```sh 155 systemctl start docker 156 ``` 157 158 ## Starting the Kubernetes Master 159 160 Ok, now that your networking is set up, you can startup Kubernetes, this is the same as the single-node case, we will use the "main" instance of the Docker daemon for the Kubernetes components. 161 162 ```sh 163 sudo docker run --net=host -d -v /var/run/docker.sock:/var/run/docker.sock gcr.io/google_containers/hyperkube:v1.0.1 /hyperkube kubelet --api-servers=http://localhost:8080 --v=2 --address=0.0.0.0 --enable-server --hostname-override=127.0.0.1 --config=/etc/kubernetes/manifests-multi --cluster-dns=10.0.0.10 --cluster-domain=cluster.local 164 ``` 165 166 > Note that `--cluster-dns` and `--cluster-domain` is used to deploy dns, feel free to discard them if dns is not needed. 167 168 ### Also run the service proxy 169 170 ```sh 171 sudo docker run -d --net=host --privileged gcr.io/google_containers/hyperkube:v1.0.1 /hyperkube proxy --master=http://127.0.0.1:8080 --v=2 172 ``` 173 174 ### Test it out 175 176 At this point, you should have a functioning 1-node cluster. Let's test it out! 177 178 Download the kubectl binary and make it available by editing your PATH ENV. 179 ([OS X](http://storage.googleapis.com/kubernetes-release/release/v1.0.1/bin/darwin/amd64/kubectl)) 180 ([linux](http://storage.googleapis.com/kubernetes-release/release/v1.0.1/bin/linux/amd64/kubectl)) 181 182 List the nodes 183 184 ```sh 185 kubectl get nodes 186 ``` 187 188 This should print: 189 190 ```console 191 NAME LABELS STATUS 192 127.0.0.1 kubernetes.io/hostname=127.0.0.1 Ready 193 ``` 194 195 If the status of the node is `NotReady` or `Unknown` please check that all of the containers you created are successfully running. 196 If all else fails, ask questions on [Slack](../../troubleshooting.md#slack). 197 198 199 ### Next steps 200 201 Move on to [adding one or more workers](worker.md) or [deploy a dns](deployDNS.md) 202 203 204 <!-- BEGIN MUNGE: GENERATED_ANALYTICS --> 205 []() 206 <!-- END MUNGE: GENERATED_ANALYTICS -->