Simplest Way to Connect Workloads in Kubernetes Cluster
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,
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,
Select your name space and click enter to continue to show the 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.
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.
Enter the port which you need to listen through locally (ex:localhost:8080),
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!