Monday, August 31, 2015

Kubernetes, Docker

Kubernetes

 This article is only to hold links and ready to use commands. You can find more in documentation.

Running Kubernetes locally via Docker 

docker run --net=host -d gcr.io/google_containers/etcd:2.0.9 /usr/local/bin/etcd --addr=127.0.0.1:4001 --bind-addr=0.0.0.0:4001 --data-dir=/var/etcd/data
 
docker run --net=host -d -v /var/run/docker.sock:/var/run/docker.sock  gcr.io/google_containers/hyperkube:v0.21.2 /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
 
docker run -d --net=host --privileged gcr.io/google_containers/hyperkube:v0.21.2 /hyperkube proxy --master=http://127.0.0.1:8080 --v=2
 

Running an application

kubectl -s http://localhost:8080 run-container nginx --image=nginx --port=80

Expose it as a service

kubectl expose rc nginx --port=80

Turn down cluster

docker ps -a | awk '{print $1}' | xargs docker kill
 

Docker

Show available images

docker images

Build image

docker build -t approdorix/appname .

Stop, remove containers/images

docker stop $(docker ps -a -q)
docker rm $(docker ps -a -q)
docker rmi $(docker images -q) 
 

Troubleshooting docker

You want to run screen but no tty in docker:
exec >/dev/tty 2>/dev/tty </dev/tty

No comments:

Post a Comment