K8S安装etcd

K8S安装etcd

apiVersion: v1
kind: Service
metadata:
  name: etcd-cluster
  
spec:
  ports:
  - name: etcd-client-port
    port: 2379
    protocol: TCP
    targetPort: 2379
  selector:
    app: etcd

---

apiVersion: v1
kind: Pod
metadata:
  labels:
    app: etcd
    etcd_node: etcd0
  name: etcd0  
spec:
  affinity:
 
  containers:
  - command:
    - /usr/local/bin/etcd
    - --name
    - etcd0
    - --auto-compaction-retention=10
    - --auto-compaction-mode=revision
    - --initial-advertise-peer-urls
    - http://etcd0:2380
    - --listen-peer-urls
    - http://0.0.0.0:2380
    - --listen-client-urls
    - http://0.0.0.0:2379
    - --advertise-client-urls
    - http://etcd0:2379
    - --initial-cluster
    - etcd0=http://etcd0:2380,etcd1=http://etcd1:2380,etcd2=http://etcd2:2380
    - --initial-cluster-state
    - new
    image: quay.io/coreos/etcd:latest
    name: etcd0
    env:
    - name: ETCDCTL_API
      value: "3"
    resources:
      requests:
        cpu: "0.1"
        memory: 100Mi
    ports:
    - containerPort: 2379
      name: client
      protocol: TCP
    - containerPort: 2380
      name: server
      protocol: TCP
  restartPolicy: Always

---

apiVersion: v1
kind: Service
metadata:
  labels:
    etcd_node: etcd0
  name: etcd0
  
spec:
  ports:
  - name: client
    port: 2379
    protocol: TCP
    targetPort: 2379
  - name: server
    port: 2380
    protocol: TCP
    targetPort: 2380
  selector:
    etcd_node: etcd0

---

apiVersion: v1
kind: Pod
metadata:
  labels:
    app: etcd
    etcd_node: etcd1
  name: etcd1
  
spec:
  affinity:
 
  containers:
  - command:
    - /usr/local/bin/etcd
    - --name
    - etcd1
    - --auto-compaction-retention=10
    - --auto-compaction-mode=revision
    - --initial-advertise-peer-urls
    - http://etcd1:2380
    - --listen-peer-urls
    - http://0.0.0.0:2380
    - --listen-client-urls
    - http://0.0.0.0:2379
    - --advertise-client-urls
    - http://etcd1:2379
    - --initial-cluster
    - etcd0=http://etcd0:2380,etcd1=http://etcd1:2380,etcd2=http://etcd2:2380
    - --initial-cluster-state
    - new
    image: quay.io/coreos/etcd:latest
    name: etcd1
    env:
    - name: ETCDCTL_API
      value: "3"
    resources:
      requests:
        cpu: "0.1"
        memory: 100Mi
    ports:
    - containerPort: 2379
      name: client
      protocol: TCP
    - containerPort: 2380
      name: server
      protocol: TCP
  restartPolicy: Always

---

apiVersion: v1
kind: Service
metadata:
  labels:
    etcd_node: etcd1
  name: etcd1
  
spec:
  ports:
  - name: client
    port: 2379
    protocol: TCP
    targetPort: 2379
  - name: server
    port: 2380
    protocol: TCP
    targetPort: 2380
  selector:
    etcd_node: etcd1

---

apiVersion: v1
kind: Pod
metadata:
  labels:
    app: etcd
    etcd_node: etcd2
  name: etcd2
  
spec:
  affinity:
 
  containers:
  - command:
    - /usr/local/bin/etcd
    - --name
    - etcd2
    - --auto-compaction-retention=10
    - --auto-compaction-mode=revision
    - --initial-advertise-peer-urls
    - http://etcd2:2380
    - --listen-peer-urls
    - http://0.0.0.0:2380
    - --listen-client-urls
    - http://0.0.0.0:2379
    - --advertise-client-urls
    - http://etcd2:2379
    - --initial-cluster
    - etcd0=http://etcd0:2380,etcd1=http://etcd1:2380,etcd2=http://etcd2:2380
    - --initial-cluster-state
    - new
    image: quay.io/coreos/etcd:latest
    name: etcd2
    env:
    - name: ETCDCTL_API
      value: "3"
    resources:
      requests:
        cpu: "0.1"
        memory: 100Mi
    ports:
    - containerPort: 2379
      name: client
      protocol: TCP
    - containerPort: 2380
      name: server
      protocol: TCP
  restartPolicy: Always

---

apiVersion: v1
kind: Service
metadata:
  labels:
    etcd_node: etcd2
  name: etcd2
  
spec:
  ports:
  - name: client
    port: 2379
    protocol: TCP
    targetPort: 2379
  - name: server
    port: 2380
    protocol: TCP
    targetPort: 2380
  selector:
    etcd_node: etcd2

posted @ 2023-01-09 14:15  小星奕的快乐  阅读(115)  评论(0)    收藏  举报