How to open multiple ports using quaternet load balancing services

I created a cluster using the Google Cloud platform (container engine) and deployed the module using the following yaml file:

apiVersion: extensions/v1beta1
kind: Deployment
metadata: 
  name: deployment-name
spec:
  replicas: 1
  template:
    metadata:
      name: pod-name
      labels: 
        app: app-label
    spec:
      containers: 
      - name: container-name
      image: gcr.io/project-id/image-name
      resources:
        requests:
          cpu: 1
      ports:
      - name: port80
        containerPort: 80
      - name: port443
        containerPort: 443
      - name: port6001
        containerPort: 6001

Then I want to create a service that allows the module to listen on all these ports. I know that he is working on a yaml file to create a service that listens on a single port:

apiVersion: v1
kind: Service
metadata: 
  name: service-name
spec:    
  ports:
  - port: 80
    targetPort: 80
  selector: 
    app: app-label
  type: LoadBalancer

However, when I want the pod to listen on multiple ports like this, it does not work:

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

How can I connect a pod to multiple ports?

+6
source share
1 answer

You have two options:

  • , . , IP-.
  • . .

:

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

, .

+6

Source: https://habr.com/ru/post/1681623/


All Articles