Update the kubernetes aio guide

The kubernetes aio guide was out of date and not
working.  Kubernetes removed hyperkube from support.

This method is similar to hypercube, but it installs
flannel and dnsmasq.  It is also capable of scaling from
single to multiple nodes using the same repo.

Change-Id: Ife68cfc8e8bb535ccc2a4634522848421a955de6
Partially-implements: blueprint documentation-initialization
This commit is contained in:
Ryan Hallisey 2016-08-28 21:30:48 -04:00
parent 4fb0538fed
commit afbdc0575e
2 changed files with 46 additions and 72 deletions

View File

@ -7,37 +7,34 @@ Kolla Kubernetes All In One Guide
Single-node Kubernetes setup
============================
http://kubernetes.io/docs/getting-started-guides/docker/
DNS services
- dnsmasq
- kube-dns
- healthz
The hyperkube container runs the following services:
- kube-apiserver (The master)
- kubelet (Starts/Stops pods and containers also syncs config)
- kube-scheduler (Resource manager)
- kube-controller-manager (Manages desired state by monitoring the RC)
- kube-proxy (Exposes the services on each node)
- etcd (Distributed key-value store)
Hypercube service
- kubernetes-dashboard
- kube-addon-manager
- controller-manager
- apiserver
- scheduler
- kube-proxy
- kubelet
Execute the following commands to create an all-in-one Kubernetes setup with DNS.
http://kubernetes.io/docs/getting-started-guides/docker-multinode/#setup-the-master-node
::
Kubernetes manipulates firewall rules so we want it to be the only service on
the host doing that or some of the containers will fail. Disable the firewall
on your host::
# Get the IP addr of the local hosts docker0 bridge, (use for Hyperkube DNS)
export DNS_SERVER_IP=`ip addr show dev docker0 | grep inet | awk '{print $2}'| cut -d'/' -f1`
export CLUSTER_DOMAIN="openstack.local"
# CentOS
systemctl stop firewalld
systemctl disable firewalld
# Start Hyperkube
docker run --volume=/:/rootfs:ro --volume=/sys:/sys:rw --volume=/var/lib/docker/:/var/lib/docker:rw --volume=/var/lib/kubelet/:/var/lib/kubelet:rw,shared --volume=/var/run:/var/run:rw --net=host --pid=host --privileged=true --name=kubelet -d gcr.io/google_containers/hyperkube-amd64:v1.3.0 /hyperkube kubelet --resolv-conf="" --containerized --hostname-override="127.0.0.1" --address="0.0.0.0" --api-servers=http://localhost:8080 --config=/etc/kubernetes/manifests --cluster-domain=${CLUSTER_DOMAIN} --allow-privileged=true --v=2 --cluster-dns=${DNS_SERVER_IP}
Execute the following commands to create an all-in-one Kubernetes setup::
# Start Kube2Sky on localhost (must start before skydns)
docker run -d --net=host --restart=always gcr.io/google_containers/kube2sky:1.12 -v=10 -logtostderr=true -domain=${CLUSTER_DOMAIN} -etcd-server="http://127.0.0.1:4001"
# Start SkyDNS on localhost (must start after kube2sky)
docker run -d --net=host --restart=always -e ETCD_MACHINES="http://127.0.0.1:4001" -e SKYDNS_DOMAIN="${CLUSTER_DOMAIN}." -e SKYDNS_ADDR="0.0.0.0:53" -e SKYDNS_NAMESERVERS="8.8.8.8:53,8.8.4.4:53" gcr.io/google_containers/skydns:2015-10-13-8c72f8c
SkyDNS as configured above will any external DNS requests through to the Google
DNS servers, which should work under most circumstances. You may change the
DNS servers 8.8.8.8 and 8.8.4.4 to custom DNS providers if necessary.
git clone https://github.com/kubernetes/kube-deploy
./kube-deploy/docker-multinode/master.sh
Download kubectl::
@ -45,55 +42,15 @@ Download kubectl::
chmod 755 kubectl
PATH=$PATH:`pwd`
Create a Kubernetes cluster configuration::
kubectl config set-cluster kolla --server=http://localhost:8080
kubectl config set-context kolla --cluster=kolla
kubectl config use-context kolla
Try it out::
kubectl get nodes
kubectl get services --all-namespaces
To confirm that DNS services are working, you can start a busybox job which will
check if ``kubernetes`` is resolvable from inside of it. If the job completes,
then DNS is up and running.
Debugging
=========
::
kube2sky
--------
kube2sky queries Kubernetes and builds out the necessary etcd records for
SkyDNS to use.
To check to see if the Kubernetes service has been copied over from Kubernetes
to SkyDNS, you can check the etcd::
curl http://127.0.0.1:4001/v2/keys/skydns/local/openstack/svc/default/kubernetes
You should see something like this::
{"action":"get","node":{"key":"/skydns/local/openstack/svc/default/kubernetes","dir":true,"nodes":[{"key":"/skydns/local/openstack/svc/default/kubernetes/c88f1059","value":"{\"host\":\"10.0.0.1\",\"priority\":10,\"weight\":10,\"ttl\":30,\"targetstrip\":0}","modifiedIndex":137,"createdIndex":137}],"modifiedIndex":92,"createdIndex":92}}
That is the DNS record for the Kubernetes service.
SkyDNS
------
SkyDNS is a DNS server that serves up data stored in etcd.
After you have verified that kube2sky is creating the necessary records in
etcd, you can check to see if the SkyDNS server is responding::
nslookup kubernetes.default.svc.openstack.local 127.0.0.1
You should see something like this::
Server: 127.0.0.1
Address: 127.0.0.1#53
Name: kubernetes.default.svc.openstack.local
Address: 10.0.0.1
From inside a Kubernetes pod, you can use::
nslookup kubernetes
kubectl create -f tools/test-dns.yml
kubectl get jobs

17
tools/test-dns.yml Normal file
View File

@ -0,0 +1,17 @@
apiVersion: batch/v1
kind: Job
metadata:
name: test-dns
spec:
template:
metadata:
name: test-dns
spec:
restartPolicy: OnFailure
containers:
- image: busybox
imagePullPolicy: IfNotPresent
name: busybox
command:
- nslookup
- kubernetes