Simplest Way to Connect Workloads in Kubernetes Cluster

Damindu Lakmal
3 min readMar 15, 2021

--

Simple Use Case

Kubernetes

Kubernetes is known as K8s which is an open-source system for automating deployment, scaling, and management of containerized applications. Mainly docker containers are functioned inside the k8s cluster.

Install and Set Up Kubectl

K8s command line tool that allows you to run commands against K8s clusters. You can use kubectl to inspect, manage, view logs and deploy the applications.

Configure Credentials

Cluster credentials should be fetched and updated a kubeconfig file. Kubectl command will have appropriate credentials and endpoint information at the K8s cluster. More details from get-credentials

Setup K8PF

K8PF is project which forward port from running pod. Use shell language to build the executable file.

Installation Steps

  • Clone the git repo (with tag)

git clone https://github.com/HADLakmal/K8PF.git

  • In ubuntu, add your K8PF download path to $PATH

export $PATH = $PATH:<your/path/K8PF>

  • Make K8PF file executable

chmod +x K8PF

  • Run the K8PF

Getting Start

Type K8PF in CLI then you will get the list of clusters as follow,

Kubernetes clusters

Select the correct number in Numeric format (ex: 1,2,3,4,…). Then click enter to view the name spaces of selected cluster as follow,

Name Spaces

Select your name space and click enter to continue to show the list of pods.

List of Pods

Pods are related to name space so you can select the pod and continue to the next step.

Options

After selecting the desired pod then you will can choose one of below option to continue further.

Kube Options

Logs

First option is to fetch all logs of the selected pod.

Logs Streamed

Second option is to fetch all logs of the selected pod and real time logs will be fetch until you disconnect connection.

port Forward

Third option is to listen specific port in the pod. You have to give target port which can be forwarded from the service of the pod.

Target Port

Enter the port which you need to listen through locally (ex:localhost:8080),

Port Forward

Conclusion

This was only an overview of the forwarding port from Kubernetes. I’d recommended to use documentation of Kubernetes. Understand K8 functionality, that (especially custom types) can make your own customize scripts.

Thank you for reading this article. I hope you enjoyed it!

--

--

Damindu Lakmal
Damindu Lakmal

No responses yet