Syntax highlighting
This commit is contained in:
@@ -22,11 +22,11 @@ Docker containers themselves. To achieve this, we need a separate "bootstrap" i
|
||||
|
||||
Run:
|
||||
|
||||
{% highlight sh %}
|
||||
```shell
|
||||
|
||||
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 &'
|
||||
|
||||
{% 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
|
||||
@@ -37,19 +37,19 @@ across reboots and failures.
|
||||
|
||||
Run:
|
||||
|
||||
{% highlight sh %}
|
||||
```shell
|
||||
|
||||
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
|
||||
|
||||
{% 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 %}
|
||||
```shell
|
||||
|
||||
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" }'
|
||||
|
||||
{% endhighlight %}
|
||||
```
|
||||
|
||||
|
||||
### Set up Flannel on the master node
|
||||
@@ -64,19 +64,19 @@ To re-configure Docker to use flannel, we need to take docker down, run flannel
|
||||
|
||||
Turning down Docker is system dependent, it may be:
|
||||
|
||||
{% highlight sh %}
|
||||
```shell
|
||||
|
||||
sudo /etc/init.d/docker stop
|
||||
|
||||
{% endhighlight %}
|
||||
```
|
||||
|
||||
or
|
||||
|
||||
{% highlight sh %}
|
||||
```shell
|
||||
|
||||
sudo systemctl stop docker
|
||||
|
||||
{% endhighlight %}
|
||||
```
|
||||
|
||||
or it may be something else.
|
||||
|
||||
@@ -84,21 +84,21 @@ or it may be something else.
|
||||
|
||||
Now run flanneld itself:
|
||||
|
||||
{% highlight sh %}
|
||||
```shell
|
||||
|
||||
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
|
||||
|
||||
{% endhighlight %}
|
||||
```
|
||||
|
||||
The previous command should have printed a really long hash, copy this hash.
|
||||
|
||||
Now get the subnet settings from flannel:
|
||||
|
||||
{% highlight sh %}
|
||||
```shell
|
||||
|
||||
sudo docker -H unix:///var/run/docker-bootstrap.sock exec <really-long-hash-from-above-here> cat /run/flannel/subnet.env
|
||||
|
||||
{% endhighlight %}
|
||||
```
|
||||
|
||||
#### Edit the docker configuration
|
||||
|
||||
@@ -108,22 +108,22 @@ This may be in `/etc/default/docker` or `/etc/systemd/service/docker.service` or
|
||||
|
||||
Regardless, you need to add the following to the docker command line:
|
||||
|
||||
{% highlight sh %}
|
||||
```shell
|
||||
|
||||
--bip=${FLANNEL_SUBNET} --mtu=${FLANNEL_MTU}
|
||||
|
||||
{% endhighlight %}
|
||||
```
|
||||
|
||||
#### Remove the existing Docker bridge
|
||||
|
||||
Docker creates a bridge named `docker0` by default. You need to remove this:
|
||||
|
||||
{% highlight sh %}
|
||||
```shell
|
||||
|
||||
sudo /sbin/ifconfig docker0 down
|
||||
sudo brctl delbr docker0
|
||||
|
||||
{% endhighlight %}
|
||||
```
|
||||
|
||||
You may need to install the `bridge-utils` package for the `brctl` binary.
|
||||
|
||||
@@ -131,25 +131,25 @@ You may need to install the `bridge-utils` package for the `brctl` binary.
|
||||
|
||||
Again this is system dependent, it may be:
|
||||
|
||||
{% highlight sh %}
|
||||
```shell
|
||||
|
||||
sudo /etc/init.d/docker start
|
||||
|
||||
{% endhighlight %}
|
||||
```
|
||||
|
||||
it may be:
|
||||
|
||||
{% highlight sh %}
|
||||
```shell
|
||||
|
||||
systemctl start docker
|
||||
|
||||
{% 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 %}
|
||||
```shell
|
||||
|
||||
sudo docker run \
|
||||
--volume=/:/rootfs:ro \
|
||||
@@ -164,17 +164,17 @@ sudo docker run \
|
||||
-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
|
||||
|
||||
{% 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 %}
|
||||
```shell
|
||||
|
||||
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
|
||||
|
||||
{% endhighlight %}
|
||||
```
|
||||
|
||||
### Test it out
|
||||
|
||||
@@ -186,20 +186,20 @@ Download the kubectl binary and make it available by editing your PATH ENV.
|
||||
|
||||
List the nodes
|
||||
|
||||
{% highlight sh %}
|
||||
```shell
|
||||
|
||||
kubectl get nodes
|
||||
|
||||
{% endhighlight %}
|
||||
```
|
||||
|
||||
This should print:
|
||||
|
||||
{% highlight console %}
|
||||
```shell
|
||||
|
||||
NAME LABELS STATUS
|
||||
127.0.0.1 kubernetes.io/hostname=127.0.0.1 Ready
|
||||
|
||||
{% 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).
|
||||
|
||||
@@ -3,65 +3,65 @@ title: "Testing your Kubernetes cluster."
|
||||
---
|
||||
To validate that your node(s) have been added, run:
|
||||
|
||||
{% highlight sh %}
|
||||
```shell
|
||||
|
||||
kubectl get nodes
|
||||
|
||||
{% endhighlight %}
|
||||
```
|
||||
|
||||
That should show something like:
|
||||
|
||||
{% highlight console %}
|
||||
```shell
|
||||
|
||||
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
|
||||
|
||||
{% 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 %}
|
||||
```shell
|
||||
|
||||
kubectl -s http://localhost:8080 run nginx --image=nginx --port=80
|
||||
|
||||
{% 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 %}
|
||||
```shell
|
||||
|
||||
kubectl expose rc nginx --port=80
|
||||
|
||||
{% 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 %}
|
||||
```shell
|
||||
|
||||
kubectl get svc nginx
|
||||
|
||||
{% endhighlight %}
|
||||
```
|
||||
|
||||
Alternatively, you can obtain only the first IP (CLUSTER_IP) by running:
|
||||
|
||||
{% highlight sh %}
|
||||
```shell
|
||||
|
||||
kubectl get svc nginx --template={{.spec.clusterIP}}
|
||||
|
||||
{% endhighlight %}
|
||||
```
|
||||
|
||||
Hit the webserver with the first IP (CLUSTER_IP):
|
||||
|
||||
{% highlight sh %}
|
||||
```shell
|
||||
|
||||
curl <insert-cluster-ip-here>
|
||||
|
||||
{% endhighlight %}
|
||||
```
|
||||
|
||||
Note that you will need run this curl command on your boot2docker VM if you are running on OS X.
|
||||
|
||||
@@ -69,19 +69,19 @@ Note that you will need run this curl command on your boot2docker VM if you are
|
||||
|
||||
Now try to scale up the nginx you created before:
|
||||
|
||||
{% highlight sh %}
|
||||
```shell
|
||||
|
||||
kubectl scale rc nginx --replicas=3
|
||||
|
||||
{% endhighlight %}
|
||||
```
|
||||
|
||||
And list the pods
|
||||
|
||||
{% highlight sh %}
|
||||
```shell
|
||||
|
||||
kubectl get pods
|
||||
|
||||
{% endhighlight %}
|
||||
```
|
||||
|
||||
You should see pods landing on the newly added machine.
|
||||
|
||||
|
||||
@@ -25,11 +25,11 @@ As previously, we need a second instance of the Docker daemon running to bootstr
|
||||
|
||||
Run:
|
||||
|
||||
{% highlight sh %}
|
||||
```shell
|
||||
|
||||
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 &'
|
||||
|
||||
{% 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
|
||||
@@ -41,19 +41,19 @@ To re-configure Docker to use flannel, we need to take docker down, run flannel
|
||||
|
||||
Turning down Docker is system dependent, it may be:
|
||||
|
||||
{% highlight sh %}
|
||||
```shell
|
||||
|
||||
sudo /etc/init.d/docker stop
|
||||
|
||||
{% endhighlight %}
|
||||
```
|
||||
|
||||
or
|
||||
|
||||
{% highlight sh %}
|
||||
```shell
|
||||
|
||||
sudo systemctl stop docker
|
||||
|
||||
{% endhighlight %}
|
||||
```
|
||||
|
||||
or it may be something else.
|
||||
|
||||
@@ -61,21 +61,21 @@ or it may be something else.
|
||||
|
||||
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 %}
|
||||
```shell
|
||||
|
||||
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
|
||||
|
||||
{% endhighlight %}
|
||||
```
|
||||
|
||||
The previous command should have printed a really long hash, copy this hash.
|
||||
|
||||
Now get the subnet settings from flannel:
|
||||
|
||||
{% highlight sh %}
|
||||
```shell
|
||||
|
||||
sudo docker -H unix:///var/run/docker-bootstrap.sock exec <really-long-hash-from-above-here> cat /run/flannel/subnet.env
|
||||
|
||||
{% endhighlight %}
|
||||
```
|
||||
|
||||
|
||||
#### Edit the docker configuration
|
||||
@@ -86,22 +86,22 @@ This may be in `/etc/default/docker` or `/etc/systemd/service/docker.service` or
|
||||
|
||||
Regardless, you need to add the following to the docker command line:
|
||||
|
||||
{% highlight sh %}
|
||||
```shell
|
||||
|
||||
--bip=${FLANNEL_SUBNET} --mtu=${FLANNEL_MTU}
|
||||
|
||||
{% endhighlight %}
|
||||
```
|
||||
|
||||
#### Remove the existing Docker bridge
|
||||
|
||||
Docker creates a bridge named `docker0` by default. You need to remove this:
|
||||
|
||||
{% highlight sh %}
|
||||
```shell
|
||||
|
||||
sudo /sbin/ifconfig docker0 down
|
||||
sudo brctl delbr docker0
|
||||
|
||||
{% endhighlight %}
|
||||
```
|
||||
|
||||
You may need to install the `bridge-utils` package for the `brctl` binary.
|
||||
|
||||
@@ -109,19 +109,19 @@ You may need to install the `bridge-utils` package for the `brctl` binary.
|
||||
|
||||
Again this is system dependent, it may be:
|
||||
|
||||
{% highlight sh %}
|
||||
```shell
|
||||
|
||||
sudo /etc/init.d/docker start
|
||||
|
||||
{% endhighlight %}
|
||||
```
|
||||
|
||||
it may be:
|
||||
|
||||
{% highlight sh %}
|
||||
```shell
|
||||
|
||||
systemctl start docker
|
||||
|
||||
{% endhighlight %}
|
||||
```
|
||||
|
||||
### Start Kubernetes on the worker node
|
||||
|
||||
@@ -129,7 +129,7 @@ systemctl start docker
|
||||
|
||||
Again this is similar to the above, but the `--api-servers` now points to the master we set up in the beginning.
|
||||
|
||||
{% highlight sh %}
|
||||
```shell
|
||||
|
||||
sudo docker run \
|
||||
--volume=/:/rootfs:ro \
|
||||
@@ -144,17 +144,17 @@ sudo docker run \
|
||||
-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
|
||||
|
||||
{% endhighlight %}
|
||||
```
|
||||
|
||||
#### Run the service proxy
|
||||
|
||||
The service proxy provides load-balancing between groups of containers defined by Kubernetes `Services`
|
||||
|
||||
{% highlight sh %}
|
||||
```shell
|
||||
|
||||
sudo docker run -d --net=host --privileged gcr.io/google_containers/hyperkube:v1.0.1 /hyperkube proxy --master=http://${MASTER_IP}:8080 --v=2
|
||||
|
||||
{% endhighlight %}
|
||||
```
|
||||
|
||||
### Next steps
|
||||
|
||||
|
||||
Reference in New Issue
Block a user