All posts

Mastering Kubernetes Internal Ports with kubectl

In Kubernetes, kubectl internal port commands can save you time, reduce errors, and help you debug faster—if you know exactly how to use them. Most people only scratch the surface, but understanding how to work with service ports, target ports, and container ports lets you control traffic flow inside your cluster with precision. When you define a Service in Kubernetes, the port is the entry point other Pods use to talk to it. The targetPort is the port on the container that actually receives th

Free White Paper

Kubernetes RBAC + Internal Developer Platforms (IDP): The Complete Guide

Architecture patterns, implementation strategies, and security best practices. Delivered to your inbox.

Free. No spam. Unsubscribe anytime.

In Kubernetes, kubectl internal port commands can save you time, reduce errors, and help you debug faster—if you know exactly how to use them. Most people only scratch the surface, but understanding how to work with service ports, target ports, and container ports lets you control traffic flow inside your cluster with precision.

When you define a Service in Kubernetes, the port is the entry point other Pods use to talk to it. The targetPort is the port on the container that actually receives the traffic. The nodePort—if used—opens it up outside the cluster. The internal port is what binds them together inside the cluster, invisible to the public but essential for your applications to talk to each other.

To see the internal ports at a glance, this command is your friend:

kubectl get svc

It lists the cluster IP, the port mapping, and lets you check that what you deployed matches what you expect.

For deeper inspection, run:

Continue reading? Get the full guide.

Kubernetes RBAC + Internal Developer Platforms (IDP): Architecture Patterns & Best Practices

Free. No spam. Unsubscribe anytime.
kubectl describe svc <service-name>

This shows every port, protocol, selector, and endpoint connected to that Service. It’s the quickest way to debug when two services can’t talk—often, it’s because the internal port or targetPort is wrong or mismatched.

If you need to test live connectivity, kubectl port-forward is your direct tunnel into a Pod from your machine:

kubectl port-forward svc/<service-name> <local-port>:<internal-port>

This is invaluable for validating internal ports and seeing responses without exposing anything to the outside world.

A reliable workflow with kubectl and internal ports means you can deploy, verify, and scale without guessing. It keeps environments consistent and lets cluster communication flow with zero confusion.

You can try these exact port management workflows in a running cluster without waiting—spin up a Kubernetes environment on hoop.dev and see it live in minutes.

Get started

See hoop.dev in action

One gateway for every database, container, and AI agent. Deploy in minutes.

Get a demoMore posts