From 739566d5c70f95b0f3a955779b1fbd71f071f077 Mon Sep 17 00:00:00 2001 From: "Dr. Stefan Schimanski" Date: Mon, 6 Jul 2015 14:39:51 +0200 Subject: [PATCH 1/4] Document how to launch kube-dns on k8sm --- docs/getting-started-guides/mesos.md | 92 ++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) diff --git a/docs/getting-started-guides/mesos.md b/docs/getting-started-guides/mesos.md index b6084b03ba2..c3cdc9cc5f1 100644 --- a/docs/getting-started-guides/mesos.md +++ b/docs/getting-started-guides/mesos.md @@ -124,6 +124,8 @@ $ km scheduler \ --etcd-servers=http://${KUBERNETES_MASTER_IP}:4001 \ --mesos-user=root \ --api-servers=${KUBERNETES_MASTER_IP}:8888 \ + --cluster-dns=10.10.10.10 \ + --cluster-domain=cluster.local \ --v=2 >scheduler.log 2>&1 & ``` @@ -191,6 +193,93 @@ Verify that the pod task is running in the Mesos web GUI. Click on the Kubernetes framework. The next screen should show the running Mesos task that started the Kubernetes pod. +## Launching kube-dns + +Kube-dns is an addon for Kubernetes which adds service discovery to the cluster. For a detailed explanation see [DNS in Kubernetes][4]. + +The kube-dns addon runs as a pod inside the cluster. The pod consists of three co-located containers: +- a local etcd instance +- the [skydns][11] DNS server +- the kube2sky process to glue skydns to the state of the Kubernetes cluster. + +The skydns container offers DNS service via port 53 to the cluster. The etcd communication works via local 127.0.0.1 communication + +We assume that kube-dns will use +- the service IP `10.10.10.10` +- and the `cluster.local` domain. + +Note that we have passed these two values already as parameter to the apiserver above. + +A template for an replication controller spinning up the pod with the 3 containers can be found at [cluster/addons/dns/skydns-rc.yaml.in][11] in the repository. The following steps are necessary in order to get a valid replication controller yaml file: + +- replace `{{ pillar['dns_replicas'] }}` with `1` +- replace `{{ pillar['dns_domain'] }}` with `cluster.local.` +- add `--kube_master_url=${KUBERNETES_MASTER}` parameter to the kube2sky container command. + +In addition the service template at [cluster/addons/dns/skydns-svc.yaml.in][12] needs the following replacement: + +- `{{ pillar['dns_server'] }}` with `10.10.10.10`. + +To do this automatically: + +```bash +sed -e "s/{{ pillar\['dns_replicas'\] }}/1/g;s,\(command = \"/kube2sky\"\),\\1\\"$'\n'" - --kube_master_url=${KUBERNETES_MASTER},;s/{{ pillar\['dns_domain'\] }}/cluster.local/g" \ + cluster/addons/dns/skydns-rc.yaml.in > skydns-rc.yaml +sed -e "s/{{ pillar\['dns_server'\] }}/10.10.10.10/g" \ + cluster/addons/dns/skydns-svc.yaml.in > skydns-svc.yaml +``` + +Now the kube-dns pod and service are ready to be launched: + +```bash +kubectl create -f skydns-rc.yaml +kubectl create -f skydns-svc.yaml +``` + +Check with `kubectl get pods` that 3/3 containers of the pods are eventually up and running. + +To check that the new DNS service in the cluster works, we start a busybox pod and use that to do a DNS lookup. First create the `busybox.yaml` pod spec: + +```bash +cat <busybox.yaml +apiVersion: v1 +kind: Pod +metadata: + name: busybox + namespace: default +spec: + containers: + - image: busybox + command: + - sleep + - "3600" + imagePullPolicy: IfNotPresent + name: busybox + restartPolicy: Always +EOF +``` + +Then start the pod: + +```bash +kubectl create -f busybox.yaml +``` + +When the pod is up and running, start a lookup: + +```bash +kubectl exec busybox -- nslookup kubernetes +``` + +If everything works fine, you will get this output: +``` +Server: 10.10.10.10 +Address 1: 10.10.10.10 + +Name: kubernetes +Address 1: 10.10.10.1 +``` + ## What next? Try out some of the standard [Kubernetes examples][9]. @@ -203,11 +292,14 @@ Future work will add instructions to this guide to enable support for Kubernetes [1]: http://mesosphere.com/docs/tutorials/run-hadoop-on-mesos-using-installer [2]: http://mesosphere.com/docs/tutorials/run-spark-on-mesos [3]: http://mesosphere.com/docs/tutorials/run-chronos-on-mesos +[4]: ../../cluster/addons/dns/README.md [5]: http://open.mesosphere.com/getting-started/cloud/google/mesosphere/ [6]: http://mesos.apache.org/ [7]: https://github.com/mesosphere/kubernetes-mesos/blob/master/docs/issues.md [8]: https://github.com/mesosphere/kubernetes-mesos/issues [9]: ../../examples/ [10]: http://open.mesosphere.com/getting-started/cloud/google/mesosphere/#vpn-setup +[11]: ../../cluster/addons/dns/skydns-rc.yaml.in +[12]: ../../cluster/addons/dns/skydns-svc.yaml.in [![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/getting-started-guides/mesos.md?pixel)]() From 34b887f064c24fc4b1dc9fb08fc32a2b4be77a0f Mon Sep 17 00:00:00 2001 From: "Dr. Stefan Schimanski" Date: Mon, 6 Jul 2015 15:00:52 +0200 Subject: [PATCH 2/4] Line wrap sed command --- docs/getting-started-guides/mesos.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/getting-started-guides/mesos.md b/docs/getting-started-guides/mesos.md index c3cdc9cc5f1..6d05912f944 100644 --- a/docs/getting-started-guides/mesos.md +++ b/docs/getting-started-guides/mesos.md @@ -223,7 +223,9 @@ In addition the service template at [cluster/addons/dns/skydns-svc.yaml.in][12] To do this automatically: ```bash -sed -e "s/{{ pillar\['dns_replicas'\] }}/1/g;s,\(command = \"/kube2sky\"\),\\1\\"$'\n'" - --kube_master_url=${KUBERNETES_MASTER},;s/{{ pillar\['dns_domain'\] }}/cluster.local/g" \ +sed -e "s/{{ pillar\['dns_replicas'\] }}/1/g;"\ +"s,\(command = \"/kube2sky\"\),\\1\\"$'\n'" - --kube_master_url=${KUBERNETES_MASTER},;"\ +"s/{{ pillar\['dns_domain'\] }}/cluster.local/g" \ cluster/addons/dns/skydns-rc.yaml.in > skydns-rc.yaml sed -e "s/{{ pillar\['dns_server'\] }}/10.10.10.10/g" \ cluster/addons/dns/skydns-svc.yaml.in > skydns-svc.yaml From 6d652eccd5a760116676640d0ab244b2cf8d09b4 Mon Sep 17 00:00:00 2001 From: "Dr. Stefan Schimanski" Date: Tue, 7 Jul 2015 08:36:19 +0200 Subject: [PATCH 3/4] Update for changed namespace of the kube-dns pods --- docs/getting-started-guides/mesos.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/getting-started-guides/mesos.md b/docs/getting-started-guides/mesos.md index 6d05912f944..038c5e23c45 100644 --- a/docs/getting-started-guides/mesos.md +++ b/docs/getting-started-guides/mesos.md @@ -238,7 +238,7 @@ kubectl create -f skydns-rc.yaml kubectl create -f skydns-svc.yaml ``` -Check with `kubectl get pods` that 3/3 containers of the pods are eventually up and running. +Check with `kubectl get pods --namespace=kube-system` that 3/3 containers of the pods are eventually up and running. Note that the kube-dns pods run in the `kube-system` namespace, not in `default`. To check that the new DNS service in the cluster works, we start a busybox pod and use that to do a DNS lookup. First create the `busybox.yaml` pod spec: From 3cb31a2ad4455ff405dd9f6759c75a98284dc0ee Mon Sep 17 00:00:00 2001 From: "Dr. Stefan Schimanski" Date: Tue, 14 Jul 2015 08:23:12 +0200 Subject: [PATCH 4/4] Address review comments --- docs/getting-started-guides/mesos.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/getting-started-guides/mesos.md b/docs/getting-started-guides/mesos.md index 038c5e23c45..d5aba54bb2d 100644 --- a/docs/getting-started-guides/mesos.md +++ b/docs/getting-started-guides/mesos.md @@ -195,7 +195,7 @@ started the Kubernetes pod. ## Launching kube-dns -Kube-dns is an addon for Kubernetes which adds service discovery to the cluster. For a detailed explanation see [DNS in Kubernetes][4]. +Kube-dns is an addon for Kubernetes which adds DNS-based service discovery to the cluster. For a detailed explanation see [DNS in Kubernetes][4]. The kube-dns addon runs as a pod inside the cluster. The pod consists of three co-located containers: - a local etcd instance @@ -267,7 +267,7 @@ Then start the pod: kubectl create -f busybox.yaml ``` -When the pod is up and running, start a lookup: +When the pod is up and running, start a lookup for the Kubernetes master service, made available on 10.10.10.1 by default: ```bash kubectl exec busybox -- nslookup kubernetes