Kubernetes - services without selector

前端 未结 3 1810
忘掉有多难
忘掉有多难 2021-01-21 02:10

I\'m struggling with Kubernetes\' service without a selector. The cluster is installed on AWS with the kops. I have a deployment with 3 nginx pods exposing port 80:



        
3条回答
  •  耶瑟儿~
    2021-01-21 02:56

    As @iliefa mentioned in his comment above, the below part of the definition is treated as labels in this type of cases.

    ports:
        - port: 80
          name: http
    

    In your scenario, we need to either remove 'name: http' as mentioned by @iliefa or we need to add 'name: http' under 'ports:' in the service definition as you can spot below.

    apiVersion: v1
    kind: Service
    metadata:
      name: dummy-svc
      labels:
        app: nginx
    spec:
     ports:
        - protocol: TCP
          port: 80
          targetPort: 80
          name: http
    

提交回复
热议问题