github.com/enmand/kubernetes@v1.2.0-alpha.0/docs/getting-started-guides/docker-multinode/worker.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/worker.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  ## Adding a Kubernetes worker node via Docker.
    35  
    36  
    37  
    38  These instructions are very similar to the master set-up above, but they are duplicated for clarity.
    39  You need to repeat these instructions for each node you want to join the cluster.
    40  We will assume that the IP address of this node is `${NODE_IP}` and you have the IP address of the master in `${MASTER_IP}` that you created in the [master instructions](master.md).
    41  
    42  For each worker node, there are three steps:
    43     * [Set up `flanneld` on the worker node](#set-up-flanneld-on-the-worker-node)
    44     * [Start Kubernetes on the worker node](#start-kubernetes-on-the-worker-node)
    45     * [Add the worker to the cluster](#add-the-node-to-the-cluster)
    46  
    47  ### Set up Flanneld on the worker node
    48  
    49  As before, the Flannel daemon is going to provide network connectivity.
    50  
    51  _Note_:
    52  There is a [bug](https://github.com/docker/docker/issues/14106) in Docker 1.7.0 that prevents this from working correctly.
    53  Please install Docker 1.6.2 or wait for Docker 1.7.1.
    54  
    55  
    56  #### Set up a bootstrap docker
    57  
    58  As previously, we need a second instance of the Docker daemon running to bootstrap the flannel networking.
    59  
    60  Run:
    61  
    62  ```sh
    63  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 &'
    64  ```
    65  
    66  _Important Note_:
    67  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
    68  across reboots and failures.
    69  
    70  #### Bring down Docker
    71  
    72  To re-configure Docker to use flannel, we need to take docker down, run flannel and then restart Docker.
    73  
    74  Turning down Docker is system dependent, it may be:
    75  
    76  ```sh
    77  sudo /etc/init.d/docker stop
    78  ```
    79  
    80  or
    81  
    82  ```sh
    83  sudo systemctl stop docker
    84  ```
    85  
    86  or it may be something else.
    87  
    88  #### Run flannel
    89  
    90  Now run flanneld itself, this call is slightly different from the above, since we point it at the etcd instance on the master.
    91  
    92  ```sh
    93  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 /opt/bin/flanneld --etcd-endpoints=http://${MASTER_IP}:4001
    94  ```
    95  
    96  The previous command should have printed a really long hash, copy this hash.
    97  
    98  Now get the subnet settings from flannel:
    99  
   100  ```sh
   101  sudo docker -H unix:///var/run/docker-bootstrap.sock exec <really-long-hash-from-above-here> cat /run/flannel/subnet.env
   102  ```
   103  
   104  
   105  #### Edit the docker configuration
   106  
   107  You now need to edit the docker configuration to activate new flags.  Again, this is system specific.
   108  
   109  This may be in `/etc/default/docker` or `/etc/systemd/service/docker.service` or it may be elsewhere.
   110  
   111  Regardless, you need to add the following to the docker command line:
   112  
   113  ```sh
   114  --bip=${FLANNEL_SUBNET} --mtu=${FLANNEL_MTU}
   115  ```
   116  
   117  #### Remove the existing Docker bridge
   118  
   119  Docker creates a bridge named `docker0` by default.  You need to remove this:
   120  
   121  ```sh
   122  sudo /sbin/ifconfig docker0 down
   123  sudo brctl delbr docker0
   124  ```
   125  
   126  You may need to install the `bridge-utils` package for the `brctl` binary.
   127  
   128  #### Restart Docker
   129  
   130  Again this is system dependent, it may be:
   131  
   132  ```sh
   133  sudo /etc/init.d/docker start
   134  ```
   135  
   136  it may be:
   137  
   138  ```sh
   139  systemctl start docker
   140  ```
   141  
   142  ### Start Kubernetes on the worker node
   143  
   144  #### Run the kubelet
   145  
   146  Again this is similar to the above, but the `--api-servers` now points to the master we set up in the beginning.
   147  
   148  ```sh
   149  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://${MASTER_IP}:8080 --v=2 --address=0.0.0.0 --enable-server --hostname-override=$(hostname -i) --cluster-dns=10.0.0.10 --cluster-domain=cluster.local
   150  ```
   151  
   152  #### Run the service proxy
   153  
   154  The service proxy provides load-balancing between groups of containers defined by Kubernetes `Services`
   155  
   156  ```sh
   157  sudo docker run -d --net=host --privileged gcr.io/google_containers/hyperkube:v1.0.1 /hyperkube proxy --master=http://${MASTER_IP}:8080 --v=2
   158  ```
   159  
   160  ### Next steps
   161  
   162  Move on to [testing your cluster](testing.md) or [add another node](#adding-a-kubernetes-worker-node-via-docker)
   163  
   164  
   165  <!-- BEGIN MUNGE: GENERATED_ANALYTICS -->
   166  [![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/getting-started-guides/docker-multinode/worker.md?pixel)]()
   167  <!-- END MUNGE: GENERATED_ANALYTICS -->