美文网首页云原生
31-Service-无头服务(Headless Service

31-Service-无头服务(Headless Service

作者: 紫荆秋雪_文 | 来源:发表于2022-02-05 09:56 被阅读0次

    一、使用Deployment启动3个Pod

    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name:  deployment-nginx-raven
      namespace: raven
      labels:
        app:  deployment-nginx-raven
    spec:
      selector:
        matchLabels:
          appt: raven-nginx
      replicas: 3
      template: # 定义 Pod
        metadata:
          labels:
            appt:  raven-nginx
        spec:
          containers:
          - name:  raven-nginx-container
            image:  nginx:1.16.1
    
    • 启动Pod标签为 appt: raven-nginx

    二、Service-yaml

    apiVersion: v1
    kind: Service
    metadata:
      name: svc-02
      namespace: raven
    spec:
      selector:
        appt: raven-nginx
      type: ClusterIP
      clusterIP: None
      ports:
      - name: http
        protocol: TCP
        port: 80
        targetPort: 80
    
    无头Service.png
    • 通过访问服务名来访问集群 image.png

    相关文章

      网友评论

        本文标题:31-Service-无头服务(Headless Service

        本文链接:https://www.haomeiwen.com/subject/coehkrtx.html