Initial checkin of v1.1 -- does not build
This commit is contained in:
@@ -0,0 +1,75 @@
|
||||
---
|
||||
layout: docwithnav
|
||||
title: "Deploy DNS"
|
||||
---
|
||||
<!-- BEGIN MUNGE: UNVERSIONED_WARNING -->
|
||||
|
||||
|
||||
<!-- END MUNGE: UNVERSIONED_WARNING -->
|
||||
|
||||
## Deploy DNS
|
||||
|
||||
### Get the template file
|
||||
|
||||
First of all, download the template dns rc and svc file from
|
||||
|
||||
[skydns-rc template](skydns-rc.yaml.in)
|
||||
|
||||
[skydns-svc template](skydns-svc.yaml.in)
|
||||
|
||||
### Set env
|
||||
|
||||
Then you need to set `DNS_REPLICAS` , `DNS_DOMAIN` , `DNS_SERVER_IP` , `KUBE_SERVER` ENV.
|
||||
|
||||
```
|
||||
{% raw %}
|
||||
$ export DNS_REPLICAS=1
|
||||
|
||||
$ export DNS_DOMAIN=cluster.local # specify in startup parameter `--cluster-domain` for containerized kubelet
|
||||
|
||||
$ export DNS_SERVER_IP=10.0.0.10 # specify in startup parameter `--cluster-dns` for containerized kubelet
|
||||
|
||||
$ export KUBE_SERVER=10.10.103.250 # your master server ip, you may change it
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
### Replace the corresponding value in the template.
|
||||
|
||||
```
|
||||
{% raw %}
|
||||
$ sed -e "s/{{ pillar\['dns_replicas'\] }}/${DNS_REPLICAS}/g;s/{{ pillar\['dns_domain'\] }}/${DNS_DOMAIN}/g;s/{kube_server_url}/${KUBE_SERVER}/g;" skydns-rc.yaml.in > ./skydns-rc.yaml
|
||||
|
||||
$ sed -e "s/{{ pillar\['dns_server'\] }}/${DNS_SERVER_IP}/g" skydns-svc.yaml.in > ./skydns-svc.yaml
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
### Use `kubectl` to create skydns rc and service
|
||||
|
||||
|
||||
```
|
||||
{% raw %}
|
||||
$ kubectl -s "$KUBE_SERVER:8080" --namespace=kube-system create -f ./skydns-rc.yaml
|
||||
|
||||
$ kubectl -s "$KUBE_SERVER:8080" --namespace=kube-system create -f ./skydns-svc.yaml
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
### Test if DNS works
|
||||
|
||||
Follow [this link](https://releases.k8s.io/release-1.1/cluster/addons/dns#how-do-i-test-if-it-is-working) to check it out.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- BEGIN MUNGE: IS_VERSIONED -->
|
||||
<!-- TAG IS_VERSIONED -->
|
||||
<!-- END MUNGE: IS_VERSIONED -->
|
||||
|
||||
|
||||
<!-- BEGIN MUNGE: GENERATED_ANALYTICS -->
|
||||
[]()
|
||||
<!-- END MUNGE: GENERATED_ANALYTICS -->
|
||||
|
||||
@@ -0,0 +1,231 @@
|
||||
---
|
||||
layout: docwithnav
|
||||
title: "Installing a Kubernetes Master Node via Docker"
|
||||
---
|
||||
<!-- BEGIN MUNGE: UNVERSIONED_WARNING -->
|
||||
|
||||
|
||||
<!-- END MUNGE: UNVERSIONED_WARNING -->
|
||||
|
||||
## Installing a Kubernetes Master Node via Docker
|
||||
|
||||
We'll begin by setting up the master node. For the purposes of illustration, we'll assume that the IP of this machine is `${MASTER_IP}`
|
||||
|
||||
There are two main phases to installing the master:
|
||||
* [Setting up `flanneld` and `etcd`](#setting-up-flanneld-and-etcd)
|
||||
* [Starting the Kubernetes master components](#starting-the-kubernetes-master)
|
||||
|
||||
|
||||
## Setting up flanneld and etcd
|
||||
|
||||
_Note_:
|
||||
There is a [bug](https://github.com/docker/docker/issues/14106) in Docker 1.7.0 that prevents this from working correctly.
|
||||
Please install Docker 1.6.2 or Docker 1.7.1.
|
||||
|
||||
### Setup Docker-Bootstrap
|
||||
|
||||
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
|
||||
Docker containers themselves. To achieve this, we need a separate "bootstrap" instance of the Docker daemon. This daemon will be started with
|
||||
`--iptables=false` so that it can only run containers with `--net=host`. That's sufficient to bootstrap our system.
|
||||
|
||||
Run:
|
||||
|
||||
{% highlight sh %}
|
||||
{% raw %}
|
||||
sudo sh -c 'docker -d -H unix:///var/run/docker-bootstrap.sock -p /var/run/docker-bootstrap.pid --iptables=false --ip-masq=false --bridge=none --graph=/var/lib/docker-bootstrap 2> /var/log/docker-bootstrap.log 1> /dev/null &'
|
||||
{% endraw %}
|
||||
{% endhighlight %}
|
||||
|
||||
_Important Note_:
|
||||
If you are running this on a long running system, rather than experimenting, you should run the bootstrap Docker instance under something like SysV init, upstart or systemd so that it is restarted
|
||||
across reboots and failures.
|
||||
|
||||
|
||||
### Startup etcd for flannel and the API server to use
|
||||
|
||||
Run:
|
||||
|
||||
{% highlight sh %}
|
||||
{% raw %}
|
||||
sudo docker -H unix:///var/run/docker-bootstrap.sock run --net=host -d gcr.io/google_containers/etcd:2.0.12 /usr/local/bin/etcd --addr=127.0.0.1:4001 --bind-addr=0.0.0.0:4001 --data-dir=/var/etcd/data
|
||||
{% endraw %}
|
||||
{% endhighlight %}
|
||||
|
||||
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:
|
||||
|
||||
{% highlight sh %}
|
||||
{% raw %}
|
||||
sudo docker -H unix:///var/run/docker-bootstrap.sock run --net=host gcr.io/google_containers/etcd:2.0.12 etcdctl set /coreos.com/network/config '{ "Network": "10.1.0.0/16" }'
|
||||
{% endraw %}
|
||||
{% endhighlight %}
|
||||
|
||||
|
||||
### Set up Flannel on the master node
|
||||
|
||||
Flannel is a network abstraction layer build by CoreOS, we will use it to provide simplified networking between our Pods of containers.
|
||||
|
||||
Flannel re-configures the bridge that Docker uses for networking. As a result we need to stop Docker, reconfigure its networking, and then restart Docker.
|
||||
|
||||
#### Bring down Docker
|
||||
|
||||
To re-configure Docker to use flannel, we need to take docker down, run flannel and then restart Docker.
|
||||
|
||||
Turning down Docker is system dependent, it may be:
|
||||
|
||||
{% highlight sh %}
|
||||
{% raw %}
|
||||
sudo /etc/init.d/docker stop
|
||||
{% endraw %}
|
||||
{% endhighlight %}
|
||||
|
||||
or
|
||||
|
||||
{% highlight sh %}
|
||||
{% raw %}
|
||||
sudo systemctl stop docker
|
||||
{% endraw %}
|
||||
{% endhighlight %}
|
||||
|
||||
or it may be something else.
|
||||
|
||||
#### Run flannel
|
||||
|
||||
Now run flanneld itself:
|
||||
|
||||
{% highlight sh %}
|
||||
{% raw %}
|
||||
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.0
|
||||
{% endraw %}
|
||||
{% endhighlight %}
|
||||
|
||||
The previous command should have printed a really long hash, copy this hash.
|
||||
|
||||
Now get the subnet settings from flannel:
|
||||
|
||||
{% highlight sh %}
|
||||
{% raw %}
|
||||
sudo docker -H unix:///var/run/docker-bootstrap.sock exec <really-long-hash-from-above-here> cat /run/flannel/subnet.env
|
||||
{% endraw %}
|
||||
{% endhighlight %}
|
||||
|
||||
#### Edit the docker configuration
|
||||
|
||||
You now need to edit the docker configuration to activate new flags. Again, this is system specific.
|
||||
|
||||
This may be in `/etc/default/docker` or `/etc/systemd/service/docker.service` or it may be elsewhere.
|
||||
|
||||
Regardless, you need to add the following to the docker command line:
|
||||
|
||||
{% highlight sh %}
|
||||
{% raw %}
|
||||
--bip=${FLANNEL_SUBNET} --mtu=${FLANNEL_MTU}
|
||||
{% endraw %}
|
||||
{% endhighlight %}
|
||||
|
||||
#### Remove the existing Docker bridge
|
||||
|
||||
Docker creates a bridge named `docker0` by default. You need to remove this:
|
||||
|
||||
{% highlight sh %}
|
||||
{% raw %}
|
||||
sudo /sbin/ifconfig docker0 down
|
||||
sudo brctl delbr docker0
|
||||
{% endraw %}
|
||||
{% endhighlight %}
|
||||
|
||||
You may need to install the `bridge-utils` package for the `brctl` binary.
|
||||
|
||||
#### Restart Docker
|
||||
|
||||
Again this is system dependent, it may be:
|
||||
|
||||
{% highlight sh %}
|
||||
{% raw %}
|
||||
sudo /etc/init.d/docker start
|
||||
{% endraw %}
|
||||
{% endhighlight %}
|
||||
|
||||
it may be:
|
||||
|
||||
{% highlight sh %}
|
||||
{% raw %}
|
||||
systemctl start docker
|
||||
{% endraw %}
|
||||
{% endhighlight %}
|
||||
|
||||
## Starting the Kubernetes Master
|
||||
|
||||
Ok, now that your networking is set up, you can startup Kubernetes, this is the same as the single-node case, we will use the "main" instance of the Docker daemon for the Kubernetes components.
|
||||
|
||||
{% highlight sh %}
|
||||
{% raw %}
|
||||
sudo docker run \
|
||||
--volume=/:/rootfs:ro \
|
||||
--volume=/sys:/sys:ro \
|
||||
--volume=/dev:/dev \
|
||||
--volume=/var/lib/docker/:/var/lib/docker:rw \
|
||||
--volume=/var/lib/kubelet/:/var/lib/kubelet:rw \
|
||||
--volume=/var/run:/var/run:rw \
|
||||
--net=host \
|
||||
--privileged=true \
|
||||
--pid=host \
|
||||
-d \
|
||||
gcr.io/google_containers/hyperkube:v1.0.1 /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
|
||||
{% endraw %}
|
||||
{% endhighlight %}
|
||||
|
||||
> Note that `--cluster-dns` and `--cluster-domain` is used to deploy dns, feel free to discard them if dns is not needed.
|
||||
|
||||
### Also run the service proxy
|
||||
|
||||
{% highlight sh %}
|
||||
{% raw %}
|
||||
sudo docker run -d --net=host --privileged gcr.io/google_containers/hyperkube:v1.0.1 /hyperkube proxy --master=http://127.0.0.1:8080 --v=2
|
||||
{% endraw %}
|
||||
{% endhighlight %}
|
||||
|
||||
### Test it out
|
||||
|
||||
At this point, you should have a functioning 1-node cluster. Let's test it out!
|
||||
|
||||
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))
|
||||
|
||||
List the nodes
|
||||
|
||||
{% highlight sh %}
|
||||
{% raw %}
|
||||
kubectl get nodes
|
||||
{% endraw %}
|
||||
{% endhighlight %}
|
||||
|
||||
This should print:
|
||||
|
||||
{% highlight console %}
|
||||
{% raw %}
|
||||
NAME LABELS STATUS
|
||||
127.0.0.1 kubernetes.io/hostname=127.0.0.1 Ready
|
||||
{% endraw %}
|
||||
{% endhighlight %}
|
||||
|
||||
If the status of the node is `NotReady` or `Unknown` please check that all of the containers you created are successfully running.
|
||||
If all else fails, ask questions on [Slack](../../troubleshooting.html#slack).
|
||||
|
||||
|
||||
### Next steps
|
||||
|
||||
Move on to [adding one or more workers](worker.html) or [deploy a dns](deployDNS.html)
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- BEGIN MUNGE: IS_VERSIONED -->
|
||||
<!-- TAG IS_VERSIONED -->
|
||||
<!-- END MUNGE: IS_VERSIONED -->
|
||||
|
||||
|
||||
<!-- BEGIN MUNGE: GENERATED_ANALYTICS -->
|
||||
[]()
|
||||
<!-- END MUNGE: GENERATED_ANALYTICS -->
|
||||
|
||||
+176
@@ -0,0 +1,176 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Copyright 2015 The Kubernetes Authors All rights reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# A scripts to install k8s worker node.
|
||||
# Author @wizard_cxy @reouser
|
||||
|
||||
set -e
|
||||
|
||||
# Make sure docker daemon is running
|
||||
if ( ! ps -ef | grep "/usr/bin/docker" | grep -v 'grep' &> /dev/null ); then
|
||||
echo "Docker is not running on this machine!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Make sure k8s version env is properly set
|
||||
if [ -z ${K8S_VERSION} ]; then
|
||||
K8S_VERSION="1.0.3"
|
||||
echo "K8S_VERSION is not set, using default: ${K8S_VERSION}"
|
||||
else
|
||||
echo "k8s version is set to: ${K8S_VERSION}"
|
||||
fi
|
||||
|
||||
|
||||
# Run as root
|
||||
if [ "$(id -u)" != "0" ]; then
|
||||
echo >&2 "Please run as root"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check if a command is valid
|
||||
command_exists() {
|
||||
command -v "$@" > /dev/null 2>&1
|
||||
}
|
||||
|
||||
lsb_dist=""
|
||||
|
||||
# Detect the OS distro, we support ubuntu, debian, mint, centos, fedora dist
|
||||
detect_lsb() {
|
||||
case "$(uname -m)" in
|
||||
*64)
|
||||
;;
|
||||
*)
|
||||
echo "Error: We currently only support 64-bit platforms."
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
if command_exists lsb_release; then
|
||||
lsb_dist="$(lsb_release -si)"
|
||||
fi
|
||||
if [ -z ${lsb_dist} ] && [ -r /etc/lsb-release ]; then
|
||||
lsb_dist="$(. /etc/lsb-release && echo "$DISTRIB_ID")"
|
||||
fi
|
||||
if [ -z ${lsb_dist} ] && [ -r /etc/debian_version ]; then
|
||||
lsb_dist='debian'
|
||||
fi
|
||||
if [ -z ${lsb_dist} ] && [ -r /etc/fedora-release ]; then
|
||||
lsb_dist='fedora'
|
||||
fi
|
||||
if [ -z ${lsb_dist} ] && [ -r /etc/os-release ]; then
|
||||
lsb_dist="$(. /etc/os-release && echo "$ID")"
|
||||
fi
|
||||
|
||||
lsb_dist="$(echo ${lsb_dist} | tr '[:upper:]' '[:lower:]')"
|
||||
}
|
||||
|
||||
|
||||
# Start the bootstrap daemon
|
||||
bootstrap_daemon() {
|
||||
sudo -b docker -d -H unix:///var/run/docker-bootstrap.sock -p /var/run/docker-bootstrap.pid --iptables=false --ip-masq=false --bridge=none --graph=/var/lib/docker-bootstrap 2> /var/log/docker-bootstrap.log 1> /dev/null
|
||||
|
||||
sleep 5
|
||||
}
|
||||
|
||||
# Start k8s components in containers
|
||||
DOCKER_CONF=""
|
||||
|
||||
start_k8s(){
|
||||
# Start etcd
|
||||
docker -H unix:///var/run/docker-bootstrap.sock run --restart=always --net=host -d gcr.io/google_containers/etcd:2.0.12 /usr/local/bin/etcd --addr=127.0.0.1:4001 --bind-addr=0.0.0.0:4001 --data-dir=/var/etcd/data
|
||||
|
||||
sleep 5
|
||||
# Set flannel net config
|
||||
docker -H unix:///var/run/docker-bootstrap.sock run --net=host gcr.io/google_containers/etcd:2.0.12 etcdctl set /coreos.com/network/config '{ "Network": "10.1.0.0/16", "Backend": {"Type": "vxlan"}}'
|
||||
|
||||
# iface may change to a private network interface, eth0 is for default
|
||||
flannelCID=$(docker -H unix:///var/run/docker-bootstrap.sock run --restart=always -d --net=host --privileged -v /dev/net:/dev/net quay.io/coreos/flannel:0.5.0 /opt/bin/flanneld -iface="eth0")
|
||||
|
||||
sleep 8
|
||||
|
||||
# Copy flannel env out and source it on the host
|
||||
docker -H unix:///var/run/docker-bootstrap.sock cp ${flannelCID}:/run/flannel/subnet.env .
|
||||
source subnet.env
|
||||
|
||||
# Configure docker net settings, then restart it
|
||||
case "$lsb_dist" in
|
||||
fedora|centos|amzn)
|
||||
DOCKER_CONF="/etc/sysconfig/docker"
|
||||
;;
|
||||
ubuntu|debian|linuxmint)
|
||||
DOCKER_CONF="/etc/default/docker"
|
||||
;;
|
||||
esac
|
||||
|
||||
# Append the docker opts
|
||||
echo "DOCKER_OPTS=\"\$DOCKER_OPTS --mtu=${FLANNEL_MTU} --bip=${FLANNEL_SUBNET}\"" | sudo tee -a ${DOCKER_CONF}
|
||||
|
||||
|
||||
# sleep a little bit
|
||||
ifconfig docker0 down
|
||||
|
||||
case "$lsb_dist" in
|
||||
fedora|centos|amzn)
|
||||
yum install bridge-utils && brctl delbr docker0 && systemctl restart docker
|
||||
;;
|
||||
ubuntu|debian|linuxmint)
|
||||
apt-get install bridge-utils && brctl delbr docker0 && service docker restart
|
||||
;;
|
||||
esac
|
||||
|
||||
# sleep a little bit
|
||||
sleep 5
|
||||
|
||||
# Start kubelet & proxy, then start master components as pods
|
||||
docker run \
|
||||
--net=host \
|
||||
--pid=host \
|
||||
--privileged \
|
||||
--restart=always \
|
||||
-d \
|
||||
-v /sys:/sys:ro \
|
||||
-v /var/run:/var/run:rw \
|
||||
-v /:/rootfs:ro \
|
||||
-v /dev:/dev \
|
||||
-v /var/lib/docker/:/var/lib/docker:ro \
|
||||
-v /var/lib/kubelet/:/var/lib/kubelet:rw \
|
||||
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
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
echo "Detecting your OS distro ..."
|
||||
detect_lsb
|
||||
|
||||
echo "Starting bootstrap docker ..."
|
||||
bootstrap_daemon
|
||||
|
||||
echo "Starting k8s ..."
|
||||
start_k8s
|
||||
|
||||
echo "Master done!"
|
||||
@@ -0,0 +1,92 @@
|
||||
apiVersion: v1
|
||||
kind: ReplicationController
|
||||
metadata:
|
||||
name: kube-dns-v8
|
||||
namespace: kube-system
|
||||
labels:
|
||||
k8s-app: kube-dns
|
||||
version: v8
|
||||
kubernetes.io/cluster-service: "true"
|
||||
spec:
|
||||
replicas: {{ pillar['dns_replicas'] }}
|
||||
selector:
|
||||
k8s-app: kube-dns
|
||||
version: v8
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
k8s-app: kube-dns
|
||||
version: v8
|
||||
kubernetes.io/cluster-service: "true"
|
||||
spec:
|
||||
containers:
|
||||
- name: etcd
|
||||
image: gcr.io/google_containers/etcd:2.0.9
|
||||
resources:
|
||||
limits:
|
||||
cpu: 100m
|
||||
memory: 50Mi
|
||||
command:
|
||||
- /usr/local/bin/etcd
|
||||
- -data-dir
|
||||
- /var/etcd/data
|
||||
- -listen-client-urls
|
||||
- http://127.0.0.1:2379,http://127.0.0.1:4001
|
||||
- -advertise-client-urls
|
||||
- http://127.0.0.1:2379,http://127.0.0.1:4001
|
||||
- -initial-cluster-token
|
||||
- skydns-etcd
|
||||
volumeMounts:
|
||||
- name: etcd-storage
|
||||
mountPath: /var/etcd/data
|
||||
- name: kube2sky
|
||||
image: gcr.io/google_containers/kube2sky:1.11
|
||||
resources:
|
||||
limits:
|
||||
cpu: 100m
|
||||
memory: 50Mi
|
||||
args:
|
||||
# command = "/kube2sky"
|
||||
- -domain={{ pillar['dns_domain'] }}
|
||||
- -kube_master_url=http://{kube_server_url}:8080
|
||||
- name: skydns
|
||||
image: gcr.io/google_containers/skydns:2015-03-11-001
|
||||
resources:
|
||||
limits:
|
||||
cpu: 100m
|
||||
memory: 50Mi
|
||||
args:
|
||||
# command = "/skydns"
|
||||
- -machines=http://localhost:4001
|
||||
- -addr=0.0.0.0:53
|
||||
- -domain={{ pillar['dns_domain'] }}.
|
||||
ports:
|
||||
- containerPort: 53
|
||||
name: dns
|
||||
protocol: UDP
|
||||
- containerPort: 53
|
||||
name: dns-tcp
|
||||
protocol: TCP
|
||||
livenessProbe:
|
||||
httpGet:
|
||||
path: /healthz
|
||||
port: 8080
|
||||
scheme: HTTP
|
||||
initialDelaySeconds: 30
|
||||
timeoutSeconds: 5
|
||||
- name: healthz
|
||||
image: gcr.io/google_containers/exechealthz:1.0
|
||||
resources:
|
||||
limits:
|
||||
cpu: 10m
|
||||
memory: 20Mi
|
||||
args:
|
||||
- -cmd=nslookup kubernetes.default.svc.{{ pillar['dns_domain'] }} localhost >/dev/null
|
||||
- -port=8080
|
||||
ports:
|
||||
- containerPort: 8080
|
||||
protocol: TCP
|
||||
volumes:
|
||||
- name: etcd-storage
|
||||
emptyDir: {}
|
||||
dnsPolicy: Default # Don't use cluster DNS.
|
||||
@@ -0,0 +1,20 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: kube-dns
|
||||
namespace: kube-system
|
||||
labels:
|
||||
k8s-app: kube-dns
|
||||
kubernetes.io/cluster-service: "true"
|
||||
kubernetes.io/name: "KubeDNS"
|
||||
spec:
|
||||
selector:
|
||||
k8s-app: kube-dns
|
||||
clusterIP: {{ pillar['dns_server'] }}
|
||||
ports:
|
||||
- name: dns
|
||||
port: 53
|
||||
protocol: UDP
|
||||
- name: dns-tcp
|
||||
port: 53
|
||||
protocol: TCP
|
||||
@@ -0,0 +1,107 @@
|
||||
---
|
||||
layout: docwithnav
|
||||
title: "Testing your Kubernetes cluster."
|
||||
---
|
||||
<!-- BEGIN MUNGE: UNVERSIONED_WARNING -->
|
||||
|
||||
|
||||
<!-- END MUNGE: UNVERSIONED_WARNING -->
|
||||
|
||||
## Testing your Kubernetes cluster.
|
||||
|
||||
To validate that your node(s) have been added, run:
|
||||
|
||||
{% highlight sh %}
|
||||
{% raw %}
|
||||
kubectl get nodes
|
||||
{% endraw %}
|
||||
{% endhighlight %}
|
||||
|
||||
That should show something like:
|
||||
|
||||
{% highlight console %}
|
||||
{% raw %}
|
||||
NAME LABELS STATUS
|
||||
10.240.99.26 kubernetes.io/hostname=10.240.99.26 Ready
|
||||
127.0.0.1 kubernetes.io/hostname=127.0.0.1 Ready
|
||||
{% endraw %}
|
||||
{% endhighlight %}
|
||||
|
||||
If the status of any node is `Unknown` or `NotReady` your cluster is broken, double check that all containers are running properly, and if all else fails, contact us on [Slack](../../troubleshooting.html#slack).
|
||||
|
||||
### Run an application
|
||||
|
||||
{% highlight sh %}
|
||||
{% raw %}
|
||||
kubectl -s http://localhost:8080 run nginx --image=nginx --port=80
|
||||
{% endraw %}
|
||||
{% endhighlight %}
|
||||
|
||||
now run `docker ps` you should see nginx running. You may need to wait a few minutes for the image to get pulled.
|
||||
|
||||
### Expose it as a service
|
||||
|
||||
{% highlight sh %}
|
||||
{% raw %}
|
||||
kubectl expose rc nginx --port=80
|
||||
{% endraw %}
|
||||
{% endhighlight %}
|
||||
|
||||
Run the following command to obtain the IP of this service we just created. There are two IPs, the first one is internal (CLUSTER_IP), and the second one is the external load-balanced IP.
|
||||
|
||||
{% highlight sh %}
|
||||
{% raw %}
|
||||
kubectl get svc nginx
|
||||
{% endraw %}
|
||||
{% endhighlight %}
|
||||
|
||||
Alternatively, you can obtain only the first IP (CLUSTER_IP) by running:
|
||||
|
||||
{% highlight sh %}
|
||||
{% raw %}
|
||||
kubectl get svc nginx --template={{.spec.clusterIP}}
|
||||
{% endraw %}
|
||||
{% endhighlight %}
|
||||
|
||||
Hit the webserver with the first IP (CLUSTER_IP):
|
||||
|
||||
{% highlight sh %}
|
||||
{% raw %}
|
||||
curl <insert-cluster-ip-here>
|
||||
{% endraw %}
|
||||
{% endhighlight %}
|
||||
|
||||
Note that you will need run this curl command on your boot2docker VM if you are running on OS X.
|
||||
|
||||
### Scaling
|
||||
|
||||
Now try to scale up the nginx you created before:
|
||||
|
||||
{% highlight sh %}
|
||||
{% raw %}
|
||||
kubectl scale rc nginx --replicas=3
|
||||
{% endraw %}
|
||||
{% endhighlight %}
|
||||
|
||||
And list the pods
|
||||
|
||||
{% highlight sh %}
|
||||
{% raw %}
|
||||
kubectl get pods
|
||||
{% endraw %}
|
||||
{% endhighlight %}
|
||||
|
||||
You should see pods landing on the newly added machine.
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- BEGIN MUNGE: IS_VERSIONED -->
|
||||
<!-- TAG IS_VERSIONED -->
|
||||
<!-- END MUNGE: IS_VERSIONED -->
|
||||
|
||||
|
||||
<!-- BEGIN MUNGE: GENERATED_ANALYTICS -->
|
||||
[]()
|
||||
<!-- END MUNGE: GENERATED_ANALYTICS -->
|
||||
|
||||
@@ -0,0 +1,184 @@
|
||||
---
|
||||
layout: docwithnav
|
||||
title: "Adding a Kubernetes worker node via Docker."
|
||||
---
|
||||
<!-- BEGIN MUNGE: UNVERSIONED_WARNING -->
|
||||
|
||||
|
||||
<!-- END MUNGE: UNVERSIONED_WARNING -->
|
||||
|
||||
## Adding a Kubernetes worker node via Docker.
|
||||
|
||||
|
||||
|
||||
These instructions are very similar to the master set-up above, but they are duplicated for clarity.
|
||||
You need to repeat these instructions for each node you want to join the cluster.
|
||||
We will assume that the IP address of this node is `${NODE_IP}` and you have the IP address of the master in `${MASTER_IP}` that you created in the [master instructions](master.html).
|
||||
|
||||
For each worker node, there are three steps:
|
||||
* [Set up `flanneld` on the worker node](#set-up-flanneld-on-the-worker-node)
|
||||
* [Start Kubernetes on the worker node](#start-kubernetes-on-the-worker-node)
|
||||
* [Add the worker to the cluster](#add-the-node-to-the-cluster)
|
||||
|
||||
### Set up Flanneld on the worker node
|
||||
|
||||
As before, the Flannel daemon is going to provide network connectivity.
|
||||
|
||||
_Note_:
|
||||
There is a [bug](https://github.com/docker/docker/issues/14106) in Docker 1.7.0 that prevents this from working correctly.
|
||||
Please install Docker 1.6.2 or wait for Docker 1.7.1.
|
||||
|
||||
|
||||
#### Set up a bootstrap docker
|
||||
|
||||
As previously, we need a second instance of the Docker daemon running to bootstrap the flannel networking.
|
||||
|
||||
Run:
|
||||
|
||||
{% highlight sh %}
|
||||
{% raw %}
|
||||
sudo sh -c 'docker -d -H unix:///var/run/docker-bootstrap.sock -p /var/run/docker-bootstrap.pid --iptables=false --ip-masq=false --bridge=none --graph=/var/lib/docker-bootstrap 2> /var/log/docker-bootstrap.log 1> /dev/null &'
|
||||
{% endraw %}
|
||||
{% endhighlight %}
|
||||
|
||||
_Important Note_:
|
||||
If you are running this on a long running system, rather than experimenting, you should run the bootstrap Docker instance under something like SysV init, upstart or systemd so that it is restarted
|
||||
across reboots and failures.
|
||||
|
||||
#### Bring down Docker
|
||||
|
||||
To re-configure Docker to use flannel, we need to take docker down, run flannel and then restart Docker.
|
||||
|
||||
Turning down Docker is system dependent, it may be:
|
||||
|
||||
{% highlight sh %}
|
||||
{% raw %}
|
||||
sudo /etc/init.d/docker stop
|
||||
{% endraw %}
|
||||
{% endhighlight %}
|
||||
|
||||
or
|
||||
|
||||
{% highlight sh %}
|
||||
{% raw %}
|
||||
sudo systemctl stop docker
|
||||
{% endraw %}
|
||||
{% endhighlight %}
|
||||
|
||||
or it may be something else.
|
||||
|
||||
#### Run flannel
|
||||
|
||||
Now run flanneld itself, this call is slightly different from the above, since we point it at the etcd instance on the master.
|
||||
|
||||
{% highlight sh %}
|
||||
{% raw %}
|
||||
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.0 /opt/bin/flanneld --etcd-endpoints=http://${MASTER_IP}:4001
|
||||
{% endraw %}
|
||||
{% endhighlight %}
|
||||
|
||||
The previous command should have printed a really long hash, copy this hash.
|
||||
|
||||
Now get the subnet settings from flannel:
|
||||
|
||||
{% highlight sh %}
|
||||
{% raw %}
|
||||
sudo docker -H unix:///var/run/docker-bootstrap.sock exec <really-long-hash-from-above-here> cat /run/flannel/subnet.env
|
||||
{% endraw %}
|
||||
{% endhighlight %}
|
||||
|
||||
|
||||
#### Edit the docker configuration
|
||||
|
||||
You now need to edit the docker configuration to activate new flags. Again, this is system specific.
|
||||
|
||||
This may be in `/etc/default/docker` or `/etc/systemd/service/docker.service` or it may be elsewhere.
|
||||
|
||||
Regardless, you need to add the following to the docker command line:
|
||||
|
||||
{% highlight sh %}
|
||||
{% raw %}
|
||||
--bip=${FLANNEL_SUBNET} --mtu=${FLANNEL_MTU}
|
||||
{% endraw %}
|
||||
{% endhighlight %}
|
||||
|
||||
#### Remove the existing Docker bridge
|
||||
|
||||
Docker creates a bridge named `docker0` by default. You need to remove this:
|
||||
|
||||
{% highlight sh %}
|
||||
{% raw %}
|
||||
sudo /sbin/ifconfig docker0 down
|
||||
sudo brctl delbr docker0
|
||||
{% endraw %}
|
||||
{% endhighlight %}
|
||||
|
||||
You may need to install the `bridge-utils` package for the `brctl` binary.
|
||||
|
||||
#### Restart Docker
|
||||
|
||||
Again this is system dependent, it may be:
|
||||
|
||||
{% highlight sh %}
|
||||
{% raw %}
|
||||
sudo /etc/init.d/docker start
|
||||
{% endraw %}
|
||||
{% endhighlight %}
|
||||
|
||||
it may be:
|
||||
|
||||
{% highlight sh %}
|
||||
{% raw %}
|
||||
systemctl start docker
|
||||
{% endraw %}
|
||||
{% endhighlight %}
|
||||
|
||||
### Start Kubernetes on the worker node
|
||||
|
||||
#### Run the kubelet
|
||||
|
||||
Again this is similar to the above, but the `--api-servers` now points to the master we set up in the beginning.
|
||||
|
||||
{% highlight sh %}
|
||||
{% raw %}
|
||||
sudo docker run \
|
||||
--volume=/:/rootfs:ro \
|
||||
--volume=/sys:/sys:ro \
|
||||
--volume=/dev:/dev \
|
||||
--volume=/var/lib/docker/:/var/lib/docker:rw \
|
||||
--volume=/var/lib/kubelet/:/var/lib/kubelet:rw \
|
||||
--volume=/var/run:/var/run:rw \
|
||||
--net=host \
|
||||
--privileged=true \
|
||||
--pid=host \
|
||||
-d \
|
||||
gcr.io/google_containers/hyperkube:v1.0.1 /hyperkube kubelet --api-servers=http://${MASTER_IP}:8080 --v=2 --address=0.0.0.0 --enable-server --hostname-override=$(hostname -i) --cluster-dns=10.0.0.10 --cluster-domain=cluster.local
|
||||
{% endraw %}
|
||||
{% endhighlight %}
|
||||
|
||||
#### Run the service proxy
|
||||
|
||||
The service proxy provides load-balancing between groups of containers defined by Kubernetes `Services`
|
||||
|
||||
{% highlight sh %}
|
||||
{% raw %}
|
||||
sudo docker run -d --net=host --privileged gcr.io/google_containers/hyperkube:v1.0.1 /hyperkube proxy --master=http://${MASTER_IP}:8080 --v=2
|
||||
{% endraw %}
|
||||
{% endhighlight %}
|
||||
|
||||
### Next steps
|
||||
|
||||
Move on to [testing your cluster](testing.html) or [add another node](#adding-a-kubernetes-worker-node-via-docker)
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- BEGIN MUNGE: IS_VERSIONED -->
|
||||
<!-- TAG IS_VERSIONED -->
|
||||
<!-- END MUNGE: IS_VERSIONED -->
|
||||
|
||||
|
||||
<!-- BEGIN MUNGE: GENERATED_ANALYTICS -->
|
||||
[]()
|
||||
<!-- END MUNGE: GENERATED_ANALYTICS -->
|
||||
|
||||
+174
@@ -0,0 +1,174 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Copyright 2015 The Kubernetes Authors All rights reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# A scripts to install k8s worker node.
|
||||
# Author @wizard_cxy @reouser
|
||||
|
||||
set -e
|
||||
|
||||
# Make sure docker daemon is running
|
||||
if ( ! ps -ef | grep "/usr/bin/docker" | grep -v 'grep' &> /dev/null ); then
|
||||
echo "Docker is not running on this machine!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Make sure k8s version env is properly set
|
||||
if [ -z ${K8S_VERSION} ]; then
|
||||
K8S_VERSION="1.0.3"
|
||||
echo "K8S_VERSION is not set, using default: ${K8S_VERSION}"
|
||||
else
|
||||
echo "k8s version is set to: ${K8S_VERSION}"
|
||||
fi
|
||||
|
||||
|
||||
|
||||
# Run as root
|
||||
if [ "$(id -u)" != "0" ]; then
|
||||
echo >&2 "Please run as root"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Make sure master ip is properly set
|
||||
if [ -z ${MASTER_IP} ]; then
|
||||
echo "Please export MASTER_IP in your env"
|
||||
exit 1
|
||||
else
|
||||
echo "k8s master is set to: ${MASTER_IP}"
|
||||
fi
|
||||
|
||||
# Check if a command is valid
|
||||
command_exists() {
|
||||
command -v "$@" > /dev/null 2>&1
|
||||
}
|
||||
|
||||
lsb_dist=""
|
||||
|
||||
# Detect the OS distro, we support ubuntu, debian, mint, centos, fedora dist
|
||||
detect_lsb() {
|
||||
case "$(uname -m)" in
|
||||
*64)
|
||||
;;
|
||||
*)
|
||||
echo "Error: We currently only support 64-bit platforms."
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
if command_exists lsb_release; then
|
||||
lsb_dist="$(lsb_release -si)"
|
||||
fi
|
||||
if [ -z ${lsb_dist} ] && [ -r /etc/lsb-release ]; then
|
||||
lsb_dist="$(. /etc/lsb-release && echo "$DISTRIB_ID")"
|
||||
fi
|
||||
if [ -z ${lsb_dist} ] && [ -r /etc/debian_version ]; then
|
||||
lsb_dist='debian'
|
||||
fi
|
||||
if [ -z ${lsb_dist} ] && [ -r /etc/fedora-release ]; then
|
||||
lsb_dist='fedora'
|
||||
fi
|
||||
if [ -z ${lsb_dist} ] && [ -r /etc/os-release ]; then
|
||||
lsb_dist="$(. /etc/os-release && echo "$ID")"
|
||||
fi
|
||||
|
||||
lsb_dist="$(echo ${lsb_dist} | tr '[:upper:]' '[:lower:]')"
|
||||
}
|
||||
|
||||
|
||||
# Start the bootstrap daemon
|
||||
bootstrap_daemon() {
|
||||
sudo -b docker -d -H unix:///var/run/docker-bootstrap.sock -p /var/run/docker-bootstrap.pid --iptables=false --ip-masq=false --bridge=none --graph=/var/lib/docker-bootstrap 2> /var/log/docker-bootstrap.log 1> /dev/null
|
||||
|
||||
sleep 5
|
||||
}
|
||||
|
||||
DOCKER_CONF=""
|
||||
|
||||
# Start k8s components in containers
|
||||
start_k8s() {
|
||||
# Start flannel
|
||||
flannelCID=$(sudo docker -H unix:///var/run/docker-bootstrap.sock run -d --restart=always --net=host --privileged -v /dev/net:/dev/net quay.io/coreos/flannel:0.5.0 /opt/bin/flanneld --etcd-endpoints=http://${MASTER_IP}:4001 -iface="eth0")
|
||||
|
||||
sleep 8
|
||||
|
||||
# Copy flannel env out and source it on the host
|
||||
sudo docker -H unix:///var/run/docker-bootstrap.sock cp ${flannelCID}:/run/flannel/subnet.env .
|
||||
source subnet.env
|
||||
|
||||
# Configure docker net settings, then restart it
|
||||
case "$lsb_dist" in
|
||||
fedora|centos|amzn)
|
||||
DOCKER_CONF="/etc/sysconfig/docker"
|
||||
;;
|
||||
ubuntu|debian|linuxmint)
|
||||
DOCKER_CONF="/etc/default/docker"
|
||||
;;
|
||||
esac
|
||||
|
||||
echo "DOCKER_OPTS=\"\$DOCKER_OPTS --mtu=${FLANNEL_MTU} --bip=${FLANNEL_SUBNET}\"" | sudo tee -a ${DOCKER_CONF}
|
||||
|
||||
ifconfig docker0 down
|
||||
|
||||
case "$lsb_dist" in
|
||||
fedora|centos)
|
||||
yum install bridge-utils && brctl delbr docker0 && systemctl restart docker
|
||||
;;
|
||||
ubuntu|debian|linuxmint)
|
||||
apt-get install bridge-utils && brctl delbr docker0 && service docker restart
|
||||
;;
|
||||
esac
|
||||
|
||||
# sleep a little bit
|
||||
sleep 5
|
||||
|
||||
# Start kubelet & proxy in container
|
||||
docker run \
|
||||
--net=host \
|
||||
--pid=host \
|
||||
--privileged \
|
||||
--restart=always \
|
||||
-d \
|
||||
-v /sys:/sys:ro \
|
||||
-v /var/run:/var/run:rw \
|
||||
-v /dev:/dev \
|
||||
-v /var/lib/docker/:/var/lib/docker:ro \
|
||||
-v /var/lib/kubelet/:/var/lib/kubelet:rw \
|
||||
gcr.io/google_containers/hyperkube:v${K8S_VERSION} \
|
||||
/hyperkube kubelet --api-servers=http://${MASTER_IP}:8080 \
|
||||
--v=2 --address=0.0.0.0 --enable-server \
|
||||
--hostname-override=$(hostname -i) \
|
||||
--cluster-dns=10.0.0.10 \
|
||||
--cluster-domain=cluster.local
|
||||
|
||||
docker run \
|
||||
-d \
|
||||
--net=host \
|
||||
--privileged \
|
||||
--restart=always \
|
||||
gcr.io/google_containers/hyperkube:v${K8S_VERSION} \
|
||||
/hyperkube proxy --master=http://${MASTER_IP}:8080 \
|
||||
--v=2
|
||||
}
|
||||
|
||||
echo "Detecting your OS distro ..."
|
||||
detect_lsb
|
||||
|
||||
echo "Starting bootstrap docker ..."
|
||||
bootstrap_daemon
|
||||
|
||||
echo "Starting k8s ..."
|
||||
start_k8s
|
||||
|
||||
echo "Worker done!"
|
||||
Reference in New Issue
Block a user