2022-12-25:etcd可以完全替代zookeeper,原因是k8s用的etcd,不用担心不成熟。请问etcd部署在k3s中,yaml如何写?
Posted 福大大架构师每日一题
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了2022-12-25:etcd可以完全替代zookeeper,原因是k8s用的etcd,不用担心不成熟。请问etcd部署在k3s中,yaml如何写?相关的知识,希望对你有一定的参考价值。
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
以上是关于2022-12-25:etcd可以完全替代zookeeper,原因是k8s用的etcd,不用担心不成熟。请问etcd部署在k3s中,yaml如何写?的主要内容,如果未能解决你的问题,请参考以下文章