- https://coreos.com/blog/running-kubernetes-example-on-CoreOS-part-2/
- https://github.com/GoogleCloudPlatform/kubernetes/blob/master/examples/guestbook/README.md
$ git clone https://gist.github.com/9d74dc702c49d41035f7.git
$ vagrant up
It will boot up one for etcd discovery
, one master
and two minion servers (minion-x
).
Setup an SSH tunnel to the Kubernetes API Server in order to use kubecfg
on your local machine.
$ curl -OL http://storage.googleapis.com/kubernetes/darwin/kubecfg
$ chmod +x kubecfg
$ mv kubecfg /usr/local/bin
$ vagrant ssh-config master > ssh.config
$ ssh -f -nNT -L 8080:127.0.0.1:8080 -F ssh.config master
$ kubecfg list pods
Name Image(s) Host Labels
---------- ---------- ---------- ----------
Cf.) https://github.com/kelseyhightower/kubernetes-coreos#running-commands-remotely
$ kubecfg -c redis-master.json create pods
I0731 16:18:06.205838 13060 request.go:220] Waiting for completion of /operations/1
I0731 16:18:26.208799 13060 request.go:220] Waiting for completion of /operations/1
I0731 16:18:46.212773 13060 request.go:220] Waiting for completion of /operations/1
.
.
.
Name Image(s) Host Labels
---------- ---------- ---------- ----------
redis-master-2 dockerfile/redis / name=redis-master
$ kubecfg list pods
Name Image(s) Host Labels
---------- ---------- ---------- ----------
redis-master-2 dockerfile/redis 192.168.12.11/ name=redis-master
$ vagrant ssh minion-1 -c "docker ps"
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
2d40ca4bff5f dockerfile/redis:latest redis-server /etc/re 47 seconds ago Up 47 seconds k8s--master--redis_-_master_-_2--ec662fc1
425efffe8238 busybox:buildroot-2014.02 sh -c 'rm -f nap && 5 minutes ago Up 5 minutes 0.0.0.0:6379->6379/tcp k8s--net--redis_-_master_-_2--882f503e
$ kubecfg -c redis-master-service.json create services
I0731 16:31:24.530943 13428 request.go:220] Waiting for completion of /operations/2
Name Labels Selector Port
---------- ---------- ---------- ----------
redismaster name=redis-master 10000
$ kubecfg list services
Name Labels Selector Port
---------- ---------- ---------- ----------
redismaster name=redis-master 10000
$ kubecfg -c redis-slave-controller.json create replicationControllers
I0731 16:41:07.076419 13563 request.go:220] Waiting for completion of /operations/3
I0731 16:41:27.080095 13563 request.go:220] Waiting for completion of /operations/3
I0731 16:41:47.083393 13563 request.go:220] Waiting for completion of /operations/3
.
.
.
Name Image(s) Selector Replicas
---------- ---------- ---------- ----------
redisSlaveController brendanburns/redis-slave name=redisslave 2
$ kubecfg list pods
Name Image(s) Host Labels
---------- ---------- ---------- ----------
redis-master-2 dockerfile/redis 192.168.12.11/ name=redis-master
9053847d-1914-11e4-9ad9-080027558144 brendanburns/redis-slave 192.168.12.11/ name=redisslave,replicationController=redisSlaveController
a82d9013-1914-11e4-9ad9-080027558144 brendanburns/redis-slave 192.168.12.12/ name=redisslave,replicationController=redisSlaveController
$ kubecfg -c redis-slave-service.json create services
I0731 16:49:09.808457 13880 request.go:220] Waiting for completion of /operations/6
Name Labels Selector Port
---------- ---------- ---------- ----------
redisslave name=redisslave name=redisslave 10001
$ kubecfg list services
Name Labels Selector Port
---------- ---------- ---------- ----------
redismaster name=redis-master 10000
redisslave name=redisslave name=redisslave 10001
$ kubecfg -c frontend-controller.json create replicationControllers
I0731 16:51:36.054889 13946 request.go:220] Waiting for completion of /operations/7
I0731 16:51:56.059760 13946 request.go:220] Waiting for completion of /operations/7
I0731 16:52:16.063003 13946 request.go:220] Waiting for completion of /operations/7
.
.
.
Name Image(s) Selector Replicas
---------- ---------- ---------- ----------
frontendController brendanburns/php-redis name=frontend 2
$ kubecfg list pods
Name Image(s) Host Labels
---------- ---------- ---------- ----------
redis-master-2 dockerfile/redis 192.168.12.11/ name=redis-master
9053847d-1914-11e4-9ad9-080027558144 brendanburns/redis-slave 192.168.12.11/ name=redisslave,replicationController=redisSlaveController
4b1165ed-1916-11e4-9ad9-080027558144 brendanburns/php-redis 192.168.12.11/ name=frontend,replicationController=frontendController
a82d9013-1914-11e4-9ad9-080027558144 brendanburns/redis-slave 192.168.12.12/ name=redisslave,replicationController=redisSlaveController
b0129fd6-1915-11e4-9ad9-080027558144 brendanburns/php-redis 192.168.12.12/ name=frontend,replicationController=frontendController
$ open http://192.168.12.11:8000
$ open http://192.168.12.12:8000