DevSecOps for BBK
  • Introduction
  • Getting Started
    • Virtual Training Practices
    • Training Plan
    • Tools and Configuration
    • Troubleshooting
  • Docker Fundamentals
    • Docker Setup
    • Docker First Container
    • Docker Network Basics
    • Docker Network Exercise
    • Docker Volume Basics
    • Docker Storage
  • Dockerfile Fundamentals
    • Dockerfile Instructions
    • Dockerfile Environment Variables
    • Dockerfile Build Arguments
    • Non-privileged Containers
    • Dockerfile Order of Execution
    • Dockerfile Volume
    • Entrypoint Command
    • Multiple Stage Build
  • Container Management
    • Containers Start Automatically
  • Docker Security
    • Seccomp Profile
  • Docker Compose
    • Docker Compose Install
    • Docker Compose Commands
    • Docker Compose File
    • Docker Compose Volumes and Network
  • K8s Cluster Setup
    • Minikube Installation
    • Calico Networking
    • K8s Walkthrough
    • K8s Cheat Sheet
  • Understand K8s
    • Pod Connectivity
    • Deployments
    • Service Cluster IP
    • Service NodePort
    • ClusterIP Exercise
    • NodePort Exercise
    • Service LoadBalancer
    • Configmap
    • Secrets
  • Application Lifecycle Management
    • Rolling Updates and Rollback
    • Multi Container Pod
  • K8s Storage
    • Persistent Volume
    • Persistent Volume Claim
    • PVC in POD
  • Istio
    • AKS Setup
    • Kubectl Setup in Windows
    • Istio Setup Manual
    • Istio Demo App
    • Istio Observability
  • Terraform
    • Terraform Setup
    • Terraform Demo
    • Azure Terraform Setup
  • Terraform AWS
    • Terraform AWS Setup
    • Terraform AWS Demo S3
  • Refrences
    • Docker Static Site
    • Docker First Image
Powered by GitBook
On this page
  1. Understand K8s

NodePort Exercise

Applications running in a Kubernetes cluster find and communicate with each other, and the outside world, through the Service abstraction

We are using a Nginx webserver that echoes back the source IP of requests it receives through an HTTP header.

  1. Create a Nginx WebServer with echoserver Image

kubectl create deployment web-app --image=k8s.gcr.io/echoserver:1.4
  1. Expose the echoserver Image pod with the help of a service.

kubectl expose deployment web-app --name=web-app-svc --port=80 --target-port=8080 --type=NodePort
  1. Get the Service IP Address

kubectl get svc web-app-svc
  1. Run a Client Server to test NodePort Connectivity

kubectl run busybox -it --image=busybox --restart=Never --rm

Inside the Busy Box Image, we are going to run the below commands.

  1. Check the IP Address of the Client.

ip addr
  1. Use Wget to call the Web-app-svc from the Busybox Pod

Replace "10.0.170.92" with the IPv4 address of the Kubernetes Worker Node and Port which is in 30000 range.

wget -qO - 10.0.170.92:30171

If you observe the output has "client_address"

The client_address is not always the client pod's IP address. there a natting done, when it is sent to Destination.

Cleanup

  1. Delete Service and Deployment

kubectl delete svc web-app-svc
kubectl delete deployment web-app
PreviousClusterIP ExerciseNextService LoadBalancer

Last updated 2 years ago