mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-06 19:52:42 +00:00
Merge the old single-node and multi-node ubuntu deployment into one better approach and update the guidance
This commit is contained in:
@@ -19,7 +19,6 @@ Bare-metal | custom | Fedora | _none_ | [docs](../../docs/getting
|
||||
Bare-metal | custom | Fedora | flannel | [docs](../../docs/getting-started-guides/fedora/flannel_multi_node_cluster.md) | Community ([@aveshagarwal](https://github.com/aveshagarwal))| Tested with 0.15.0
|
||||
libvirt | custom | Fedora | flannel | [docs](../../docs/getting-started-guides/fedora/flannel_multi_node_cluster.md) | Community ([@aveshagarwal](https://github.com/aveshagarwal))| Tested with 0.15.0
|
||||
KVM | custom | Fedora | flannel | [docs](../../docs/getting-started-guides/fedora/flannel_multi_node_cluster.md) | Community ([@aveshagarwal](https://github.com/aveshagarwal))| Tested with 0.15.0
|
||||
Bare-metal | custom | Ubuntu Cluster | flannel | [docs](../../docs/getting-started-guides/ubuntu_multinodes_cluster.md) | Community (@resouer @WIZARD-CXY) | use k8s version 0.12.0
|
||||
Mesos/GCE | | | | [docs](../../docs/getting-started-guides/mesos.md) | [Community](https://github.com/mesosphere/kubernetes-mesos) ([@jdef](https://github.com/jdef)) | Uses K8s v0.11.2
|
||||
AWS | CoreOS | CoreOS | flannel | [docs](../../docs/getting-started-guides/coreos.md) | Community | Uses K8s version 0.15.0
|
||||
GCE | CoreOS | CoreOS | flannel | [docs](../../docs/getting-started-guides/coreos.md) | Community (@kelseyhightower) | Uses K8s version 0.15.0
|
||||
@@ -34,7 +33,9 @@ Joyent | Juju | Ubuntu | flannel | [docs](../../docs/getting
|
||||
AWS | Saltstack | Ubuntu | OVS | [docs](../../docs/getting-started-guides/aws.md) | Community (@justinsb) | Uses K8s version 0.5.0
|
||||
Vmware | CoreOS | CoreOS | flannel | [docs](../../docs/getting-started-guides/coreos.md) | Community (@kelseyhightower) | Uses K8s version 0.15.0
|
||||
Azure | Saltstack | Ubuntu | OpenVPN | [docs](../../docs/getting-started-guides/azure.md) | Community |
|
||||
Bare-metal | custom | Ubuntu | _none_ | [docs](../../docs/getting-started-guides/ubuntu_single_node.md) | Community (@jainvipin) |
|
||||
Bare-metal | custom | Ubuntu | flannel | [docs](../../docs/getting-started-guides/ubuntu.md) | Community (@resouer @WIZARD-CXY) | use k8s version 0.15.0
|
||||
Docker Single Node | custom | N/A | local | [docs](docker.md) | Project (@brendandburns) | Tested @ 0.14.1 |
|
||||
Docker Multi Node | Flannel| N/A | local | [docs](docker-multinode.md) | Project (@brendandburns) | Tested @ 0.14.1 |
|
||||
Local | | | _none_ | [docs](../../docs/getting-started-guides/locally.md) | Community (@preillyme) |
|
||||
libvirt/KVM | CoreOS | CoreOS | libvirt/KVM | [docs](../../docs/getting-started-guides/libvirt-coreos.md) | Community (@lhuard1A) |
|
||||
oVirt | | | | [docs](../../docs/getting-started-guides/ovirt.md) | Community (@simon3z) |
|
||||
|
172
docs/getting-started-guides/ubuntu.md
Normal file
172
docs/getting-started-guides/ubuntu.md
Normal file
@@ -0,0 +1,172 @@
|
||||
# Kubernetes deployed on ubuntu nodes
|
||||
|
||||
This document describes how to deploy kubernetes on ubuntu nodes, including 1 master node and 3 minion nodes, and people uses this approach can scale to **any number of minion nodes** by changing some settings with ease. Although there exists saltstack based ubuntu k8s installation , it may be tedious and hard for a guy that knows little about saltstack but want to build a really distributed k8s cluster. This new approach of kubernetes deployment is much more easy and automatical than the previous one.
|
||||
|
||||
[Cloud team from ZJU](https://github.com/ZJU-SEL) will keep updating this work.
|
||||
|
||||
### **Prerequisites:**
|
||||
*1 The minion 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 should also work on most Ubuntu versions*
|
||||
|
||||
*4 Dependences of this guide: etcd-2.0.0, flannel-0.4.0, k8s-0.15.0, but it may work with higher versions*
|
||||
|
||||
*5 All the remote servers can be ssh logged in without a password by using key authentication*
|
||||
|
||||
|
||||
### **Main Steps**
|
||||
#### I. Make *kubernetes* , *etcd* and *flanneld* binaries
|
||||
|
||||
First clone the kubernetes github repo, `$ git clone git@github.com:GoogleCloudPlatform/kubernetes.git`
|
||||
then `$ cd kubernetes/cluster/ubuntu`.
|
||||
|
||||
Then run `$ ./build.sh`, this will download all the needed binaries into `./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.0 , flannel version is 0.4.0 and K8s version is 0.15.0.
|
||||
|
||||
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.
|
||||
|
||||
> 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 a example.
|
||||
|
||||
#### II. Configure and start the kubernetes cluster
|
||||
An example cluster is listed as below:
|
||||
|
||||
| IP Address|Role |
|
||||
|---------|------|
|
||||
|10.10.103.223| minion |
|
||||
|10.10.103.162| minion |
|
||||
|10.10.103.250| both master and minion|
|
||||
|
||||
First configure the cluster information in cluster/ubuntu/config-default.sh, below is a simple sample.
|
||||
|
||||
```
|
||||
export nodes="vcap@10.10.103.250 vcap@10.10.103.162 vcap@10.10.103.223"
|
||||
|
||||
export roles=("ai" "i" "i")
|
||||
|
||||
export NUM_MINIONS=${NUM_MINIONS:-3}
|
||||
|
||||
export PORTAL_NET=11.1.1.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 `<user_1@ip_1> <user_2@ip_2> <user_3@ip_3> `
|
||||
|
||||
Then the `roles ` variable defines the role of above machine in the same order, "ai" stands for machine acts as both master and minion, "a" stands for master, "i" stands for minion. So they are just defined the k8s cluster as the table above described.
|
||||
|
||||
The `NUM_MINIONS` variable defines the total number of minions.
|
||||
|
||||
The `PORTAL_NET` variable defines the kubernetes service portal ip range. Please make sure that you do have a private ip range defined here.You can use below three private network range accordin 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)
|
||||
|
||||
172.16.0.0 - 172.31.255.255 (172.16/12 prefix)
|
||||
|
||||
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 PORTAL_NET range
|
||||
|
||||
After all the above variable being set correctly. We can use below command in cluster/ directory to bring up the whole cluster.
|
||||
|
||||
`$ KUBERNETES_PROVIDER=ubuntu ./kube-up.sh`
|
||||
|
||||
The scripts is 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 like. So you will not type in the wrong password.
|
||||
|
||||
```
|
||||
|
||||
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.
|
||||
|
||||
For example, use `$ kubectl get minions` to see if you get all your minion nodes comming up and ready. It may take some times for the minions be ready to use like below.
|
||||
|
||||
```
|
||||
NAME LABELS STATUS
|
||||
|
||||
10.10.103.162 <none> Ready
|
||||
|
||||
10.10.103.223 <none> Ready
|
||||
|
||||
10.10.103.250 <none> Ready
|
||||
|
||||
```
|
||||
|
||||
Also you can run kubernetes [guest-example](https://github.com/GoogleCloudPlatform/kubernetes/tree/master/examples/guestbook) to build a redis backend cluster on the k8s.
|
||||
|
||||
|
||||
#### IV. Deploy addons
|
||||
|
||||
After the previous parts, you will have a working k8s cluster, this part will teach you how to deploy addones like dns onto the existing cluster.
|
||||
|
||||
The configuration of dns is configured in cluster/ubuntu/config-default.sh.
|
||||
|
||||
```
|
||||
|
||||
ENABLE_CLUSTER_DNS=true
|
||||
|
||||
DNS_SERVER_IP="192.168.3.10"
|
||||
|
||||
DNS_DOMAIN="kubernetes.local"
|
||||
|
||||
DNS_REPLICAS=1
|
||||
|
||||
```
|
||||
The `DNS_SERVER_IP` is defining the ip of dns server which must be in the portal_net range.
|
||||
|
||||
The `DNS_REPLICAS` describes how many dns pod running in the cluster.
|
||||
|
||||
After all the above variable have been set. Just type the below command
|
||||
|
||||
```
|
||||
|
||||
$ cd cluster/ubuntu
|
||||
|
||||
$ KUBERNETES_PROVIDER=ubuntu ./deployAddons.sh
|
||||
|
||||
```
|
||||
|
||||
After some time, you can use `$ kubectl get pods` to see the dns pod is running in the cluster. Done!
|
||||
|
||||
|
||||
#### IV. Trouble Shooting
|
||||
|
||||
Generally, what this approach did is quite simple:
|
||||
|
||||
1. Download and copy binaries and configuration files to proper dirctories 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**
|
||||
|
||||
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:
|
||||
```
|
||||
ETCD_OPTS="-name infra1 -initial-advertise-peer-urls <http://ip_of_this_node:2380> -listen-peer-urls <http://ip_of_this_node:2380> -initial-cluster-token etcd-cluster-1 -initial-cluster infra1=<http://ip_of_this_node:2380>,infra2=<http://ip_of_another_node:2380>,infra3=<http://ip_of_another_node:2380> -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.
|
||||
|
||||
4. You can also customize your own settings in `/etc/default/{component_name}` after configured success.
|
@@ -1,170 +0,0 @@
|
||||
# Kubernetes deployed on multiple ubuntu nodes
|
||||
|
||||
This document describes how to deploy kubernetes on multiple ubuntu nodes, including 1 master node and 3 minion nodes, and people uses this approach can scale to **any number of minion nodes** by changing some settings with ease. Although there exists saltstack based ubuntu k8s installation , it may be tedious and hard for a guy that knows little about saltstack but want to build a really distributed k8s cluster. This approach is inspired by [k8s deploy on a single node](http://docs.k8s.io/getting-started-guides/ubuntu_single_node.md).
|
||||
|
||||
[Cloud team from ZJU](https://github.com/ZJU-SEL) will keep updating this work.
|
||||
|
||||
### **Prerequisites:**
|
||||
*1 The minion nodes have installed docker version 1.2+*
|
||||
|
||||
*2 All machines can communicate with each orther, 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 should also work on most Ubuntu versions*
|
||||
|
||||
*4 Dependences of this guide: etcd-2.0.0, flannel-0.2.0, k8s-0.12.0, but it may work with higher versions*
|
||||
|
||||
|
||||
### **Main Steps**
|
||||
#### I. Make *kubernetes* , *etcd* and *flanneld* binaries
|
||||
|
||||
On your laptop, copy `cluster/ubuntu-cluster` directory to your workspace.
|
||||
|
||||
The `build.sh` will download and build all the needed binaries into `./binaries`.
|
||||
|
||||
You can customize your etcd version or K8s version in the build.sh by changing variable `ETCD_V` and `K8S_V` in build.sh, default etcd version is 2.0.0 and K8s version is 0.12.0.
|
||||
|
||||
|
||||
```
|
||||
$ cd cluster/ubuntu-cluster
|
||||
$ sudo ./build.sh
|
||||
```
|
||||
|
||||
Please copy all the files in `./binaries` into `/opt/bin` of every machine you want to run as Kubernetes cluster node.
|
||||
|
||||
|
||||
Alternatively, if your Kubernetes nodes have access to Internet, you can copy `cluster/ubuntu-cluster` directory to every node and run:
|
||||
```
|
||||
# in every node
|
||||
$ cd cluster/ubuntu-cluster
|
||||
$ sudo ./build.sh
|
||||
$ sudo cp ./binaries/* /opt/bin
|
||||
```
|
||||
|
||||
|
||||
> 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 a example.
|
||||
|
||||
#### II. Configue and install every components upstart script
|
||||
An example cluster is listed as below:
|
||||
|
||||
| IP Address|Role |
|
||||
|---------|------|
|
||||
|10.10.103.223| minion|
|
||||
|10.10.103.224| minion|
|
||||
|10.10.103.162| minion|
|
||||
|10.10.103.250| master|
|
||||
|
||||
First of all, make sure `cluster/ubuntu-cluster` exists on this node,and run `configue.sh`.
|
||||
|
||||
On master( infra1 10.10.103.250 ) node:
|
||||
|
||||
```
|
||||
# in cluster/ubuntu-cluster
|
||||
$ sudo ./configure.sh
|
||||
Welcome to use this script to configure k8s setup
|
||||
|
||||
Please enter all your cluster node ips, MASTER node comes first
|
||||
And separated with blank space like "<ip_1> <ip2> <ip3>": 10.10.103.250 10.10.103.223 10.10.103.224 10.10.103.162
|
||||
|
||||
This machine acts as
|
||||
both MASTER and MINION: 1
|
||||
only MASTER: 2
|
||||
only MINION: 3
|
||||
Please choose a role > 2
|
||||
|
||||
IP address of this machine > 10.10.103.250
|
||||
|
||||
Configure Success
|
||||
```
|
||||
|
||||
On every minion ( e.g. 10.10.103.224 ) node:
|
||||
|
||||
|
||||
```
|
||||
# in cluster/ubuntu-cluster
|
||||
$ sudo ./configure.sh
|
||||
Welcome to use this script to configure k8s setup
|
||||
|
||||
Please enter all your cluster node ips, MASTER node comes first
|
||||
And separated with blank space like "<ip_1> <ip2> <ip3>": 10.10.103.250 10.10.103.223 10.10.103.224 10.10.103.162
|
||||
|
||||
This machine acts as
|
||||
both MASTER and MINION: 1
|
||||
only MASTER: 2
|
||||
only MINION: 3
|
||||
Please choose a role > 3
|
||||
|
||||
IP address of this machine > 10.10.103.224
|
||||
|
||||
Configure Success
|
||||
```
|
||||
|
||||
If you want a node acts as **both running the master and minion**, please choose option 1.
|
||||
|
||||
#### III. Start all components
|
||||
1. On the master node:
|
||||
|
||||
`$ sudo service etcd start`
|
||||
|
||||
Then on every minion node:
|
||||
|
||||
`$ sudo service etcd start`
|
||||
|
||||
> The kubernetes commands will be started automatically after etcd
|
||||
|
||||
2. On any node:
|
||||
|
||||
`$ /opt/bin/etcdctl mk /coreos.com/network/config '{"Network":"10.0.0.0/16"}'`
|
||||
|
||||
Note the `10.0.0.0/16` is a virtual network address. It has nothing to do with master and minions IP addresses assigned by the cloud provider. In other words even if your master and minions use address from another network (e.g. 172.16.0x) you can still use `10.0.0.0/16` for your virtual network.
|
||||
|
||||
> You can use the below command on another node to confirm if the network setting is correct.
|
||||
|
||||
> `$ /opt/bin/etcdctl get /coreos.com/network/config`
|
||||
|
||||
> If you got `{"Network":"10.0.0.0/16"}`, then etcd cluster is working well.
|
||||
> If not , please check` /var/log/upstart/etcd.log` to resolve etcd problem before going forward.
|
||||
> Finally, use `ifconfig` to see if there is a new network interface named `flannel0` coming up.
|
||||
|
||||
|
||||
3. On every minion node
|
||||
|
||||
Make sure you have `brctl` installed on every minion, otherwise please run `sudo apt-get install bridge-utils`
|
||||
|
||||
`$ sudo ./reconfigureDocker.sh`
|
||||
|
||||
This will make the docker daemon aware of flannel network.
|
||||
|
||||
|
||||
**All done !**
|
||||
|
||||
#### IV. Validation
|
||||
You can use kubectl command to see if the newly created k8s is working correctly.
|
||||
|
||||
For example , `$ kubectl get minions` to see if you get all your minion nodes comming up.
|
||||
|
||||
Also you can run kubernetes [guest-example](https://github.com/GoogleCloudPlatform/kubernetes/tree/master/examples/guestbook) to build a redis backend cluster on the k8s.
|
||||
|
||||
#### V. Trouble Shooting
|
||||
|
||||
Generally, what of this guide did is quite simple:
|
||||
|
||||
1. Build and copy binaries and configuration files to proper dirctories on every node
|
||||
|
||||
2. Configure `etcd` using IPs based on input from user
|
||||
|
||||
3. Create and start flannel network
|
||||
|
||||
So, whenver you have problem, do not blame Kubernetes, **check etcd configuration first**
|
||||
|
||||
Please try:
|
||||
|
||||
1. Check `/var/log/upstart/etcd.log` for suspicisous etcd log
|
||||
|
||||
2. Check `/etc/default/etcd`, as we do not have much input validation, a right config should be like:
|
||||
```
|
||||
ETCD_OPTS="-name infra1 -initial-advertise-peer-urls <http://ip_of_this_node:2380> -listen-peer-urls <http://ip_of_this_node:2380> -initial-cluster-token etcd-cluster-1 -initial-cluster infra1=<http://ip_of_this_node:2380>,infra2=<http://ip_of_another_node:2380>,infra3=<http://ip_of_another_node:2380> -initial-cluster-state new"
|
||||
```
|
||||
|
||||
3. Remove `data-dir` of etcd and run `reconfigureDocker.sh`again, the default path of `data-dir` is /infra*.etcd/
|
||||
|
||||
4. You can also customize your own settings in `/etc/default/{component_name}` after configured success.
|
@@ -1,50 +0,0 @@
|
||||
## Getting started on Ubuntu
|
||||
|
||||
This document describes how to get started to run kubernetes services on a single host (which is acting both as master and minion) for ubuntu systems. It consists of three steps
|
||||
|
||||
1. Make kubernetes and etcd binaries
|
||||
2. Install upstart scripts
|
||||
3. Customizing ubuntu launch
|
||||
|
||||
### 1. Make kubernetes and etcd binaries
|
||||
Either build or download the latest [kubernetes binaries] (http://docs.k8s.io/getting-started-guides/binary_release.md)
|
||||
|
||||
Copy the kube binaries into `/opt/bin` or a path of your choice
|
||||
|
||||
Similarly pull an `etcd` binary from [etcd releases](https://github.com/coreos/etcd/releases) or build the `etcd` yourself using instructions at [https://github.com/coreos/etcd](https://github.com/coreos/etcd)
|
||||
|
||||
Copy the `etcd` binary into `/opt/bin` or path of your choice
|
||||
|
||||
### 2. Install upstart scripts
|
||||
Running ubuntu/util.sh would install/copy the scripts for upstart to pick up. The script may warn you on some valid problems/conditions
|
||||
|
||||
```
|
||||
$ cd kubernetes/cluster/ubuntu
|
||||
$ sudo ./util.sh
|
||||
```
|
||||
|
||||
After this the kubernetes and `etcd` services would be up and running. You can use `service start/stop/restart/force-reload` on the services.
|
||||
|
||||
Launching and scheduling containers using kubectl can also be used at this point, as explained mentioned in the [examples](https://github.com/GoogleCloudPlatform/kubernetes/tree/master/examples/guestbook)
|
||||
|
||||
### 3. Customizing the ubuntu launch
|
||||
To customize the defaults you will need to tweak `/etc/default/kube*` files and restart the appropriate services. This is needed if the binaries are copied in a place other than `/opt/bin`. A run could look like
|
||||
|
||||
```
|
||||
$ sudo cat /etc/default/etcd
|
||||
# Etcd Upstart and SysVinit configuration file
|
||||
|
||||
# Customize etcd location
|
||||
# ETCD="/opt/bin/etcd"
|
||||
|
||||
# Use ETCD_OPTS to modify the start/restart options
|
||||
ETCD_OPTS="-listen-client-urls=http://127.0.0.1:4001"
|
||||
|
||||
# Add more environment settings used by etcd here
|
||||
|
||||
$ sudo service etcd status
|
||||
etcd start/running, process 834
|
||||
$ sudo service etcd restart
|
||||
etcd stop/waiting
|
||||
etcd start/running, process 29050
|
||||
```
|
Reference in New Issue
Block a user