From ee9591e25d7ff7a6242dcb65ade87ea85a2cbe79 Mon Sep 17 00:00:00 2001 From: Brendan Burns Date: Fri, 3 Apr 2015 14:54:09 -0700 Subject: [PATCH 1/2] Add a docker image for the hyperkube binary. --- cluster/images/hyperkube/Dockerfile | 4 ++++ cluster/images/hyperkube/Makefile | 10 ++++++++++ 2 files changed, 14 insertions(+) create mode 100644 cluster/images/hyperkube/Dockerfile create mode 100644 cluster/images/hyperkube/Makefile diff --git a/cluster/images/hyperkube/Dockerfile b/cluster/images/hyperkube/Dockerfile new file mode 100644 index 0000000000000..dbd3401ea7813 --- /dev/null +++ b/cluster/images/hyperkube/Dockerfile @@ -0,0 +1,4 @@ +FROM google/debian:wheezy + +COPY hyperkube /hyperkube + diff --git a/cluster/images/hyperkube/Makefile b/cluster/images/hyperkube/Makefile new file mode 100644 index 0000000000000..5a8fed70736a5 --- /dev/null +++ b/cluster/images/hyperkube/Makefile @@ -0,0 +1,10 @@ +# build the hyperkube image. + +VERSION=dev + +all: + cp ../../../_output/release-stage/server/linux-amd64/kubernetes/server/bin/hyperkube ./ + docker build -t gcr.io/google_containers/hyperkube:${VERSION} . + gcloud preview docker push gcr.io/google_containers/hyperkube:${VERSION} + +.PHONY: all From 628b052aaea8968c0121513f1c5650a3ed9036eb Mon Sep 17 00:00:00 2001 From: Brendan Burns Date: Fri, 3 Apr 2015 17:04:58 -0700 Subject: [PATCH 2/2] Add a docker how-to guide. --- cluster/images/hyperkube/Dockerfile | 5 ++ cluster/images/hyperkube/Makefile | 4 +- cluster/images/hyperkube/master.json | 45 ++++++++++++++++ docs/getting-started-guides/README.md | 3 ++ docs/getting-started-guides/docker.md | 76 +++++++++++++++++++++++++++ 5 files changed, 131 insertions(+), 2 deletions(-) create mode 100644 cluster/images/hyperkube/master.json create mode 100644 docs/getting-started-guides/docker.md diff --git a/cluster/images/hyperkube/Dockerfile b/cluster/images/hyperkube/Dockerfile index dbd3401ea7813..ec8b6afefc961 100644 --- a/cluster/images/hyperkube/Dockerfile +++ b/cluster/images/hyperkube/Dockerfile @@ -1,4 +1,9 @@ FROM google/debian:wheezy +RUN apt-get update +RUN apt-get -yy -q install iptables COPY hyperkube /hyperkube +RUN chmod a+rx /hyperkube + +COPY master.json /etc/kubernetes/manifests/master.json diff --git a/cluster/images/hyperkube/Makefile b/cluster/images/hyperkube/Makefile index 5a8fed70736a5..b3d120e758b5c 100644 --- a/cluster/images/hyperkube/Makefile +++ b/cluster/images/hyperkube/Makefile @@ -1,9 +1,9 @@ # build the hyperkube image. -VERSION=dev +VERSION=v0.14.1 all: - cp ../../../_output/release-stage/server/linux-amd64/kubernetes/server/bin/hyperkube ./ +# cp ../../../_output/release-stage/server/linux-amd64/kubernetes/server/bin/hyperkube ./ docker build -t gcr.io/google_containers/hyperkube:${VERSION} . gcloud preview docker push gcr.io/google_containers/hyperkube:${VERSION} diff --git a/cluster/images/hyperkube/master.json b/cluster/images/hyperkube/master.json new file mode 100644 index 0000000000000..fc9cb2466fca9 --- /dev/null +++ b/cluster/images/hyperkube/master.json @@ -0,0 +1,45 @@ +{ +"apiVersion": "v1beta3", +"kind": "Pod", +"metadata": {"name":"nginx"}, +"spec":{ + "hostNetwork": true, + "containers":[ + { + "name": "controller-manager", + "image": "gcr.io/google_containers/hyperkube:v0.14.1", + "command": [ + "/hyperkube", + "controller-manager", + "--master=127.0.0.1:8080", + "--machines=127.0.0.1", + "--sync_nodes=true", + "--v=2" + ] + }, + { + "name": "apiserver", + "image": "gcr.io/google_containers/hyperkube:v0.14.1", + "command": [ + "/hyperkube", + "apiserver", + "--portal_net=10.0.0.1/24", + "--address=127.0.0.1", + "--etcd_servers=http://127.0.0.1:4001", + "--cluster_name=kubernetes", + "--v=2" + ] + }, + { + "name": "scheduler", + "image": "gcr.io/google_containers/hyperkube:v0.14.1", + "command": [ + "/hyperkube", + "scheduler", + "--master=127.0.0.1:8080", + "--v=2" + ] + } + ] + } +} diff --git a/docs/getting-started-guides/README.md b/docs/getting-started-guides/README.md index e943af97daf59..9eafb5b911511 100644 --- a/docs/getting-started-guides/README.md +++ b/docs/getting-started-guides/README.md @@ -1,6 +1,8 @@ If you are not sure what OSes and infrastructure is supported, the table below lists all the combinations which have been tested recently. +For the easiest "kick the tires" experience, please try the [local docker](docker.md) guide. + If you are considering contributing a new guide, please read the [guidelines](../../docs/devel/writing-a-getting-started-guide.md). @@ -23,6 +25,7 @@ Vmware | CoreOS | CoreOS | flannel | [docs](../../docs/getting Azure | Saltstack | Ubuntu | OpenVPN | [docs](../../docs/getting-started-guides/azure.md) | Community (@jeffmendoza) | Bare-metal | custom | Ubuntu | _none_ | [docs](../../docs/getting-started-guides/ubuntu_single_node.md) | Community (@jainvipin) | Bare-metal | custom | Ubuntu Cluster | flannel | [docs](../../docs/getting-started-guides/ubuntu_multinodes_cluster.md) | Community (@resouer @WIZARD-CXY) | use k8s version 0.12.0 +Docker | custom | N/A | local | [docs](docker.md) | Project (@brendandburns) | Tested @ 0.14.1 | Local | | | _none_ | [docs](../../docs/getting-started-guides/locally.md) | Community (@preillyme) | Ovirt | | | | [docs](../../docs/getting-started-guides/ovirt.md) | Inactive | Rackspace | CoreOS | CoreOS | Rackspace | [docs](../../docs/getting-started-guides/rackspace.md) | Inactive | diff --git a/docs/getting-started-guides/docker.md b/docs/getting-started-guides/docker.md new file mode 100644 index 0000000000000..933775605ee50 --- /dev/null +++ b/docs/getting-started-guides/docker.md @@ -0,0 +1,76 @@ +## Running kubernetes locally via Docker + +The following instructions show you how to set up a simple, single node kubernetes cluster using Docker. + +### Step One: Run etcd +```sh +docker run --net=host -d kubernetes/etcd:2.0.5.1 /usr/local/bin/etcd --addr=127.0.0.1:4001 --bind-addr=0.0.0.0:4001 --data-dir=/var/etcd/data +``` + +### Step Two: Run the master +```sh +docker run --net=host -d -v /var/run/docker.sock:/var/run/docker.sock gcr.io/google_containers/hyperkube:v0.14.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 +``` + +This actually runs the kubelet, which in turn runs a [pod](https://github.com/GoogleCloudPlatform/kubernetes/blob/master/docs/pods.md) that contains the other master components. + +### Step Three: Run the service proxy +*Note, this could be combined with master above, but it requires --privileged for iptables manipulation* +```sh +docker run -d --net=host --privileged gcr.io/google_containers/hyperkube:v0.14.1 /hyperkube proxy --master=http://127.0.0.1:8080 --v=2 +``` + +### Test it out +At this point you should have a running kubernetes cluster. You can test this by downloading the kubectl +binary +([OS X](http://storage.googleapis.com/kubernetes-release/release/v0.14.1/bin/darwin/amd64/kubectl)) +([linux](http://storage.googleapis.com/kubernetes-release/release/v0.14.1/bin/linux/amd64/kubectl)) + +*Note:* +On OS/X you will need to set up port forwarding via ssh: +```sh +boot2docker ssh -L8080:localhost:8080 +``` + +List the nodes in your cluster by running:: + +```sh +kubectl get nodes +``` + +This should print: +``` +NAME LABELS STATUS +127.0.0.1 Ready +``` + +If you are running different kubernetes clusters, you may need to specify ```-s http://localhost:8080``` to select the local cluster. + +### Run an application +```sh +kubectl -s http://localhost:8080 run-container nginx --image=nginx --port=80 +``` + +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: +```sh +kubectl expose rc nginx --port=80 +``` + +This should print: +``` +NAME LABELS SELECTOR IP PORT(S) +nginx run-container=nginx 80/TCP +``` + +Hit the webserver: +```sh +curl +``` + +Note that you will need run this curl command on your boot2docker VM if you are running on OS X. + +### A note on turning down your cluster +Many of these containers run under the management of the ```kubelet``` binary, which attempts to keep containers running, even if they fail. So, in order to turn down +the cluster, you need to first kill the kubelet container, and then any other containers.