github.com/enmand/kubernetes@v1.2.0-alpha.0/docs/getting-started-guides/fedora/flannel_multi_node_cluster.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/fedora/flannel_multi_node_cluster.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  Kubernetes multiple nodes cluster with flannel on Fedora
    34  --------------------------------------------------------
    35  
    36  **Table of Contents**
    37  
    38  - [Introduction](#introduction)
    39  - [Prerequisites](#prerequisites)
    40  - [Master Setup](#master-setup)
    41  - [Node Setup](#node-setup)
    42  - [**Test the cluster and flannel configuration**](#test-the-cluster-and-flannel-configuration)
    43  
    44  ## Introduction
    45  
    46  This document describes how to deploy Kubernetes on multiple hosts to set up a multi-node cluster and networking with flannel. Follow fedora [getting started guide](fedora_manual_config.md) to setup 1 master (fed-master) and 2 or more nodes. Make sure that all nodes have different names (fed-node1, fed-node2 and so on) and labels (fed-node1-label, fed-node2-label, and so on) to avoid any conflict. Also make sure that the Kubernetes master host is running etcd, kube-controller-manager, kube-scheduler, and kube-apiserver services, and the nodes are running docker, kube-proxy and kubelet services. Now install flannel on Kubernetes nodes. flannel on each node configures an overlay network that docker uses. flannel runs on each node to setup a unique class-C container network.
    47  
    48  ## Prerequisites
    49  
    50  1. You need 2 or more machines with Fedora installed.
    51  
    52  ## Master Setup
    53  
    54  **Perform following commands on the Kubernetes master**
    55  
    56  * Configure flannel by creating a `flannel-config.json` in your current directory on fed-master. flannel provides udp and vxlan among other overlay networking backend options. In this guide, we choose kernel based vxlan backend. The contents of the json are:
    57  
    58  ```json
    59  {
    60      "Network": "18.16.0.0/16",
    61      "SubnetLen": 24,
    62      "Backend": {
    63          "Type": "vxlan",
    64          "VNI": 1
    65       }
    66  }
    67  ```
    68  
    69  **NOTE:** Choose an IP range that is *NOT* part of the public IP address range.
    70  
    71  * Add the configuration to the etcd server on fed-master.
    72  
    73  ```sh
    74  etcdctl set /coreos.com/network/config < flannel-config.json
    75  ```
    76  
    77  * Verify the key exists in the etcd server on fed-master.
    78  
    79  ```sh
    80  etcdctl get /coreos.com/network/config
    81  ```
    82  
    83  ## Node Setup
    84  
    85  **Perform following commands on all Kubernetes nodes**
    86  
    87  * Edit the flannel configuration file /etc/sysconfig/flanneld as follows:
    88  
    89  ```sh
    90  # Flanneld configuration options
    91  
    92  # etcd url location.  Point this to the server where etcd runs
    93  FLANNEL_ETCD="http://fed-master:4001"
    94  
    95  # etcd config key.  This is the configuration key that flannel queries
    96  # For address range assignment
    97  FLANNEL_ETCD_KEY="/coreos.com/network"
    98  
    99  # Any additional options that you want to pass
   100  FLANNEL_OPTIONS=""
   101  ```
   102  
   103  **Note:** By default, flannel uses the interface for the default route. If you have multiple interfaces and would like to use an interface other than the default route one, you could add "-iface=" to FLANNEL_OPTIONS. For additional options, run `flanneld --help` on command line.
   104  
   105  * Enable the flannel service.
   106  
   107  ```sh
   108  systemctl enable flanneld
   109  ```
   110  
   111  * If docker is not running, then starting flannel service is enough and skip the next step.
   112  
   113  ```sh
   114  systemctl start flanneld
   115  ```
   116  
   117  * If docker is already running, then stop docker, delete docker bridge (docker0), start flanneld and restart docker as follows. Another alternative is to just reboot the system (`systemctl reboot`).
   118  
   119  ```sh
   120  systemctl stop docker
   121  ip link delete docker0
   122  systemctl start flanneld
   123  systemctl start docker
   124  ```
   125  
   126  ***
   127  
   128  ## **Test the cluster and flannel configuration**
   129  
   130  * Now check the interfaces on the nodes. Notice there is now a flannel.1 interface, and the ip addresses of docker0 and flannel.1 interfaces are in the same network. You will notice that docker0 is assigned a subnet (18.16.29.0/24 as shown below) on each Kubernetes node out of the IP range configured above. A working output should look like this:
   131  
   132  ```console
   133  # ip -4 a|grep inet
   134      inet 127.0.0.1/8 scope host lo
   135      inet 192.168.122.77/24 brd 192.168.122.255 scope global dynamic eth0
   136      inet 18.16.29.0/16 scope global flannel.1
   137      inet 18.16.29.1/24 scope global docker0
   138  ```
   139  
   140  * From any node in the cluster, check the cluster members by issuing a query to etcd server via curl (only partial output is shown using `grep -E "\{|\}|key|value"`). If you set up a 1 master and 3 nodes cluster, you should see one block for each node showing the subnets they have been assigned. You can associate those subnets to each node by the MAC address (VtepMAC) and IP address (Public IP) that is listed in the output.
   141  
   142  ```sh
   143  curl -s http://fed-master:4001/v2/keys/coreos.com/network/subnets | python -mjson.tool
   144  ```
   145  
   146  ```json
   147  {
   148      "node": {
   149          "key": "/coreos.com/network/subnets",
   150              {
   151                  "key": "/coreos.com/network/subnets/18.16.29.0-24",
   152                  "value": "{\"PublicIP\":\"192.168.122.77\",\"BackendType\":\"vxlan\",\"BackendData\":{\"VtepMAC\":\"46:f1:d0:18:d0:65\"}}"
   153              },
   154              {
   155                  "key": "/coreos.com/network/subnets/18.16.83.0-24",
   156                  "value": "{\"PublicIP\":\"192.168.122.36\",\"BackendType\":\"vxlan\",\"BackendData\":{\"VtepMAC\":\"ca:38:78:fc:72:29\"}}"
   157              },
   158              {
   159                  "key": "/coreos.com/network/subnets/18.16.90.0-24",
   160                  "value": "{\"PublicIP\":\"192.168.122.127\",\"BackendType\":\"vxlan\",\"BackendData\":{\"VtepMAC\":\"92:e2:80:ba:2d:4d\"}}"
   161              }
   162      }
   163  }
   164  ```
   165  
   166  * From all nodes, review the `/run/flannel/subnet.env` file.  This file was generated automatically by flannel.
   167  
   168  ```console
   169  # cat /run/flannel/subnet.env
   170  FLANNEL_SUBNET=18.16.29.1/24
   171  FLANNEL_MTU=1450
   172  FLANNEL_IPMASQ=false
   173  ```
   174  
   175  * At this point, we have etcd running on the Kubernetes master, and flannel / docker running on Kubernetes nodes. Next steps are for testing cross-host container communication which will confirm that docker and flannel are configured properly.
   176  
   177  * Issue the following commands on any 2 nodes:
   178  
   179  ```console
   180  # docker run -it fedora:latest bash
   181  bash-4.3# 
   182  ```
   183  
   184  * This will place you inside the container. Install iproute and iputils packages to install ip and ping utilities. Due to a [bug](https://bugzilla.redhat.com/show_bug.cgi?id=1142311), it is required to modify capabilities of ping binary to work around "Operation not permitted" error.
   185  
   186  ```console
   187  bash-4.3# yum -y install iproute iputils
   188  bash-4.3# setcap cap_net_raw-ep /usr/bin/ping
   189  ```
   190  
   191  * Now note the IP address on the first node:
   192  
   193  ```console
   194  bash-4.3# ip -4 a l eth0 | grep inet
   195      inet 18.16.29.4/24 scope global eth0
   196  ```
   197  
   198  * And also note the IP address on the other node:
   199  
   200  ```console
   201  bash-4.3# ip a l eth0 | grep inet
   202      inet 18.16.90.4/24 scope global eth0
   203  ```
   204  
   205  * Now ping from the first node to the other node:
   206  
   207  ```console
   208  bash-4.3# ping 18.16.90.4
   209  PING 18.16.90.4 (18.16.90.4) 56(84) bytes of data.
   210  64 bytes from 18.16.90.4: icmp_seq=1 ttl=62 time=0.275 ms
   211  64 bytes from 18.16.90.4: icmp_seq=2 ttl=62 time=0.372 ms
   212  ```
   213  
   214  * Now Kubernetes multi-node cluster is set up with overlay networking set up by flannel.
   215  
   216  
   217  <!-- BEGIN MUNGE: GENERATED_ANALYTICS -->
   218  [![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/getting-started-guides/fedora/flannel_multi_node_cluster.md?pixel)]()
   219  <!-- END MUNGE: GENERATED_ANALYTICS -->