Skip to content

Commit d246ed0

Browse files
author
k8s-merge-robot
committed
Merge pull request kubernetes#18894 from luxas/update_master_multi
Auto commit by PR queue bot
2 parents c4d46ad + 7d49744 commit d246ed0

File tree

7 files changed

+191
-127
lines changed

7 files changed

+191
-127
lines changed

cluster/get-kube-local.sh

+2
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ function create_cluster {
7575
--api-servers=http://localhost:8080 \
7676
--config=/etc/kubernetes/manifests \
7777
--allow-privileged=true \
78+
--cluster-dns=10.0.0.10 \
79+
--cluster-domain=cluster.local \
7880
--v=2"
7981

8082
echo -e -n "\tWaiting for master components to start..."

cluster/images/hyperkube/Dockerfile

+2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ COPY hyperkube /hyperkube
1919
RUN chmod a+rx /hyperkube
2020

2121
COPY master-multi.json /etc/kubernetes/manifests-multi/master.json
22+
COPY kube-proxy.json /etc/kubernetes/manifests-multi/kube-proxy.json
23+
2224
COPY master.json /etc/kubernetes/manifests/master.json
2325
COPY etcd.json /etc/kubernetes/manifests/etcd.json
2426
COPY kube-proxy.json /etc/kubernetes/manifests/kube-proxy.json

docs/getting-started-guides/docker-multinode.md

+10-10
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,6 @@ _Note_:
3838
These instructions are somewhat significantly more advanced than the [single node](docker.md) instructions. If you are
3939
interested in just starting to explore Kubernetes, we recommend that you start there.
4040

41-
_Note_:
42-
There is a [bug](https://github.com/docker/docker/issues/14106) in Docker 1.7.0 that prevents this from working correctly.
43-
Please install Docker 1.6.2 or Docker 1.7.1.
44-
4541
**Table of Contents**
4642

4743
- [Prerequisites](#prerequisites)
@@ -54,7 +50,7 @@ Please install Docker 1.6.2 or Docker 1.7.1.
5450

5551
## Prerequisites
5652

57-
1. You need a machine with docker of right version installed.
53+
The only thing you need is a machine with **Docker 1.7.1 or higher**
5854

5955
## Overview
6056

@@ -75,10 +71,13 @@ This pattern is necessary because the `flannel` daemon is responsible for settin
7571
all of the Docker containers created by Kubernetes. To achieve this, it must run outside of the _main_ Docker daemon. However,
7672
it is still useful to use containers for deployment and management, so we create a simpler _bootstrap_ daemon to achieve this.
7773

78-
You can specify k8s version on very node before install:
74+
You can specify the version on every node before install:
7975

80-
```
81-
export K8S_VERSION=<your_k8s_version (e.g. 1.0.3)>
76+
```sh
77+
export K8S_VERSION=<your_k8s_version (e.g. 1.1.3)>
78+
export ETCD_VERSION=<your_etcd_version (e.g. 2.2.1)>
79+
export FLANNEL_VERSION=<your_flannel_version (e.g. 0.5.5)>
80+
export FLANNEL_IFACE=<flannel_interface (defaults to eth0)>
8281
```
8382

8483
Otherwise, we'll use latest `hyperkube` image as default k8s version.
@@ -87,7 +86,8 @@ Otherwise, we'll use latest `hyperkube` image as default k8s version.
8786

8887
The first step in the process is to initialize the master node.
8988

90-
Clone the Kubernetes repo, and run [master.sh](docker-multinode/master.sh) on the master machine with root:
89+
The MASTER_IP step here is optional, it defaults to the first value of `hostname -I`.
90+
Clone the Kubernetes repo, and run [master.sh](docker-multinode/master.sh) on the master machine _with root_:
9191

9292
```console
9393
$ export MASTER_IP=<your_master_ip (e.g. 1.2.3.4)>
@@ -103,7 +103,7 @@ See [here](docker-multinode/master.md) for detailed instructions explanation.
103103

104104
Once your master is up and running you can add one or more workers on different machines.
105105

106-
Clone the Kubernetes repo, and run [worker.sh](docker-multinode/worker.sh) on the worker machine with root:
106+
Clone the Kubernetes repo, and run [worker.sh](docker-multinode/worker.sh) on the worker machine _with root_:
107107

108108
```console
109109
$ export MASTER_IP=<your_master_ip (e.g. 1.2.3.4)>

docs/getting-started-guides/docker-multinode/master.md

+46-17
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,17 @@ Documentation for other releases can be found at
3636

3737
We'll begin by setting up the master node. For the purposes of illustration, we'll assume that the IP of this machine
3838
is `${MASTER_IP}`. We'll need to run several versioned Kubernetes components, so we'll assume that the version we want
39-
to run is `${K8S_VERSION}`, which should hold a value such as "1.0.7".
39+
to run is `${K8S_VERSION}`, which should hold a value such as "1.1.3".
40+
41+
Enviroinment variables used:
42+
43+
```sh
44+
export MASTER_IP=<the_master_ip_here>
45+
export K8S_VERSION=<your_k8s_version (e.g. 1.1.3)>
46+
export ETCD_VERSION=<your_etcd_version (e.g. 2.2.1)>
47+
export FLANNEL_VERSION=<your_flannel_version (e.g. 0.5.5)>
48+
export FLANNEL_IFACE=<flannel_interface (defaults to eth0)>
49+
```
4050

4151
There are two main phases to installing the master:
4252
* [Setting up `flanneld` and `etcd`](#setting-up-flanneld-and-etcd)
@@ -46,10 +56,9 @@ There are two main phases to installing the master:
4656
## Setting up flanneld and etcd
4757

4858
_Note_:
49-
There is a [bug](https://github.com/docker/docker/issues/14106) in Docker 1.7.0 that prevents this from working correctly.
50-
Please install Docker 1.6.2 or Docker 1.7.1 or Docker 1.8.3.
59+
This guide expects **Docker 1.7.1 or higher**.
5160

52-
### Setup Docker-Bootstrap
61+
### Setup Docker Bootstrap
5362

5463
We're going to use `flannel` to set up networking between Docker daemons. Flannel itself (and etcd on which it relies) will run inside of
5564
Docker containers themselves. To achieve this, we need a separate "bootstrap" instance of the Docker daemon. This daemon will be started with
@@ -71,13 +80,22 @@ across reboots and failures.
7180
Run:
7281

7382
```sh
74-
sudo docker -H unix:///var/run/docker-bootstrap.sock run --net=host -d gcr.io/google_containers/etcd:2.2.1 /usr/local/bin/etcd --listen-client-urls=http://127.0.0.1:4001,http://${MASTER_IP}:4001 --advertise-client-urls=http://${MASTER_IP}:4001 --data-dir=/var/etcd/data
83+
sudo docker -H unix:///var/run/docker-bootstrap.sock run -d \
84+
--net=host \
85+
gcr.io/google_containers/etcd:${ETCD_VERSION} \
86+
/usr/local/bin/etcd \
87+
--listen-client-urls=http://127.0.0.1:4001,http://${MASTER_IP}:4001 \
88+
--advertise-client-urls=http://${MASTER_IP}:4001 \
89+
--data-dir=/var/etcd/data
7590
```
7691

7792
Next, you need to set a CIDR range for flannel. This CIDR should be chosen to be non-overlapping with any existing network you are using:
7893

7994
```sh
80-
sudo docker -H unix:///var/run/docker-bootstrap.sock run --net=host gcr.io/google_containers/etcd:2.2.1 etcdctl set /coreos.com/network/config '{ "Network": "10.1.0.0/16" }'
95+
sudo docker -H unix:///var/run/docker-bootstrap.sock run \
96+
--net=host \
97+
gcr.io/google_containers/etcd:${ETCD_VERSION} \
98+
etcdctl set /coreos.com/network/config '{ "Network": "10.1.0.0/16" }'
8199
```
82100

83101

@@ -116,10 +134,16 @@ or it may be something else.
116134
Now run flanneld itself:
117135

118136
```sh
119-
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.5 --ip-masq
137+
sudo docker -H unix:///var/run/docker-bootstrap.sock run -d \
138+
--net=host \
139+
--privileged \
140+
-v /dev/net:/dev/net \
141+
quay.io/coreos/flannel:${FLANNEL_VERSION} \
142+
--ip-masq \
143+
--iface=${FLANNEL_IFACE}
120144
```
121145

122-
The previous command should have printed a really long hash, copy this hash.
146+
The previous command should have printed a really long hash, the container id, copy this hash.
123147

124148
Now get the subnet settings from flannel:
125149

@@ -180,24 +204,29 @@ sudo docker run \
180204
--privileged=true \
181205
--pid=host \
182206
-d \
183-
gcr.io/google_containers/hyperkube:v${K8S_VERSION} /hyperkube kubelet --api-servers=http://localhost:8080 --v=2 --address=0.0.0.0 --enable-server --hostname-override=127.0.0.1 --config=/etc/kubernetes/manifests-multi --cluster-dns=10.0.0.10 --cluster-domain=cluster.local
207+
gcr.io/google_containers/hyperkube:v${K8S_VERSION} \
208+
/hyperkube kubelet \
209+
--allow-privileged=true \
210+
--api-servers=http://localhost:8080 \
211+
--v=2 \
212+
--address=0.0.0.0 \
213+
--enable-server \
214+
--hostname-override=127.0.0.1 \
215+
--config=/etc/kubernetes/manifests-multi \
216+
--containerized \
217+
--cluster-dns=10.0.0.10 \
218+
--cluster-domain=cluster.local
184219
```
185220

186221
> Note that `--cluster-dns` and `--cluster-domain` is used to deploy dns, feel free to discard them if dns is not needed.
187222
188-
### Also run the service proxy
189-
190-
```sh
191-
sudo docker run -d --net=host --privileged gcr.io/google_containers/hyperkube:v${K8S_VERSION} /hyperkube proxy --master=http://127.0.0.1:8080 --v=2
192-
```
193-
194223
### Test it out
195224

196225
At this point, you should have a functioning 1-node cluster. Let's test it out!
197226

198227
Download the kubectl binary for `${K8S_VERSION}` (look at the URL in the following links) and make it available by editing your PATH environment variable.
199-
([OS X](http://storage.googleapis.com/kubernetes-release/release/v1.0.7/bin/darwin/amd64/kubectl))
200-
([linux](http://storage.googleapis.com/kubernetes-release/release/v1.0.7/bin/linux/amd64/kubectl))
228+
([OS X](http://storage.googleapis.com/kubernetes-release/release/v1.1.3/bin/darwin/amd64/kubectl))
229+
([linux](http://storage.googleapis.com/kubernetes-release/release/v1.1.3/bin/linux/amd64/kubectl))
201230

202231
For example, OS X:
203232

docs/getting-started-guides/docker-multinode/master.sh

+57-57
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
1616

17-
# A scripts to install k8s worker node.
18-
# Author @wizard_cxy @reouser
17+
# A script to setup the k8s master in docker containers.
18+
# Authors @wizard_cxy @resouer
1919

2020
set -e
2121

@@ -26,12 +26,10 @@ if ( ! ps -ef | grep "/usr/bin/docker" | grep -v 'grep' &> /dev/null ); then
2626
fi
2727

2828
# Make sure k8s version env is properly set
29-
if [ -z ${K8S_VERSION} ]; then
30-
K8S_VERSION="1.0.7"
31-
echo "K8S_VERSION is not set, using default: ${K8S_VERSION}"
32-
else
33-
echo "k8s version is set to: ${K8S_VERSION}"
34-
fi
29+
K8S_VERSION=${K8S_VERSION:-"1.1.3"}
30+
ETCD_VERSION=${ETCD_VERSION:-"2.2.1"}
31+
FLANNEL_VERSION=${FLANNEL_VERSION:-"0.5.5"}
32+
FLANNEL_IFACE=${FLANNEL_IFACE:-"eth0"}
3533

3634
# Run as root
3735
if [ "$(id -u)" != "0" ]; then
@@ -41,12 +39,15 @@ fi
4139

4240
# Make sure master ip is properly set
4341
if [ -z ${MASTER_IP} ]; then
44-
echo "Please export MASTER_IP in your env"
45-
exit 1
46-
else
47-
echo "k8s master is set to: ${MASTER_IP}"
42+
MASTER_IP=$(hostname -I | awk '{print $1}')
4843
fi
4944

45+
echo "K8S_VERSION is set to: ${K8S_VERSION}"
46+
echo "ETCD_VERSION is set to: ${ETCD_VERSION}"
47+
echo "FLANNEL_VERSION is set to: ${FLANNEL_VERSION}"
48+
echo "FLANNEL_IFACE is set to: ${FLANNEL_IFACE}"
49+
echo "MASTER_IP is set to: ${MASTER_IP}"
50+
5051
# Check if a command is valid
5152
command_exists() {
5253
command -v "$@" > /dev/null 2>&1
@@ -95,16 +96,17 @@ detect_lsb() {
9596

9697

9798
# Start the bootstrap daemon
99+
# TODO: do not start docker-bootstrap if it's already running
98100
bootstrap_daemon() {
99-
sudo -b docker -d \
100-
-H unix:///var/run/docker-bootstrap.sock \
101-
-p /var/run/docker-bootstrap.pid \
102-
--iptables=false \
103-
--ip-masq=false \
104-
--bridge=none \
105-
--graph=/var/lib/docker-bootstrap \
106-
2> /var/log/docker-bootstrap.log \
107-
1> /dev/null
101+
docker -d \
102+
-H unix:///var/run/docker-bootstrap.sock \
103+
-p /var/run/docker-bootstrap.pid \
104+
--iptables=false \
105+
--ip-masq=false \
106+
--bridge=none \
107+
--graph=/var/lib/docker-bootstrap \
108+
2> /var/log/docker-bootstrap.log \
109+
1> /dev/null &
108110

109111
sleep 5
110112
}
@@ -115,34 +117,34 @@ DOCKER_CONF=""
115117
start_k8s(){
116118
# Start etcd
117119
docker -H unix:///var/run/docker-bootstrap.sock run \
118-
--restart=always \
119-
--net=host \
120-
-d \
121-
gcr.io/google_containers/etcd:2.2.1 \
122-
/usr/local/bin/etcd \
123-
--listen-client-urls=http://127.0.0.1:4001,http://${MASTER_IP}:4001 \
124-
--advertise-client-urls=http://${MASTER_IP}:4001 \
125-
--data-dir=/var/etcd/data
120+
--restart=always \
121+
--net=host \
122+
-d \
123+
gcr.io/google_containers/etcd:${ETCD_VERSION} \
124+
/usr/local/bin/etcd \
125+
--listen-client-urls=http://127.0.0.1:4001,http://${MASTER_IP}:4001 \
126+
--advertise-client-urls=http://${MASTER_IP}:4001 \
127+
--data-dir=/var/etcd/data
126128

127129
sleep 5
128130
# Set flannel net config
129131
docker -H unix:///var/run/docker-bootstrap.sock run \
130-
--net=host gcr.io/google_containers/etcd:2.2.1 \
131-
etcdctl \
132-
set /coreos.com/network/config \
133-
'{ "Network": "10.1.0.0/16", "Backend": {"Type": "vxlan"}}'
132+
--net=host gcr.io/google_containers/etcd:${ETCD_VERSION} \
133+
etcdctl \
134+
set /coreos.com/network/config \
135+
'{ "Network": "10.1.0.0/16", "Backend": {"Type": "vxlan"}}'
134136

135137
# iface may change to a private network interface, eth0 is for default
136138
flannelCID=$(docker -H unix:///var/run/docker-bootstrap.sock run \
137-
--restart=always \
138-
-d \
139-
--net=host \
140-
--privileged \
141-
-v /dev/net:/dev/net \
142-
quay.io/coreos/flannel:0.5.5 \
143-
/opt/bin/flanneld \
144-
--ip-masq \
145-
-iface="eth0")
139+
--restart=always \
140+
-d \
141+
--net=host \
142+
--privileged \
143+
-v /dev/net:/dev/net \
144+
quay.io/coreos/flannel:${FLANNEL_VERSION} \
145+
/opt/bin/flanneld \
146+
--ip-masq \
147+
--iface="${FLANNEL_IFACE}")
146148

147149
sleep 8
148150

@@ -155,13 +157,13 @@ start_k8s(){
155157
case "${lsb_dist}" in
156158
amzn)
157159
DOCKER_CONF="/etc/sysconfig/docker"
158-
echo "OPTIONS=\"\$OPTIONS --mtu=${FLANNEL_MTU} --bip=${FLANNEL_SUBNET}\"" | sudo tee -a ${DOCKER_CONF}
160+
echo "OPTIONS=\"\$OPTIONS --mtu=${FLANNEL_MTU} --bip=${FLANNEL_SUBNET}\"" | tee -a ${DOCKER_CONF}
159161
ifconfig docker0 down
160162
yum -y -q install bridge-utils && brctl delbr docker0 && service docker restart
161163
;;
162164
centos)
163165
DOCKER_CONF="/etc/sysconfig/docker"
164-
echo "OPTIONS=\"\$OPTIONS --mtu=${FLANNEL_MTU} --bip=${FLANNEL_SUBNET}\"" | sudo tee -a ${DOCKER_CONF}
166+
echo "OPTIONS=\"\$OPTIONS --mtu=${FLANNEL_MTU} --bip=${FLANNEL_SUBNET}\"" | tee -a ${DOCKER_CONF}
165167
if ! command_exists ifconfig; then
166168
yum -y -q install net-tools
167169
fi
@@ -170,7 +172,7 @@ start_k8s(){
170172
;;
171173
ubuntu|debian)
172174
DOCKER_CONF="/etc/default/docker"
173-
echo "DOCKER_OPTS=\"\$DOCKER_OPTS --mtu=${FLANNEL_MTU} --bip=${FLANNEL_SUBNET}\"" | sudo tee -a ${DOCKER_CONF}
175+
echo "DOCKER_OPTS=\"\$DOCKER_OPTS --mtu=${FLANNEL_MTU} --bip=${FLANNEL_SUBNET}\"" | tee -a ${DOCKER_CONF}
174176
ifconfig docker0 down
175177
apt-get install bridge-utils
176178
brctl delbr docker0
@@ -190,7 +192,7 @@ start_k8s(){
190192
# sleep a little bit
191193
sleep 5
192194

193-
# Start kubelet & proxy, then start master components as pods
195+
# Start kubelet and then start master components as pods
194196
docker run \
195197
--net=host \
196198
--pid=host \
@@ -205,18 +207,16 @@ start_k8s(){
205207
-v /var/lib/kubelet/:/var/lib/kubelet:rw \
206208
gcr.io/google_containers/hyperkube:v${K8S_VERSION} \
207209
/hyperkube kubelet \
208-
--v=2 --address=0.0.0.0 --enable-server \
209-
--config=/etc/kubernetes/manifests-multi \
210-
--cluster-dns=10.0.0.10 \
211-
--cluster-domain=cluster.local \
212-
--containerized
210+
--address=0.0.0.0 \
211+
--allow-privileged=true \
212+
--enable-server \
213+
--api-servers=http://localhost:8080 \
214+
--config=/etc/kubernetes/manifests-multi \
215+
--cluster-dns=10.0.0.10 \
216+
--cluster-domain=cluster.local \
217+
--containerized \
218+
--v=2
213219

214-
docker run \
215-
-d \
216-
--net=host \
217-
--privileged \
218-
gcr.io/google_containers/hyperkube:v${K8S_VERSION} \
219-
/hyperkube proxy --master=http://127.0.0.1:8080 --v=2
220220
}
221221

222222
echo "Detecting your OS distro ..."

0 commit comments

Comments
 (0)