Port-Forward
Expose a Pod or Service to a local port for quick debugging.
kubectl port-forward is great for local debugging. It forwards a cluster port to your machine.
Common usage
kubectl port-forward svc/api 8080:80
kubectl port-forward pod/api-7c9d8d9c8c-abcde 8080:80
When to use
- Quick API testing
- Local UI access
- Temporary troubleshooting
Notes
- Not for production traffic
- Switch the local port if there is a conflict
Practical notes
- Start with a quick inventory:
kubectl get nodes,kubectl get pods -A, andkubectl get events -A. - Compare desired vs. observed state;
kubectl describeusually explains drift or failed controllers. - Keep names, labels, and selectors consistent so Services and controllers can find Pods.
Quick checklist
- The resource matches the intent you described in YAML.
- Namespaces, RBAC, and images are correct for the target environment.
- Health checks and logs are in place before promotion.