K8S service配置文件注意点

kind: Service
apiVersion: v1
metadata:
  name: redis-exporter-svc
  namespace: redis-exporter
  labels:
    app: redis-exporter

spec:
  ports:
    - name: http
      protocol: TCP
      port: 9121
      targetPort: 9121
  selector:
    app: redis
  clusterIP: 169.253.141.119
  type: ClusterIP

  注意selector下面的app:的标签 一定要和pod里的标签一致

spec:
  replicas: 1
  selector:
    matchLabels:
      app: redis
  template:
    metadata:
      creationTimestamp: null
      labels:
        app: redis

 

posted on 2024-06-28 11:14  MaXianZhe  阅读(3)  评论(0编辑  收藏  举报

导航