|
| 1 | +--- |
| 2 | +assignees: |
| 3 | +- mikedanese |
| 4 | +- luxas |
| 5 | +- errordeveloper |
| 6 | + |
| 7 | +--- |
| 8 | + |
| 9 | + |
| 10 | +This document provides information on how to use kubeadm's advanced options. |
| 11 | + |
| 12 | +Running kubeadm init bootstraps a Kubernetes cluster. This consists of the |
| 13 | +following steps: |
| 14 | + |
| 15 | +1. kubeadm generates a token that additional nodes can use to register themselves |
| 16 | +with the master in future. |
| 17 | + |
| 18 | +1. kubeadm generates a self-signed CA using openssl to provision identities |
| 19 | +for each node in the cluster, and for the API server to secure communication |
| 20 | +with clients. |
| 21 | + |
| 22 | +1. Outputting a kubeconfig file for the kubelet to use to connect to the API server, |
| 23 | +as well as an additional kubeconfig file for administration. |
| 24 | + |
| 25 | +1. kubeadm generates Kubernetes resource manifests for the API server, controller manager |
| 26 | +and scheduler, and placing them in `/etc/kubernetes/manifests`. The kubelet watches |
| 27 | +this directory for static resources to create on startup. These are the core |
| 28 | +components of Kubernetes, and once they are up and running we can use `kubectl` |
| 29 | +to set up/manage any additional components. |
| 30 | + |
| 31 | +1. kubeadm installs any add-on components, such as DNS or discovery, via the API server. |
| 32 | + |
| 33 | +## Usage |
| 34 | + |
| 35 | +Fields that support multiple values do so either with comma separation, or by specifying |
| 36 | +the flag multiple times. |
| 37 | + |
| 38 | +### `kubeadm init` |
| 39 | + |
| 40 | +It is usually sufficient to run `kubeadm init` without any flags, |
| 41 | +but in some cases you might like to override the default behaviour. |
| 42 | +Here we specify all the flags that can be used to customise the Kubernetes |
| 43 | +installation. |
| 44 | + |
| 45 | +- `--api-advertise-addresses` (multiple values are allowed) |
| 46 | +- `--api-external-dns-names` (multiple values are allowed) |
| 47 | + |
| 48 | +By default, `kubeadm init` automatically detects IP addresses and uses |
| 49 | +these to generate certificates for the API server. This uses the IP address |
| 50 | +of the default network interface. If you would like to access the API server |
| 51 | +through a different IP address, or through a hostname, you can override these |
| 52 | +defaults with `--api-advertise-addresses` and `--api-external-dns-names`. |
| 53 | +For example, to generate certificates that verify the API server at addresses |
| 54 | +`10.100.245.1` and `100.123.121.1`, you could use |
| 55 | +`--api-advertise-addresses=10.100.245.1,100.123.121.1`. To allow it to be accessed |
| 56 | +with a hostname, `--api-external-dns-names=kubernetes.example.com,kube.example.com` |
| 57 | +Specifying `--api-advertise-addresses` disables auto detection of IP addresses. |
| 58 | + |
| 59 | +- `--cloud-provider` |
| 60 | + |
| 61 | +Currently, `kubeadm init` does not provide autodetection of cloud provider. |
| 62 | +This means that load balancing and persistent volumes are not supported out |
| 63 | +of the box. You can specify a cloud provider using `--cloud-provider`. |
| 64 | +Valid values are the ones supported by `controller-manager`, namely `"aws"`, |
| 65 | +`"azure"`, `"cloudstack"`, `"gce"`, `"mesos"`, `"openstack"`, `"ovirt"`, |
| 66 | +`"rackspace"`, `"vsphere"`. In order to provide additional configuration for |
| 67 | +the cloud provider, you should create a `/etc/kubernetes/cloud-config.json` |
| 68 | +file manually, before running `kubeadm init`. `kubeadm` automatically |
| 69 | +picks those settings up and ensures other nodes are configured correctly. |
| 70 | +You must also set the `--cloud-provider` and `--cloud-config` parameters |
| 71 | +yourself by editing the `/etc/systemd/system/kubelet.service.d/10-kubeadm.conf` |
| 72 | +file appropriately. |
| 73 | + |
| 74 | +- `--external-etcd-cafile` etcd certificate authority file |
| 75 | +- `--external-etcd-endpoints` (multiple values are allowed) |
| 76 | +- `--external-etcd-certfile` etcd client certificate file |
| 77 | +- `--external-etcd-keyfile` etcd client key file |
| 78 | + |
| 79 | +By default, `kubeadm` deploys a single node etcd cluster on the master |
| 80 | +to store Kubernetes state. This means that any failure on the master node |
| 81 | +requires you to rebuild your cluster from scratch. Currently `kubeadm init` |
| 82 | +does not support automatic deployment of a highly available etcd cluster. |
| 83 | +If you would like to use your own etcd cluster, you can override this |
| 84 | +behaviour with `--external-etcd-endpoints`. `kubeadm` supports etcd client |
| 85 | +authentication using the `--external-etcd-cafile`, `--external-etcd-certfile` |
| 86 | +and `--external-etcd-keyfile` flags. |
| 87 | + |
| 88 | +- `--pod-network-cidr` |
| 89 | + |
| 90 | +By default, `kubeadm init` does not set node CIDR's for pods and allows you to |
| 91 | +bring your own networking configuration through a CNI compatible network |
| 92 | +controller addon such as [Weave Net](https://github.com/weaveworks/weave-kube), |
| 93 | +[Calico](https://github.com/projectcalico/calico-containers/tree/master/docs/cni/kubernetes/manifests/kubeadm) |
| 94 | +or [Canal](https://github.com/tigera/canal/tree/master/k8s-install/kubeadm). |
| 95 | +If you are using a compatible cloud provider or flannel, you can specify a |
| 96 | +subnet to use for each pod on the cluster with the `--pod-network-cidr` flag. |
| 97 | +This should be a minimum of a /16 so that kubeadm is able to assign /24 subnets |
| 98 | +to each node in the cluster. |
| 99 | + |
| 100 | +- `--service-cidr` (default '10.12.0.0/12') |
| 101 | + |
| 102 | +You can use the `--service-cidr` flag to override the subnet Kubernetes uses to |
| 103 | +assign pods IP addresses. If you do, you will also need to update the |
| 104 | +`/etc/systemd/system/kubelet.service.d/10-kubeadm.conf` file to reflect this change |
| 105 | +else DNS will not function correctly. |
| 106 | + |
| 107 | +- `--service-dns-domain` (default 'cluster.local') |
| 108 | + |
| 109 | +By default, `kubeadm init` deploys a cluster that assigns services with DNS names |
| 110 | +`<service_name>.<namespace>.svc.cluster.local`. You can use the `--service-dns-domain` |
| 111 | +to change the DNS name suffix. Again, you will need to update the |
| 112 | +`/etc/systemd/system/kubelet.service.d/10-kubeadm.conf` file accordingly else DNS will |
| 113 | +not function correctly. |
| 114 | + |
| 115 | +- `--token` |
| 116 | + |
| 117 | +By default, `kubeadm init` automatically generates the token used to initialise |
| 118 | +each new node. If you would like to manually specify this token, you can use the |
| 119 | +`--token` flag. The token must be of the format '<6 character string>.<16 character string>'. |
| 120 | + |
| 121 | +- `--use-kubernetes-version` (default 'v1.4.1') the kubernetes version to initialise |
| 122 | + |
| 123 | +`kubeadm` was originally built for Kubernetes version **v1.4.0**, older versions are not |
| 124 | +supported. With this flag you can try any future version, e.g. **v1.5.0-beta.1** |
| 125 | +whenever it comes out (check [releases page](https://github.com/kubernetes/kubernetes/releases) |
| 126 | +for a full list of available versions). |
| 127 | + |
| 128 | +### `kubeadm join` |
| 129 | + |
| 130 | +`kubeadm join` has one mandatory flag, the token used to secure cluster bootstrap, |
| 131 | +and one mandatory argument, the master IP address. |
| 132 | + |
| 133 | +Here's an example on how to use it: |
| 134 | + |
| 135 | +`kubeadm join --token=the_secret_token 192.168.1.1` |
| 136 | + |
| 137 | +- `--token=<token>` |
| 138 | + |
| 139 | +By default, when `kubeadm init` runs, a token is generated and revealed in the output. |
| 140 | +That's the token you should use here. |
| 141 | + |
| 142 | +## Troubleshooting |
| 143 | + |
| 144 | +* Some users on RHEL/CentOS 7 have reported issues with traffic being routed incorrectly due to iptables being bypassed. You should ensure `net.bridge.bridge-nf-call-iptables` is set to 1 in your sysctl config, eg. |
| 145 | + |
| 146 | +``` |
| 147 | +# cat /etc/sysctl.d/k8s.conf |
| 148 | +net.bridge.bridge-nf-call-ip6tables = 1 |
| 149 | +net.bridge.bridge-nf-call-iptables = 1 |
| 150 | +``` |
0 commit comments