Configure Port Forwarding to access the application in Kubernetes Cluster
IT Tricks Random

Configure Port Forwarding to access the application in Kubernetes Cluster


Configure Port Forwarding to access applications in Kubernetes Cluster – Cuongquach.com | Kubectl port-foward will help you access and interact with the Pod services running on Kubernetes Cluster from your localhost. This method is often used to debug problems related to services, without being allowed to publicize the service. Go Port-forwarding What are you can refer here: https://en.wikipedia.org/wiki/Port_forwarding

Manipulate Port-Forwarding configuration with Kubernetes Cluster

The purpose of the use Port Fowarding Normally :

  • You have internal application, need security, .. do not let public out. Should only be accessible from internal servers via VPN or office.
  • It could be a web application, it could also be a database application like redis, postgresql, etc.
  • You can open the port forward from localhost laptop to that local service. From there, you can manage from laptop or simply debug problems arising with that internal service through the service port with the localhost port (tunnel port forwarding).

Kubectl is one of the main command program tools used to interactively manage the Kubernetes Cluster. The program helps you deploy applications, manage Kubernetes Cluster system components, …

Process of operation Port Forward with kubectl Simple as follows:

  • User to use command kubectl to initialize Port-fowarding to the port of Pod / Deployment / Service on the Kubernetes Cluster.
  • The Kubernetes API will proceed to initialize a Tunnel Connection between your localhost and the resource running on the Kubernetes Cluster.
  • Kubernetes Cluster objects you can interact through Port-forwarding kubectl : Deployment / Pod / Service / ReplicaSet.

Configure Port Forwarding with kubectl

Command syntax portfoward will help initialize one Tunnel from Pod designated to localhost running port-forward command. From there you can access the service application through local port to port Pod.

Syntax:

Now we will create one Deployment service so it’s easy to experiment with. I will choose Grafana service, have interface to access web dashboard from localhost laptop try it out.

Then you check it out Deployment and Pod Is Grafana running:

Normal to be accessible Grafana Dashboard, then this service needs to be configured to be accessible from outside the Kubernetes Cluster. But the initial default is only accessible from within the Kubernetes Cluster because Grafana is being configured ClusterIP.

So this helps to practice for user needs Port Forwarding easier to understand. By opening local port forwarding to the Grafana service’s web port dashboard.

We now have the correct information for Namespace and Pod / Deployment / Service Grafana is running offline in the above command output.

+ Use specific local forwarding port (: 8080)

We will open port-forwarding to port 3000 of Pod Grafana with local host port is 8080.

or port-forward to the Deployment Grafana.

or port-foward to Service Grafana.

Access result of port 8080 on test laptop.

+ Use random local port forwarding

Source: https://cuongquach.com/

Leave a Reply

Your email address will not be published. Required fields are marked *