If you already have a running cluster skip next step (please change the IP address used in the commands)
From 0 to k8s -> https://coreos.com/kubernetes/docs/latest/kubernetes-on-vagrant-single.html
kubectl run example-go --image=deis/example-go --replicas=1 --port=8080
kubectl expose rc example-go --port=8080
kubectl scale --replicas=3 replicationcontrollers example-go
kubectl annotate svc example-go "serviceloadbalancer/lb.host=www.k8s.io"
wget https://gist.githubusercontent.com/aledbf/2985931789f3c182f22b/raw/53ff53f49a598fd7ee67e5a6cc0d12526313c2fe/haproxy-rc.yaml
kubectl create -f haproxy-rc.yaml
(wait)
kubectl describe pods -l app=service-loadbalancer
#Routing using the service name:
http://172.17.4.99/example-go:8080
#Routing using Host header:
kubectl annotate svc example-go "serviceloadbalancer/lb.host=www.k8s.io"
curl -v 172.17.4.99 -H "Host: www.k8s.io"
##Session Affinity:
If non-empty, set the session affinity for the service to this; legal values: 'None', 'ClientIP'
kubectl expose example-go --session-affinity="ClusterIP"
if the service already exists
kubectl patch svc example-go -p '{"spec":{"sessionAffinity":"ClientIP"}}'
kubectl expose example-go --session-affinity="ClientIP"
kubectl annotate svc example-go "serviceloadbalancer/lb.cookie-sticky-session=true"
if the service already exists
kubectl patch svc example-go -p '{"spec":{"sessionAffinity":"ClientIP"}}'
kubectl annotate svc example-go "serviceloadbalancer/lb.cookie-sticky-session=true"
--namespace
different namespace than "default"--all-namespaces
all available namespaces
kubectl 1.1.0 is required (because of the annotate command)