service的yaml文件中type的位置

这里的type一定要和selector对齐,而不是和app:web对齐,如果和后者对齐,生成的service的类型还是ClusterIP(service/web2就出现这个问题),而不是NodePort

apiVersion: v1
kind: Service
metadata:
  creationTimestamp: null
  labels:
    app: web
  name: web3
spec:
  ports:
  - port: 80
    protocol: TCP
    targetPort: 80
  selector:
    app: web
  type: NodePort
status:
  loadBalancer: {}

posted @ 2022-10-16 17:28  cnhkzyy  阅读(23)  评论(0编辑  收藏  举报