kubectl port-forward
kubectl port-forward is a command in Kubernetes that allows you to create a secure tunnel between a local computer and a Kubernetes pod, allowing you to access a service running on the pod using your local computer's browser or command line.
The syntax for the command is as follows:
kubectl port-forward <pod-name> <local-port>:<pod-port>
Where:
<pod-name>: the name of the pod you want to forward the port for<local-port>: the port on your local computer that you want to use to access the pod's service<pod-port>: the port on the pod that the service is running on
For example, to forward port 8080 on your local computer to port 80 on a pod named my-app, you would run the following command:
kubectl port-forward my-app 8080:80
Once the command is running, you can access the service running on the pod by opening your web browser and navigating to http://localhost:8080
原文地址: https://www.cveoy.top/t/topic/cQRT 著作权归作者所有。请勿转载和采集!