Kubernetes is exposing docker interface ip

10/13/2016

I could create a kubernetes deployment and create a service with type loadbalancer. When i describe the pods with kubectl i get the information that my containers are binded to my docker interface. I cant access them and dont wont to route the call of the eth0 interface ip to docker interface ip.

kubectl describe services
Name:           fpgra
Namespace:      default
Labels:         run=fpgra
Selector:       run=fpgra
Type:           LoadBalancer
IP:         10.254.138.121
Port:           <unset> 3000/TCP
NodePort:       <unset> 32547/TCP
Endpoints:      172.17.2.3:3033,172.17.30.2:3033
Session Affinity:   None
No events.

I just want to access my application and test the behaviour of kubernetes as load-balancer and automatic scaler.

This is how i created the service for exposing my application to make it reachable from extern:

kubectl expose deployment fpgra --port=3000 --target-port=3033 --type=LoadBalancer
-- hasan
kubernetes

1 Answer

4/12/2017

It looks like kubectl port-forward can help you. If you need to reach only a single endpoint (pod) behind the service, you can use one of these:

$ kubectl port-forward -h
Forward one or more local ports to a pod.

Examples:
  # Listen on ports 5000 and 6000 locally, forwarding data to/from ports 5000 and 6000 in the pod
  kubectl port-forward mypod 5000 6000

  # Listen on port 8888 locally, forwarding to 5000 in the pod
  kubectl port-forward mypod 8888:5000

  # Listen on a random port locally, forwarding to 5000 in the pod
  kubectl port-forward mypod :5000

  # Listen on a random port locally, forwarding to 5000 in the pod
  kubectl port-forward mypod 0:5000
-- AhmetB - Google
Source: StackOverflow