Skip to content

Latest commit

 

History

History

README.md

GKE Workshop LAB-04

Web-Application Deployment, NodePort Example

Context License

Introduction

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.

Deployment

  1. Apply all manifests to the cluster
kubectl apply -f .

Cluster Application Check / Playground

  1. You can check the state of Pods at any time with the following kubectl command:
kubectl get pods -n doit-lab-04
  1. You can check your deployment with the following kubectl command:
kubectl get deployments -n doit-lab-04
  1. You can check the corresponding service endpoint by the following kubectl command:
kubectl get services -n doit-lab-04
  1. 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'
  1. 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
  1. Now you can access your service calling one of your external node-IPs:30000 in your browser
-> http://<one-of-your-external-node-ip>:30000

Optional Steps

Now 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-04

Application Clean-Up

gcloud compute firewall-rules delete my-node-port-opened-service
kubectl delete -f .

Links