Skip to content

Latest commit

 

History

History
161 lines (126 loc) · 4.47 KB

04-deploy-on-kubernetes.md

File metadata and controls

161 lines (126 loc) · 4.47 KB

Deploy on Kubernetes

Build Icon on Kubernetes Minikube

eval $(minikube docker-env)
docker build -t spiddy/coin:v1.0 -t spiddy/coin:v2.0 images/coin/

Deploy Coin & Status Page

The following components are created in Kubernetes

kubectl create -f kubernetes/

Get the Pods

$ kubectl get pods
sNAME                          READY     STATUS    RESTARTS   AGE
coin-7895dcd8b8-lxdbb         1/1       Running   0          19s
statuspage-7656d9bfd6-k7xj6   1/1       Running   0          19s

Get the Services:

$ kubectl get services
NAME         TYPE        CLUSTER-IP   EXTERNAL-IP   PORT(S)        AGE
coin         NodePort    10.0.0.185   <none>        80:31000/TCP   40s
kubernetes   ClusterIP   10.0.0.1     <none>        443/TCP        16h
statuspage   NodePort    10.0.0.146   <none>        80:32000/TCP   40s

Get the Minikube IP

$ minikube ip
192.168.99.100

Get response from Coin at port :31000

$ curl 192.168.99.100:31000
500 - Bad luck, try flipping the coin again!

Open browser to http://192.168.99.100:32000

Scale Up Coins

$ kubectl scale deployment coin --replicas=10
deployment "coin" scaled

Check Pods

$ kubectl get pods
NAME                          READY     STATUS    RESTARTS   AGE
coin-7895dcd8b8-2swck         1/1       Running   0          14s
coin-7895dcd8b8-4gg56         1/1       Running   0          14s
coin-7895dcd8b8-b54gh         1/1       Running   0          14s
coin-7895dcd8b8-fmg6r         1/1       Running   0          14s
coin-7895dcd8b8-h2s4g         1/1       Running   0          14s
coin-7895dcd8b8-hmbzh         1/1       Running   0          14s
coin-7895dcd8b8-j7k5j         1/1       Running   0          14s
coin-7895dcd8b8-m5wmq         1/1       Running   0          14s
coin-7895dcd8b8-mrb9t         1/1       Running   0          5m
coin-7895dcd8b8-zk8b6         1/1       Running   0          14s

Check output of Coin

$ repeat 10 echo $(curl -s 192.168.99.100:31000)
500 - Bad luck, try flipping the coin again!
500 - Bad luck, try flipping the coin again!
200 - You are a lucky lucky person!
200 - You are a lucky lucky person!
200 - You are a lucky lucky person!
200 - You are a lucky lucky person!
200 - You are a lucky lucky person!
200 - You are a lucky lucky person!
200 - You are a lucky lucky person!
200 - You are a lucky lucky person!

Activate Health Checks to Coins

We'll now reconfigure existing Coin deployment with new configuration that includes LivenessProbe and ReadinessProbe:

$ kubectl apply -f kubernetes-with-healthchecks/
deployment "coin" configured

Check Pods

$ watch kubectl get pod
NAME                          READY     STATUS    RESTARTS   AGE
coin-6bd789f884-dlzgx         1/1       Running   0          8m
statuspage-7656d9bfd6-qfwm9   1/1       Running   0          13m

Check output of Coin

$ repeat 10 echo $(curl -s 192.168.99.100:31000)
200 - You are a lucky lucky person!
200 - You are a lucky lucky person!
200 - You are a lucky lucky person!
200 - You are a lucky lucky person!
200 - You are a lucky lucky person!
200 - You are a lucky lucky person!
200 - You are a lucky lucky person!
200 - You are a lucky lucky person!
200 - You are a lucky lucky person!
200 - You are a lucky lucky person!

Upgrade Coin

Let's upgrade the Coin to v2.0:

$ kubectl set image deployment coin 'coin=spiddy/coin:v2.0'
deployment "coin" image updated

Check output of Coin

$ repeat 10 echo $(curl -s 192.168.99.100:31000)
200 - You are a lucky lucky person!
200 - You are a lucky lucky person!
200 - You are a lucky lucky person!
200 - You are a lucky lucky person!
200 - You are a lucky lucky person!
200 - You are a lucky lucky person!
200 - You are a lucky lucky person!
200 - You are a lucky lucky person!
200 - You are a lucky lucky person!
200 - You are a lucky lucky person!

Cleanup

kubectl delete -f kubernetes