![]() Listen on ports 50 locally, forwarding data to/from ports 50 in a pod selected by the service kubectl port-forward service/myservice 5000 6000 Listen on ports 50 locally, forwarding data to/from ports 50 in a pod selected by the deployment kubectl port-forward deployment/mydeployment 5000 6000 Listen on ports 50 locally, forwarding data to/from ports 50 in the pod kubectl port-forward pod/mypod 5000 6000 Listen on port 8888 on localhost and selected IP, forwarding to 5000 in the pod kubectl port-forward -address localhost,10.19.21.23 pod/mypod 8888:5000 Listen on a random port locally, forwarding to 5000 in the pod kubectl port-forward pod/mypod :5000 Listen on port 8888 on all addresses, forwarding to 5000 in the pod kubectl port-forward -address 0.0.0.0 pod/mypod 8888:5000 Listen on port 8888 locally, forwarding to 5000 in the pod kubectl port-forward pod/mypod 8888:5000 To take things even further, you could even execute some preliminary tests to the pods you feel could be more error-prone right inside your CI/CD pipeline in Jenkins by using multiple conditions, declarative pipeline. This command is very useful for example in blue/green deployments where you would want to troubleshoot a misbehaving pod. The port-forward command, Forwards one (or more) local ports to a pod. Or kubectl port-forward svc/redis-master 6379:6379 Or kubectl port-forward rs/redis-master 6379:6379 Or kubectl port-forward deployment/redis-master 6379:6379 Which is the same as kubectl port-forward pods/redis-master-765d459796-258hz 6379:6379 Kubectl port-forward is useful for testing/debugging purposes so you can access your service locally without exposing it.īelow is the name of the pod and it will forward it's port 6379 to localhost:6379. Compared to kubectl proxy, kubectl port-forward is more generic as it can forward TCP traffic while kubectl proxy can only forward HTTP traffic. Kubectl port-forward forwards connections to a local port to a port on a pod. API server then becomes, in a sense, a temporary gateway between your local port and the Kubernetes cluster. Now, the port-forward feature of kubectl simply tunnels the traffic from a specified port at your local host machine to the specified port on the specified pod. To start, it's useful to note and remember that in Kubernetes, every pod gets its own ip address from 10.*, that is usable only within the cluster. ![]()
0 Comments
Leave a Reply. |