Main Menu

Search

KUBERNETES: How To Quickly Test App Pod Without A Service & Not Exposed Externally Whether It is Accessible And Working?

KUBERNETES: How To Quickly Test App Pod Without A Service & Not Exposed Externally Whether It is Accessible And Working?

The quickest and easiest way to verify whether the app pod that is not exposed externally and without a service, is to do following

  • Identify the port on which app is listening/running in the pod.
  • One of the control nodes, use kubectl port-forward command to forward requests coming into IP address/Port on the control node to app pod and port on which app is listening on the pod.
  • Access the application via curl, wget or from browser using the IP address and port of the control node on which kubectl port-forward command is being executed.

Following is the syntax for kubectl port-forward command that has to be executed on the control node.

kubectl port-forward --address <local machine address> <target pod name> -n <namespace> <local machine port>:<target pod app listening port>

Once above kubectl port-forward command is executed, command will be running and control node will be listening on the port waiting for connects. For e.g.On one of the Kubernetes control nodes, You can do port forwarding to forward requests on port 8080 on that kubernetes control node to port 80 on one of the nginx pods as shown below.

kubectl port-forward --address 10.10.10.10 nginx-deployment-6595874d85-n6rww 8080:80

You can then try to access the application using the IP of the Kubernetes nodes and port in this case using http://10.10.10.10:8080 for accessing the nginx app. Other way to test if BUI access is not available is to do wget test as follows in this example. 

wget -p 10.10.10.10:8080

You will see output as follows which indicates nginx index.html file is accessible on port 8080 (forwarded port)

 wget -p 10.10.10.10:8080
--2024-03-21 18:07:29--  http://127.0.0.1:8080/
Connecting to 10.10.10.10:8080... connected.
HTTP request sent, awaiting response... 200 OK
Length: 612 [text/html]
Saving to: ‘10.10.10.10:8080/index.html’

100%[=========================================>] 612         --.-K/s   in 0s      

2024-03-21 18:07:29 (1.23 MB/s) - ‘10.10.10.10:8080/index.html’ saved [612/612]

FINISHED --2024-03-21 18:07:29--

No comments:

Post a Comment