In the following lab we will set up our local development environment, provision the workshop cluster and roll out a static nginx page. Your deployment will be exposed by corresponding pod-service and wait for incoming traffic through NodePort 30000 (http://<one-node-ip>:30000) at all available nodes in all zones.
- Apply all manifests to the cluster
kubectl apply -f .- You can check the state of Pods at any time with the following kubectl command:
kubectl get pods -n doit-lab-04- You can check your deployment with the following kubectl command:
kubectl get deployments -n doit-lab-04- You can check the corresponding service endpoint by the following kubectl command:
kubectl get services -n doit-lab-04- You can check your external IP addresses of your node by entering the following command:
kubectl get nodes -o jsonpath='{ $.items[*].status.addresses[?(@.type=="ExternalIP")].address }' -n doit-lab-04 | tr ' ' '\n'- To access your service by NodePort you have to allow tcp-access to your port-definition (e.g. 30000)
gcloud compute firewall-rules create my-node-port-opened-service --allow tcp:30000 --priority 999- Now you can access your service calling one of your external node-IPs:30000 in your browser
-> http://<one-of-your-external-node-ip>:30000Now we can set the current k8s context to our lab exercise namespace doit-lab-04 to make sure that every command set is run against this lab resources.
kubectl config set-context --current --namespace=doit-lab-04gcloud compute firewall-rules delete my-node-port-opened-service
kubectl delete -f .