创建 svc 不指定 selector

    1. apiVersion: v1
    2. kind: Service
    3. metadata:
    4. name: svc-myapp-dep
    5. spec:
    6. clusterIP: 10.11.0.180
    7. ports:
    8. - port: 80
    9. protocol: TCP
    10. targetPort: 80
    11. # selector:
    12. # app: myapp-dep

    svc 创建成功 但是没有实际 pod
    image.png

    创建 endpoint , 名字要与 svc 一致

    apiVersion: v1
    kind: Endpoints
    metadata:
      name: svc-myapp-dep
    subsets:
    - addresses:
      - ip: 1.1.1.1
      - ip: 1.1.1.2
      - ip: 1.1.1.3
      ports:
      - port: 80
        protocol: TCP
    

    image.png

    image.png