Steps to create Port Forwarding in Kubernetes

Steps to create Port Forwarding in Kubernetes

Steps to create Port Forwarding in Kubernetes

In this blog, we will show you the steps to create Port Forwarding in 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.

 

CREATING A POD USING KUBECTL COMMAND

  • Login to the kubernetes master server through putty.

Steps to create Port Forwarding in Kubernetes

 

  • Use the below command to create a POD.

Syntax: kubectl run <pod name> --image=<image-name> --port=<port number of container application> --generator=run-pod/v1

Example: kubectl run web-pod --image=nginx --port=80 --generator=run-pod/v1

Steps to create Port Forwarding in Kubernetes

 

  • POD created successfully.

Steps to create Port Forwarding in Kubernetes

  • For more information about the generator, please check this URL https://kubernetes.io/docs/reference/kubectl/conventions/#generators
  • The new POD is available on the list.

Steps to create Port Forwarding in Kubernetes

 

  • We can also view the detailed information about the POD using describe command.

kubectl describe pods web-pod

Steps to create Port Forwarding in Kubernetes

 

Steps to create Port Forwarding in Kubernetes

 

CONFIGURE PORT FORWARDING

  • Use the below command to create a Port forwarding for a container.

Syntax: kubectl port-forward <pod name> <local machine port>:<pod container port>

Example: kubectl port-forward web-pod 8888:80

Steps to create Port Forwarding in Kubernetes

 

  • The port forwarding is in running state.

Steps to create Port Forwarding in Kubernetes

 

  • Open a duplicate session of the master server and access the container using the command.

curl 127.0.0.1:8888

Steps to create Port Forwarding in Kubernetes

 

  • You can able to see the nginx homepage.

Steps to create Port Forwarding in Kubernetes

 

  • This is an easy method to verify the container ports without creating the services.

KUBERNETES LOGS

  • We can verify the POD logs using the below command.

Syntax: kubectl logs <pod name>

Example: kubectl logs web-pod

Steps to create Port Forwarding in Kubernetes

 

  • You can able to see the POD logs as shown below.

Steps to create Port Forwarding in Kubernetes

 

 

OTHER KUBERNETES COMMANDS

  • Use the below command to display the POD internal IP.

kubectl get pods -o wide

Steps to create Port Forwarding in Kubernetes

 

  • To display the POD configuration in YAML format.

Syntax: kubectl get pods <pod name> -o yaml

Example: kubectl get pods web-pod -o yaml

Steps to create Port Forwarding in Kubernetes

 

  • To display the POD configuration in JSON format.

kubectl get pods web-pod -o json

Steps to create Port Forwarding in Kubernetes

 

Thanks for reading this blog. We hope it was useful for you to learn about port forwarding in the kubernetes environment.

Share on facebook
Facebook
Share on twitter
Twitter
Share on pinterest
Pinterest
Share on linkedin
LinkedIn
More Interested Related Posts
zfs pool usage

ZFS Pool and Dataset Usage

ZFS Pool and Dataset Usage   I am back with another blog to provide the useful script to the Freebsd users to determine the zpool

Assistanz Networks

Installing Zabbix Agent in FreeBSD 12.0

Zabbix Agent Installation and Configuration Guide on FreeBSD 12.0   Zabbix is an open-source monitoring software tool for diverse IT components, including networks, servers, virtual

DirectAdmin Server Management Plans

Premium Support

24/7 End User Support from your Helpdesk
$ 99 Monthly / Server
  • Unlimited Support Plan
  • 24/7 Emergency Phone
  • Chat Support for Admin
  • Separate Account Manager
  • NDA & SLA
  • SLA Review Meetings
  • FREE Consultancy Services
  • Simple SignUp Process
  • Instant Account Activation
  •  

Platinum Support

24/7 Proactive Support
$ 49 Monthly / Server
  • Unlimited Support Plan
  • 24/7 Emergency Phone
  • Chat Support for Admin
  • Separate Account Manager
  • Advance Proactive Monitoring
  • Guaranteed SLA
  • SLA Review Meetings
  • 3rd Party Application Support
  • FREE Consultancy Services
  • Server Migration Support
  • Weekly Status Report
  • No End User Support
Popular

Unlimited Support

24/7 Support

$ 30 Monthly / Server
  • Unlimited Support Plan
  • 24/7 Support
  • Basic Monitoring
  • 30 Minutes Response Time
  • 4 Hours Resolution time for the Possible Issues
  • Security and Performance Optimization
  • React to Customers queries
  • Simple SignUp Process
  • Instant Account Activation
  • No Third party application support
  • No Migration and End User Support

Cpanel Server Management Plans

Premium Support

24/7 End User Support from your Helpdesk

$ 99 Monthly / Server
  • 24/7 End User White Label Support
  • Unlimited Number of Tickets
  • Chat Support for Admin
  • Separate Account Manager
  • Guaranteed SLA
  • Weekly Status Reports
  • FREE Consultancy Services
  • Simple SignUp Process
  • Instant Account Activation

Platinum Support

24/7 Proactive Server Management
$ 49 Monthly / Server
  • Unlimited Support Plan
  • 24/7 Emergency Phone
  • Chat Support for Admin
  • Separate Account Manager
  • Advance Proactive Monitoring
  • Guaranteed SLA
  • SLA Review Meetings
  • 3rd Party Application Support
  • FREE Consultancy Services
  • Server Migration Support
  • Weekly Status Report
  • No End User Support
Popular

Unlimited Support

24/7 Server Management

$ 29 Monthly / Server
  • Unlimited Admin Tasks
  • 24/7 Support
  • Basic Monitoring
  • 30 Minutes Response time
  • 4 hours Response time for possible issues
  • Security and Performance Optimization
  • React to Customers queries
  • No Third party application support
  • No Migration and End User Support

Cpanel Server Management Plans

Premium Support

24/7 End User Support from your Helpdesk

$ 99 Monthly / Server
  • 24/7 End User White Label Support
  • Unlimited Number of Tickets
  • Chat Support for Admin
  • Separate Account Manager
  • Guaranteed SLA
  • Weekly Status Reports
  • FREE Consultancy Services
  • Simple SignUp Process
  • Instant Account Activation

Platinum Support

24/7 Proactive Server Management
$ 49 Monthly / Server
  • Unlimited Support Plan
  • 24/7 Emergency Phone
  • Chat Support for Admin
  • Separate Account Manager
  • Advance Proactive Monitoring
  • Guaranteed SLA
  • SLA Review Meetings
  • 3rd Party Application Support
  • FREE Consultancy Services
  • Server Migration Support
  • Weekly Status Report
  • No End User Support
Popular

Unlimited Support

24/7 Server Management

$ 29 Monthly / Server
  • Unlimited Admin Tasks
  • 24/7 Support
  • Basic Monitoring
  • 30 Minutes Response time
  • 4 hours Response time for possible issues
  • Security and Performance Optimization
  • React to Customers queries
  • No Third party application support
  • No Migration and End User Support