apiVersion: v1
kind: Service
metadata:
  name: discov
  namespace: discovery
spec:
  ports:
    - name: discov-port
      port: 2379
      protocol: TCP
      targetPort: 2379
  selector:
    app: discov

---

apiVersion: v1
kind: Pod
metadata:
  labels:
    app: discov
    discov_node: discov0
  name: discov0
  namespace: discovery
spec:
  containers:
    - command:
        - /usr/local/bin/etcd
        - --name
        - discov0
        - --initial-advertise-peer-urls
        - http://discov0:2380
        - --listen-peer-urls
        - http://0.0.0.0:2380
        - --listen-client-urls
        - http://0.0.0.0:2379
        - --advertise-client-urls
        - http://discov0:2379
        - --initial-cluster
        - discov0=http://discov0:2380,discov1=http://discov1:2380,discov2=http://discov2:2380,discov3=http://discov3:2380,discov4=http://discov4:2380
        - --initial-cluster-state
        - new
      image: registry-vpc.cn-hangzhou.aliyuncs.com/xapp/etcd:latest
      name: discov0
      ports:
        - containerPort: 2379
          name: client
          protocol: TCP
        - containerPort: 2380
          name: server
          protocol: TCP
  imagePullSecrets:
    - name: aliyun
  affinity:
    podAntiAffinity:
      requiredDuringSchedulingIgnoredDuringExecution:
        - labelSelector:
            matchExpressions:
              - key: app
                operator: In
                values:
                  - discov
          topologyKey: "kubernetes.io/hostname"
  restartPolicy: Always

---

apiVersion: v1
kind: Service
metadata:
  labels:
    discov_node: discov0
  name: discov0
  namespace: discovery
spec:
  ports:
    - name: client
      port: 2379
      protocol: TCP
      targetPort: 2379
    - name: server
      port: 2380
      protocol: TCP
      targetPort: 2380
  selector:
    discov_node: discov0

---

apiVersion: v1
kind: Pod
metadata:
  labels:
    app: discov
    discov_node: discov1
  name: discov1
  namespace: discovery
spec:
  containers:
    - command:
        - /usr/local/bin/etcd
        - --name
        - discov1
        - --initial-advertise-peer-urls
        - http://discov1:2380
        - --listen-peer-urls
        - http://0.0.0.0:2380
        - --listen-client-urls
        - http://0.0.0.0:2379
        - --advertise-client-urls
        - http://discov1:2379
        - --initial-cluster
        - discov0=http://discov0:2380,discov1=http://discov1:2380,discov2=http://discov2:2380,discov3=http://discov3:2380,discov4=http://discov4:2380
        - --initial-cluster-state
        - new
      image: registry-vpc.cn-hangzhou.aliyuncs.com/xapp/etcd:latest
      name: discov1
      ports:
        - containerPort: 2379
          name: client
          protocol: TCP
        - containerPort: 2380
          name: server
          protocol: TCP
  imagePullSecrets:
    - name: aliyun
  affinity:
    podAntiAffinity:
      requiredDuringSchedulingIgnoredDuringExecution:
        - labelSelector:
            matchExpressions:
              - key: app
                operator: In
                values:
                  - discov
          topologyKey: "kubernetes.io/hostname"
  restartPolicy: Always

---

apiVersion: v1
kind: Service
metadata:
  labels:
    discov_node: discov1
  name: discov1
  namespace: discovery
spec:
  ports:
    - name: client
      port: 2379
      protocol: TCP
      targetPort: 2379
    - name: server
      port: 2380
      protocol: TCP
      targetPort: 2380
  selector:
    discov_node: discov1

---

apiVersion: v1
kind: Pod
metadata:
  labels:
    app: discov
    discov_node: discov2
  name: discov2
  namespace: discovery
spec:
  containers:
    - command:
        - /usr/local/bin/etcd
        - --name
        - discov2
        - --initial-advertise-peer-urls
        - http://discov2:2380
        - --listen-peer-urls
        - http://0.0.0.0:2380
        - --listen-client-urls
        - http://0.0.0.0:2379
        - --advertise-client-urls
        - http://discov2:2379
        - --initial-cluster
        - discov0=http://discov0:2380,discov1=http://discov1:2380,discov2=http://discov2:2380,discov3=http://discov3:2380,discov4=http://discov4:2380
        - --initial-cluster-state
        - new
      image: registry-vpc.cn-hangzhou.aliyuncs.com/xapp/etcd:latest
      name: discov2
      ports:
        - containerPort: 2379
          name: client
          protocol: TCP
        - containerPort: 2380
          name: server
          protocol: TCP
  imagePullSecrets:
    - name: aliyun
  affinity:
    podAntiAffinity:
      requiredDuringSchedulingIgnoredDuringExecution:
        - labelSelector:
            matchExpressions:
              - key: app
                operator: In
                values:
                  - discov
          topologyKey: "kubernetes.io/hostname"
  restartPolicy: Always

---

apiVersion: v1
kind: Service
metadata:
  labels:
    discov_node: discov2
  name: discov2
  namespace: discovery
spec:
  ports:
    - name: client
      port: 2379
      protocol: TCP
      targetPort: 2379
    - name: server
      port: 2380
      protocol: TCP
      targetPort: 2380
  selector:
    discov_node: discov2

---

apiVersion: v1
kind: Pod
metadata:
  labels:
    app: discov
    discov_node: discov3
  name: discov3
  namespace: discovery
spec:
  containers:
    - command:
        - /usr/local/bin/etcd
        - --name
        - discov3
        - --initial-advertise-peer-urls
        - http://discov3:2380
        - --listen-peer-urls
        - http://0.0.0.0:2380
        - --listen-client-urls
        - http://0.0.0.0:2379
        - --advertise-client-urls
        - http://discov3:2379
        - --initial-cluster
        - discov0=http://discov0:2380,discov1=http://discov1:2380,discov2=http://discov2:2380,discov3=http://discov3:2380,discov4=http://discov4:2380
        - --initial-cluster-state
        - new
      image: registry-vpc.cn-hangzhou.aliyuncs.com/xapp/etcd:latest
      name: discov3
      ports:
        - containerPort: 2379
          name: client
          protocol: TCP
        - containerPort: 2380
          name: server
          protocol: TCP
  imagePullSecrets:
    - name: aliyun
  affinity:
    podAntiAffinity:
      requiredDuringSchedulingIgnoredDuringExecution:
        - labelSelector:
            matchExpressions:
              - key: app
                operator: In
                values:
                  - discov
          topologyKey: "kubernetes.io/hostname"
  restartPolicy: Always

---

apiVersion: v1
kind: Service
metadata:
  labels:
    discov_node: discov3
  name: discov3
  namespace: discovery
spec:
  ports:
    - name: client
      port: 2379
      protocol: TCP
      targetPort: 2379
    - name: server
      port: 2380
      protocol: TCP
      targetPort: 2380
  selector:
    discov_node: discov3

---

apiVersion: v1
kind: Pod
metadata:
  labels:
    app: discov
    discov_node: discov4
  name: discov4
  namespace: discovery
spec:
  containers:
    - command:
        - /usr/local/bin/etcd
        - --name
        - discov4
        - --initial-advertise-peer-urls
        - http://discov4:2380
        - --listen-peer-urls
        - http://0.0.0.0:2380
        - --listen-client-urls
        - http://0.0.0.0:2379
        - --advertise-client-urls
        - http://discov4:2379
        - --initial-cluster
        - discov0=http://discov0:2380,discov1=http://discov1:2380,discov2=http://discov2:2380,discov3=http://discov3:2380,discov4=http://discov4:2380
        - --initial-cluster-state
        - new
      image: registry-vpc.cn-hangzhou.aliyuncs.com/xapp/etcd:latest
      name: discov4
      ports:
        - containerPort: 2379
          name: client
          protocol: TCP
        - containerPort: 2380
          name: server
          protocol: TCP
  imagePullSecrets:
    - name: aliyun
  affinity:
    podAntiAffinity:
      requiredDuringSchedulingIgnoredDuringExecution:
        - labelSelector:
            matchExpressions:
              - key: app
                operator: In
                values:
                  - discov
          topologyKey: "kubernetes.io/hostname"
  restartPolicy: Always

---

apiVersion: v1
kind: Service
metadata:
  labels:
    discov_node: discov4
  name: discov4
  namespace: discovery
spec:
  ports:
    - name: client
      port: 2379
      protocol: TCP
      targetPort: 2379
    - name: server
      port: 2380
      protocol: TCP
      targetPort: 2380
  selector:
    discov_node: discov4
