2022-12-25:etcd可以完全替代zookeeper,原因是k8s用的etcd,不用担心不成熟

2022-12-25:etcd可以完全替代zookeeper,原因是k8s用的etcd,不用担心不成熟。请问etcd部署在k3s中,yaml如何写?

答案2022-12-25:

用户名:root
密码:moonfdd

yaml如下:

apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: etcd
  name: etcd
  namespace: moonfdd
spec:
  replicas: 1
  selector:
    matchLabels:
      app: etcd
  template:
    metadata:
      labels:
        app: etcd
    spec:
      containers:
        - env:
            - name: "ETCD_ROOT_PASSWORD"
              value: "moonfdd"
            - name: "ETCD_ADVERTISE_CLIENT_URLS"
              value: "http://0.0.0.0:2379"
            - name: "ETCD_LISTEN_PEER_URLS"
              value: "http://0.0.0.0:2380"
            - name: "ETCD_INITIAL_ADVERTISE_PEER_URLS"
              value: "http://0.0.0.0:2380"
            - name: "ETCD_INITIAL_CLUSTER"
              value: "moonfdd=http://0.0.0.0:2380"
            - name: "ETCD_NAME"
              value: "moonfdd"
            - name: "ETCD_DATA_DIR"
              value: "/opt/bitnami/etcd/data"
          image: bitnami/etcd
          securityContext:
            privileged: true
          imagePullPolicy: IfNotPresent
          name: etcd
          volumeMounts:
            - mountPath: /opt/bitnami/etcd/data
              name: volv2
      volumes:
        - hostPath:
            path: /root/k8s/moonfdd/etcd/opt/bitnami/etcd/data
            type: DirectoryOrCreate
          name: volv2
---
apiVersion: v1
kind: Service
metadata:
  labels:
    app: etcd
  name: etcd
  namespace: moonfdd
spec:
  ports:
    - port: 2379
      protocol: TCP
      targetPort: 2379
      name: 2379-2379
    - port: 2380
      protocol: TCP
      targetPort: 2380
      name: 2380-2380
  selector:
    app: etcd
  type: NodePort

在这里插入图片描述
在这里插入图片描述

在这里插入图片描述

本作品采用《CC 协议》,转载必须注明作者和本文链接
微信公众号:福大大架构师每日一题。最新面试题,涉及golang,rust,mysql,redis,云原生,算法,分布式,网络,操作系统。
讨论数量: 0
(= ̄ω ̄=)··· 暂无内容!

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!