简体   繁体   English

Kubernetes公开Docker接口IP

[英]Kubernetes is exposing docker interface ip

I could create a kubernetes deployment and create a service with type loadbalancer. 我可以创建一个kubernetes部署,并创建一个类型为loadbalancer的服务。 When i describe the pods with kubectl i get the information that my containers are binded to my docker interface. 当我用kubectl描述吊舱时,我得到的信息是我的容器已绑定到我的docker接口。 I cant access them and dont wont to route the call of the eth0 interface ip to docker interface ip. 我无法访问它们,也不会将eth0接口ip的调用路由到docker接口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. 我只想访问我的应用程序并测试kubernetes作为负载均衡器和自动缩放器的行为。

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

It looks like kubectl port-forward can help you. 看起来kubectl port-forward可以为您提供帮助。 If you need to reach only a single endpoint (pod) behind the service, you can use one of these: 如果您只需要到达服务后面的单个端点(pod),则可以使用以下之一:

$ 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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM