From ffe9bb0e25bfbd5b1ee7b04c86d42210ce296809 Mon Sep 17 00:00:00 2001 From: He Simei Date: Thu, 27 Aug 2015 12:57:56 +0800 Subject: [PATCH] upgrade to v1.0.3, refactor the guide --- cluster/ubuntu/build.sh | 2 +- .../docker-multinode/master.md | 2 +- docs/getting-started-guides/ubuntu.md | 143 ++++++++++-------- 3 files changed, 84 insertions(+), 63 deletions(-) diff --git a/cluster/ubuntu/build.sh b/cluster/ubuntu/build.sh index c7a22a5d0d3..b6081796212 100755 --- a/cluster/ubuntu/build.sh +++ b/cluster/ubuntu/build.sh @@ -55,7 +55,7 @@ cp $ETCD/etcd $ETCD/etcdctl binaries/minion # k8s echo "Download kubernetes release ..." -K8S_VERSION=${K8S_VERSION:-"1.0.1"} +K8S_VERSION=${K8S_VERSION:-"1.0.3"} if [ ! -f kubernetes.tar.gz ] ; then curl -L https://github.com/GoogleCloudPlatform/kubernetes/releases/download/v${K8S_VERSION}/kubernetes.tar.gz -o kubernetes.tar.gz diff --git a/docs/getting-started-guides/docker-multinode/master.md b/docs/getting-started-guides/docker-multinode/master.md index ea219ed9185..3f760c51ca8 100644 --- a/docs/getting-started-guides/docker-multinode/master.md +++ b/docs/getting-started-guides/docker-multinode/master.md @@ -175,7 +175,7 @@ sudo docker run -d --net=host --privileged gcr.io/google_containers/hyperkube:v1 At this point, you should have a functioning 1-node cluster. Let's test it out! -Download the kubectl binary +Download the kubectl binary and make it available by editing your PATH ENV. ([OS X](http://storage.googleapis.com/kubernetes-release/release/v1.0.1/bin/darwin/amd64/kubectl)) ([linux](http://storage.googleapis.com/kubernetes-release/release/v1.0.1/bin/linux/amd64/kubectl)) diff --git a/docs/getting-started-guides/ubuntu.md b/docs/getting-started-guides/ubuntu.md index 7c77ffb589f..0ed0cc7719c 100644 --- a/docs/getting-started-guides/ubuntu.md +++ b/docs/getting-started-guides/ubuntu.md @@ -35,53 +35,66 @@ Kubernetes Deployment On Bare-metal Ubuntu Nodes - [Introduction](#introduction) - [Prerequisites](#prerequisites) - - [Starting a Cluster](#starting-a-cluster) - - [Make *kubernetes* , *etcd* and *flanneld* binaries](#make-kubernetes--etcd-and-flanneld-binaries) - - [Configure and start the Kubernetes cluster](#configure-and-start-the-kubernetes-cluster) - - [Deploy addons](#deploy-addons) - - [Trouble Shooting](#trouble-shooting) +- [Starting a Cluster](#starting-a-cluster) + - [Download binaries](#download-binaries) + - [Configure and start the kubernetes cluster](#configure-and-start-the-kubernetes-cluster) + - [Test it out](#test-it-out) + - [Deploy addons](#deploy-addons) + - [Trouble shooting](#trouble-shooting) ## Introduction -This document describes how to deploy Kubernetes on ubuntu nodes, including 1 Kubernetes master and 3 Kubernetes nodes, and people uses this approach can scale to **any number of nodes** by changing some settings with ease. The original idea was heavily inspired by @jainvipin 's ubuntu single node work, which has been merge into this document. +This document describes how to deploy kubernetes on ubuntu nodes, 1 master and 3 nodes involved +in the given examples. You can scale to **any number of nodes** by changing some settings with ease. +The original idea was heavily inspired by @jainvipin 's ubuntu single node +work, which has been merge into this document. [Cloud team from Zhejiang University](https://github.com/ZJU-SEL) will maintain this work. ## Prerequisites -*1 The nodes have installed docker version 1.2+ and bridge-utils to manipulate linux bridge* - -*2 All machines can communicate with each other, no need to connect Internet (should use private docker registry in this case)* - -*3 These guide is tested OK on Ubuntu 14.04 LTS 64bit server, but it can not work with Ubuntu 15 which use systemd instead of upstart and we are fixing this* - -*4 Dependencies of this guide: etcd-2.0.12, flannel-0.4.0, k8s-1.0.1, but it may work with higher versions* - -*5 All the remote servers can be ssh logged in without a password by using key authentication* +1. The nodes have installed docker version 1.2+ and bridge-utils to manipulate linux bridge. +2. All machines can communicate with each other, no need to connect Internet (should use +private docker registry in this case). +3. These guide is tested OK on Ubuntu 14.04 LTS 64bit server, but it can not work with +Ubuntu 15 which use systemd instead of upstart. We are working around fixing this. +4. Dependencies of this guide: etcd-2.0.12, flannel-0.4.0, k8s-1.0.3, may work with higher versions. +5. All the remote servers can be ssh logged in without a password by using key authentication. ### Starting a Cluster -#### Make *kubernetes* , *etcd* and *flanneld* binaries +#### Download binaries -First clone the kubernetes github repo, `$ git clone https://github.com/GoogleCloudPlatform/kubernetes.git` +First clone the kubernetes github repo -then `$ cd kubernetes/cluster/ubuntu`. +``` console +$ git clone https://github.com/GoogleCloudPlatform/kubernetes.git +``` -Then run `$ ./build.sh`, this will download all the needed binaries into `./binaries`. +Then download all the needed binaries into given directory (cluster/ubuntu/binaries) -You can customize your etcd version, flannel version, k8s version by changing variable `ETCD_VERSION` , `FLANNEL_VERSION` and `K8S_VERSION` in build.sh, default etcd version is 2.0.12, flannel version is 0.4.0 and K8s version is 1.0.1. +``` console +$ cd kubernetes/cluster/ubuntu +$ ./build.sh +``` -Please make sure that there are `kube-apiserver`, `kube-controller-manager`, `kube-scheduler`, `kubelet`, `kube-proxy`, `etcd`, `etcdctl` and `flannel` in the binaries/master or binaries/minion directory. +You can customize your etcd version, flannel version, k8s version by changing corresponding variables +`ETCD_VERSION` , `FLANNEL_VERSION` and `K8S_VERSION` in build.sh, by default etcd version is 2.0.12, +flannel version is 0.4.0 and k8s version is 1.0.3. -> We used flannel here because we want to use overlay network, but please remember it is not the only choice, and it is also not a k8s' necessary dependence. Actually you can just build up k8s cluster natively, or use flannel, Open vSwitch or any other SDN tool you like, we just choose flannel here as an example. +Make sure that the involved binaries are located properly in the binaries/master +or binaries/minion directory before you go ahead to the next step . + +Note that we use flannel here to set up overlay network, yet it's optional. Actually you can build up k8s +cluster natively, or use flannel, Open vSwitch or any other SDN tool you like. #### Configure and start the Kubernetes cluster -An example cluster is listed as below: +An example cluster is listed below: -| IP Address|Role | -|---------|------| +| IP Address | Role | +|-------------|----------| |10.10.103.223| node | |10.10.103.162| node | |10.10.103.250| both master and node| @@ -100,13 +113,18 @@ export SERVICE_CLUSTER_IP_RANGE=192.168.3.0/24 export FLANNEL_NET=172.16.0.0/16 ``` -The first variable `nodes` defines all your cluster nodes, MASTER node comes first and separated with blank space like ` ` +The first variable `nodes` defines all your cluster nodes, MASTER node comes first and +separated with blank space like ` ` -Then the `role` variable defines the role of above machine in the same order, "ai" stands for machine acts as both master and node, "a" stands for master, "i" stands for node. So they are just defined the k8s cluster as the table above described. +Then the `role` variable defines the role of above machine in the same order, "ai" stands for machine +acts as both master and node, "a" stands for master, "i" stands for node. The `NUM_MINIONS` variable defines the total number of nodes. -The `SERVICE_CLUSTER_IP_RANGE` variable defines the Kubernetes service IP range. Please make sure that you do have a valid private ip range defined here, because some IaaS provider may reserve private ips. You can use below three private network range according to rfc1918. Besides you'd better not choose the one that conflicts with your own private network range. +The `SERVICE_CLUSTER_IP_RANGE` variable defines the kubernetes service IP range. Please make sure +that you do have a valid private ip range defined here, because some IaaS provider may reserve private ips. +You can use below three private network range according to rfc1918. Besides you'd better not choose the one +that conflicts with your own private network range. 10.0.0.0 - 10.255.255.255 (10/8 prefix) @@ -114,38 +132,41 @@ The `SERVICE_CLUSTER_IP_RANGE` variable defines the Kubernetes service IP range. 192.168.0.0 - 192.168.255.255 (192.168/16 prefix) -The `FLANNEL_NET` variable defines the IP range used for flannel overlay network, should not conflict with above `SERVICE_CLUSTER_IP_RANGE`. +The `FLANNEL_NET` variable defines the IP range used for flannel overlay network, +should not conflict with above `SERVICE_CLUSTER_IP_RANGE`. After all the above variables being set correctly, we can use following command in cluster/ directory to bring up the whole cluster. `$ KUBERNETES_PROVIDER=ubuntu ./kube-up.sh` -The scripts automatically scp binaries and config files to all the machines and start the k8s service on them. The only thing you need to do is to type the sudo password when promoted. The current machine name is shown below, so you will not type in the wrong password. +The scripts automatically scp binaries and config files to all the machines and start the k8s service on them. +The only thing you need to do is to type the sudo password when promoted. ```console Deploying minion on machine 10.10.103.223 - ... - [sudo] password to copy files and start minion: ``` -If all things goes right, you will see the below message from console -`Cluster validation succeeded` indicating the k8s is up. - -**All done !** - -You can also use `kubectl` command to see if the newly created k8s is working correctly. The `kubectl` binary is under the `cluster/ubuntu/binaries` directory. You can move it into your PATH. Then you can use the below command smoothly. - -For example, use `$ kubectl get nodes` to see if all your nodes are in ready status. It may take some time for the nodes ready to use like below. +If all things goes right, you will see the below message from console indicating the k8s is up. ```console +Cluster validation succeeded +``` + +#### Test it out + +You can use `kubectl` command to check if the newly created k8s is working correctly. +The `kubectl` binary is under the `cluster/ubuntu/binaries` directory. +You can make it available via PATH, then you can use the below command smoothly. + +For example, use `$ kubectl get nodes` to see if all of your nodes are ready. + +```console +$ kubectl get nodes NAME LABELS STATUS - 10.10.103.162 kubernetes.io/hostname=10.10.103.162 Ready - 10.10.103.223 kubernetes.io/hostname=10.10.103.223 Ready - 10.10.103.250 kubernetes.io/hostname=10.10.103.250 Ready ``` @@ -154,7 +175,8 @@ Also you can run Kubernetes [guest-example](../../examples/guestbook/) to build #### Deploy addons -After the previous parts, you will have a working k8s cluster, this part will teach you how to deploy addons like DNS and UI onto the existing cluster. +Assuming you have a starting cluster now, this section will tell you how to deploy addons like DNS +and UI onto the existing cluster. The configuration of DNS is configured in cluster/ubuntu/config-default.sh. @@ -169,60 +191,59 @@ DNS_REPLICAS=1 ``` The `DNS_SERVER_IP` is defining the ip of dns server which must be in the `SERVICE_CLUSTER_IP_RANGE`. - The `DNS_REPLICAS` describes how many dns pod running in the cluster. -Further, if you want to deploy UI addon, you should also modify the configuration file as follows: +By default, we also take care of kube-ui addon. ```sh ENABLE_CLUSTER_UI="${KUBE_ENABLE_CLUSTER_UI:-true}" ``` -After all the above variable have been set, just type the below command. +After all the above variables have been set, just type the following command. ```console $ cd cluster/ubuntu - $ KUBERNETES_PROVIDER=ubuntu ./deployAddons.sh ``` -After some time, you can use `$ kubectl get pods --namespace=kube-system` to see the DNS and UI pods are running in the cluster. Done! +After some time, you can use `$ kubectl get pods --namespace=kube-system` to see the DNS and UI pods are running in the cluster. #### On going We are working on these features which we'd like to let everybody know: -1. Run Kubernetes binaries in Docker using [kube-in-docker](https://github.com/ZJU-SEL/kube-in-docker/tree/baremetal-kube), to eliminate OS-distro differences. - +1. Run kubernetes binaries in Docker using [kube-in-docker](https://github.com/ZJU-SEL/kube-in-docker/tree/baremetal-kube), +to eliminate OS-distro differences. 2. Tearing Down scripts: clear and re-create the whole stack by one click. -#### Trouble Shooting +#### Trouble shooting -Generally, what this approach did is quite simple: +Generally, what this approach does is quite simple: 1. Download and copy binaries and configuration files to proper directories on every node - 2. Configure `etcd` using IPs based on input from user - 3. Create and start flannel network -So, if you see a problem, **check etcd configuration first** +So if you encounter a problem, **check etcd configuration first** Please try: 1. Check `/var/log/upstart/etcd.log` for suspicious etcd log - 2. Check `/etc/default/etcd`, as we do not have much input validation, a right config should be like: ```sh ETCD_OPTS="-name infra1 -initial-advertise-peer-urls -listen-peer-urls -initial-cluster-token etcd-cluster-1 -initial-cluster infra1=,infra2=,infra3= -initial-cluster-state new" ``` -3. You can use below command - `$ KUBERNETES_PROVIDER=ubuntu ./kube-down.sh` to bring down the cluster and run - `$ KUBERNETES_PROVIDER=ubuntu ./kube-up.sh` again to start again. +3. You may find following commands useful, the former one to bring down the cluster, while +the latter one could start it again. -4. You can also customize your own settings in `/etc/default/{component_name}` after configured success. + ```console + $ KUBERNETES_PROVIDER=ubuntu ./kube-down.sh + $ KUBERNETES_PROVIDER=ubuntu ./kube-up.sh + ``` + +4. You can also customize your own settings in `/etc/default/{component_name}`.