×
access the POD from outside the cluster
Blog Cloud Computing Containers

Steps to access the POD from outside the cluster

Steps to access the POD from outside the cluster

In this blog, we will show you the Steps to access the POD from outside the cluster in Google Kubernetes environment.

 

REQUIREMENTS

  • 2 Node Cluster ( 1 Master VM with 2 Nodes)
  • Kubernetes Components

 

INFRASTRUCTURE OVERVIEW

  • We have already installed and configured the 2 Node cluster in our demo environment.

 

KUBERNETES SERVICES

  • We can able to access our application through services. Our application can be access from the inside and the outside the cluster.
  • Services will be the reliable between the POD and client end.
  • The service will get a virtual IP from the DNS and it will never change. Also, it gets a DNS name and a Port number. The port number is available through cluster-wide. Using this port we can able to access our application from outside.
  • We are creating endpoint object along with the services. It contains the POD information. The endpoint will get updated when a POD creates (or) deletes.
  • We tied pods with services using Labels.
  • We will specify the Labels information in the POD creation manifest file.
  • DNS cluster add-on implements DNS service in the cluster.
  • Services get DNS names that are resolvable inside the cluster.

 

ENVIRONMENT OVERVIEW

  • We have already created a POD named hello-pod for this demo.

Steps to access the POD from outside the cluster

 

  • Also, we used the below manifest file to create our demo hello-pod.

Steps to access the POD from outside the cluster

 

Note: Labels are mandatory for kubernetes services. So we need to specify the label information in the manifest file for POD creation.

 

  • Currently, there are 2 nodes in the cluster. Node 1 IP is 192.168.3.82 and Node 2 IP is 192.168.3.83

Steps to access the POD from outside the cluster

 

 

CREATING A SERVICE

  • From the Kubernetes Master server, execute the below command to create a service.

Syntax: kubectl expose pod <pod-name> --name=<name for the service> --port=<container application port> --type=NodePort

Example: kubectl expose pod hello-pod --name=hello-svc --port=80 --type=NodePort

Steps to access the POD from outside the cluster

 

Note: By default, public ngnix container listens to port 80.

 

  • Service created successfully.

Steps to access the POD from outside the cluster

 

  • Describe the service using the below command.

kubectl describe service hello-svc

Steps to access the POD from outside the cluster

 

  • The service virtual IP is 10.103.224.243 and the NodePort is 30134. Using this node port we can able to access the application from your local machine.
  • Services Port will be available from 30000 to 32767.

 

VERIFICATION

  • Open the web browser from the local machine and access type the kubernetes node IP along with the Node port.

Steps to access the POD from outside the cluster

 

  • We are able to access the nginx homepage successfully. It’s a containerized web server listening in the port 80 and we mapped it to 30134 in every node in the cluster.

Steps to access the POD from outside the cluster

 

  • We can also able to access the application from Node 2.

Steps to access the POD from outside the cluster

 

VIDEO

Thanks for reading this blog. We hope it was useful for you to learn to access the POD from outside the cluster.

2 thoughts on “Steps to access the POD from outside the cluster”

  1. Hi Loges,

    I have read all your two blogs and its working perfectly. But i have one problem, i am stetting up this cluster in a private datacenter, which dosent have “LoadBalancer” type service implemented. They provided me an external static IP. now how can i access multiple services which i run in the cluster with hostname (I know nginx ingress is there, but i cant albe to make it workable). Can you please share a blog regarding this

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.