云原生

31-Service-无头服务(Headless Service

2022-02-05  本文已影响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

二、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
上一篇下一篇

猜你喜欢

热点阅读