Skip to content

Instantly share code, notes, and snippets.

@binario200
Last active March 17, 2016 21:55
Show Gist options
  • Save binario200/3f945b5b20961e028cd0 to your computer and use it in GitHub Desktop.
Save binario200/3f945b5b20961e028cd0 to your computer and use it in GitHub Desktop.
# http://sebgoa.blogspot.mx/2015/04/1-command-to-kubernetes-with-docker.html
# You need to have docker installed on one machine.
# check for docker compose installation if not install it with
curl -L https://github.com/docker/compose/releases/download/1.2.0/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
# check for correct installation with
docker-compose version
#create the yaml fiel to be used to raise the kubernetes server, named as k8s.yml
# see the yaml included
# set the version of kubernetes of use (for these demo 0.17.0)
export K8S_VERSION=0.17.0
# And now, 1 command, in the same directory where is the k8s.yml file
docker-compose -f k8s.yml up -d
# check docker ps for the components of kubernetes
docker ps
# at this point you should have a running kubernetes cluster
# to test the cluster we need the client/cli -> kubctl
wget http://storage.googleapis.com/kubernetes-release/release/v${K8S_VERSION}/bin/linux/amd64/kubectl
chmod 755 kubectl
PATH=$PATH:`pwd`
# test by listing the nodes running in the cluster
kubectl get nodes
# running an app
kubectl run-container nginx --image=nginx --port=80
# check for the pod where you new container app was grouped
# also you will see the pod for kubernetes (yeah kubernetes managed by kubernetes)
kubectl get pods
#check for the replication controller (rc)
kubectl get rc
# you can have some fun resize capability and see how a new container pop-up
kubectl resize --replicas=2 rc nginx
# Expose it as a service
kubectl expose rc nginx --port=80 --public-ip=the_instance_public_IP
# now go to http://the_instance_public_IP
# at the very very end
docker-compose -f k8s.yml stop
# kill them all
docker kill $(docker ps -aq)
etcd:
image: kubernetes/etcd:2.0.5.1
net: "host"
command: /usr/local/bin/etcd --addr=127.0.0.1:4001 --bind-addr=0.0.0.0:4001 --data-dir=/var/etcd/data
master:
image: gcr.io/google_containers/hyperkube:v0.17.0
net: "host"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
command: /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
proxy:
image: gcr.io/google_containers/hyperkube:v0.17.0
net: "host"
privileged: true
command: /hyperkube proxy --master=http://127.0.0.1:8080 --v=2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment