Kubernetes Services, ClusterIP – NodePort – ALB architecture for exposing service

A kubernetes service is a group of pods running in a cluster.

ClusterIP is a service which is accessible only within the Kubernetes cluster. Hence, it is the internal IP of the components inside a Kubernetes cluster.

NodePort is an open port for every node in the cluster. This is accessible from outside the cluster.

LoadBalancer distributes the external request among the workers of the cluster.

Following commands are used to create 4 PODS using four Manifest files (pod1.yaml, pod2.yaml, pod3.yaml, pod4.yaml)

After the PODS are created, a CLUSTERIP service with the same label as the pods is created with port forwarding 80 to 5666.
With the cluster ip and port 5666, the application is hit.

After that, NodePort service is created with the same “label” as the PODs and port forwarding to 5667. When it is described, an external port 32350 is generated. The IP of the NodePort with the port 5667 or the IP of the worker (A.X.Y.Z) with the port 32350 is used to access the application.

After that, a Load Balancer is created with the same label as the pods and forwarded to port 5668.

1057 kubectl get pod | grep manu
1058 clear
1059 ls
1060 cp pod.yaml pod2.yaml
1061 cp pod.yaml pod3.yaml
1062 cp pod.yaml pod4.yaml
1063 cp pod.yaml pod1.yaml
1064 vi pod1.yaml
1065 vi pod3.yaml
1066 vi pod4.yaml
1067 clear
1068 kubectl apply -f pod1.yaml
1069 kubectl apply -f pod2.yaml
1070 vi pod2.yaml
1071 kubectl apply -f pod2.yaml
1072 vi pod2.yaml
1073 kubectl apply -f pod2.yaml
1074 vi pod3.yaml
1075 kubectl apply -f pod3.yaml
1076 vi pod4.yaml
1077 kubectl apply -f pod4.yaml
1078 kubectl get pod|grep manu
1079 kubectl get pod -o wide | grep manu
1080 clear
1081 kubectl get pod -o wide | grep manu
1082 ipconfig
1083 ifconfig
1084 clear
1085 kubectl create service clusterip manucs –tcp=5666:80
1086 kubectl get svc
1087 kubectl get svc|grep manu
1088 kubectl delete svc manunp
1089 kubectl get svc|grep manu
1090 curl
1091 kubectl edit svc manucs
1092 curl
1093 watch curl
1094 clear
1095 kubectl create service nodeport manunp –tcp=5667:80
1096 kubectl get svc manunp
1097 kubectl get svc | grep manu
1098 kubectl get svc|grep manu
1099 kubectl edit svc manunp
1100 curl
1101 watch cur;
1102 watch curl
1103 watch curl
1104 curl
1105 watch curl
1106 clear
1107 kubectl create service loadbalancer manulb –tcp=5668:80
1108 kubectl get svc|grep manu
1109* kubectl t svc manulb
1110 watch curl
1111 watch curl
1112 watch curl
1113 watch curl
1114 watch curl
1115 watch curl
1116 clear
1117 history