How to expose a Kubernetes service on a specific Nodeport?

后端 未结 6 2081
不思量自难忘°
不思量自难忘° 2021-02-07 00:04

I have create a pod with the below yaml definition.

apiVersion: v1
kind: Pod
metadata:
  name: myapp-pod
  labels:
    app: myapp
spec:
  containers:
  - name: m         


        
6条回答
  •  终归单人心
    2021-02-07 00:21

    If your cluster does not have a LoadBalancer Provider, you can specify externalIPs in IP of nodes' network interface.

    For example:

    apiVersion: v1
    kind: Service
    metadata:
      name: nginx
    spec:   
      type: ClusterIP
      externalIPs:
        - 125.100.99.101 # Node1-IP
        - 125.100.99.102 # Node2-IP
        - 192.168.55.112 # Node2-IP2
      selector:
        pod: nginx
      ports:
        - name: http
          port: 80      
        - name: https
          port: 443      
    

    This will listen 80 and 443 on the specified node, and forward to the nginx service.

提交回复
热议问题