Here we will see a standard blue-green rolling deployment where we change from an older version of an application to an updated one.
We will see two ways of creating a service so that you become familiar with kubectl and YAML.
Relevant Kubernetes documentation is found here. Instructors will cover "Writing a Deployment Spec."
These steps are to be executed from your local machine!
$ cd /[LOCATION YOU CLONED THIS REPO]/GKE-hands-on-training
$ kubectl apply -f examples/rolling-deployment/deployment-v1.0.yaml
$ kubectl get deployments k8s-workshop-site
Decribe the deployment
$ kubectl describe deployments k8s-workshop-site
See all the pods running on the cluster
$ kubectl get pods -o wide
$ kubectl expose deployment k8s-workshop-site --type=LoadBalancer --name=k8s-workshop-site-dev
Find the port and external IP
$ kubectl get services k8s-workshop-site-dev
You should now be seeing:
root@bootstrap-node:~/hands-on-with-kubernetes-workshop# kubectl get services
NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE
k8s-workshop-site 172.17.149.128 104.196.252.72 80:32233/TCP 13s
Navigate to the external-ip address with the port (104.196.252.72:80 in this example).
Execute the following command from your machine:
$ kubectl apply -f examples/rolling-deployment/deployment-v1.1.yaml
Check the pods that are running (either in UI or with command)
$ kubectl get pods -o wide
Now if we check the pods currently running we should see v1.1 of the application is coming online:
NAME READY STATUS RESTARTS AGE
k8s-workshop-site-1412125313-c9clv 1/1 Running 0 7m
k8s-workshop-site-1412125313-dlhsh 1/1 Terminating 0 7m
k8s-workshop-site-1412125313-lxtx3 1/1 Running 0 7m
k8s-workshop-site-1641828995-6z6xm 0/1 ContainerCreating 0 3s
k8s-workshop-site-1641828995-jjgtc 0/1 ContainerCreating 0 3s
Refresh the site in the browser. You should see version 1.1.
Delete the Service
kubectl delete services k8s-workshop-site-dev
Finally delete the deployment
$ kubectl delete -f examples/rolling-deployment/deployment-v1.1.yaml