How to expose multiple port using a load balancer services in kubernetes

被刻印的时光 ゝ 提交于 2019-11-30 18:18:14

You have two options:

  1. You could have multiple services, one for each port. As you pointed out, each service will end up with a different IP address
  2. You could have a single service with multiple ports. In this particular case, you must give all ports a name.

In your case, the service becomes:

apiVersion: v1
kind: Service
metadata:
  name: service-name
spec:
  ports:
  - name: http
    port: 80
    targetPort: 80
  - name: https
    port: 443
    targetPort: 443
  - name: something
    port: 6001
    targetPort: 6001
  selector:
    app: app-label
  type: LoadBalancer

This is necessary so that endpoints can be disambiguated.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!