In the following lab we will set up our local development environment, provision the workshop cluster and roll out our static web application example. Your deployment won't be exposed and is only available by ClusterIP of the corresponding pod-service. You can access the application by tunneling your localhost through kubectl proxy
command, or kubectl port-forward
.
- Run deployment
kubectl apply -f .
- You can check the state of Pods at any time with the following kubectl command:
kubectl get pods -n doit-lab-03
- You can check your deployment with the following kubectl command:
kubectl get deployments -n doit-lab-03
- You can check the corresponding service endpoint by the following kubectl command:
kubectl get services -n doit-lab-03
- You can test the deployed web application using this command and access the app by hitting url
http://localhost:8080
kubectl port-forward service/static-web-app-service 8080:8080 -n doit-lab-03
curl http://localhost:8080
Now we can set the current k8s context to our lab exercise namespace doit-lab-03
to make sure that every command set is run against this lab resources.
kubectl config set-context --current --namespace=doit-lab-03
Replace 03-static-web-app-deployment.yaml
with affinity-tolerations/04-static-web-app-affinity-deployment.yaml
to see how the Kubernetes scheduler decides on the pod placement now:
kubectl delete -f 03-static-web-app-deployment.yaml
kubectl apply -f affinity-tolerations/04-static-web-app-affinity-deployment.yaml
Taint your nodes with the NoSchedule
taint and recreate the deployment:
kubectl get nodes
kubectl taint nodes node1 node2 node3 blocked:NoSchedule
kubectl delete -f 03-static-web-app-deployment.yaml
kubectl apply -f 03-static-web-app-deployment.yaml
Replace the (unscheduleable, due to taints) deployment with affinity-tolerations/04-static-web-app-tolerations-deployment.yaml
:
kubectl delete -f 03-static-web-app-deployment.yaml
kubectl apply -f affinity-tolerations/05-static-web-app-tolerations-deployment.yaml
kubectl delete -f .
kubectl taint nodes node1 node2 node3 blocked:NoSchedule-