Kubernetes中使用CronJob定时备份etcd集群数据
生活随笔
收集整理的這篇文章主要介紹了
Kubernetes中使用CronJob定时备份etcd集群数据
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
2019獨角獸企業(yè)重金招聘Python工程師標(biāo)準(zhǔn)>>>
Kubernetes中使用CronJob定時備份etcd集群數(shù)據(jù)
- 注意:這里的內(nèi)容已經(jīng)過時!
- 使用kubernetes1.12.3和etcd3.2.24請參考 Kubernetes的etcd探秘-狀態(tài)數(shù)據(jù)備份 。
kubernetes中部署的應(yīng)用的信息都存放在etcd里面,這里面的數(shù)據(jù)非常重要,需要備份,以備不時之需。
這里使用k8s提供的定時任務(wù)來執(zhí)行備份任務(wù),定時任務(wù)的pod要和etcd的pod要在同一個node上面(使用nodeAffinity)。
要求
- kubernetes 1.6
- etcd 3.0.17
yaml文件
apiVersion: batch/v2alpha1 kind: CronJob metadata:name: etcd-disaster-recoverynamespace: cron spec:schedule: "0 22 * * *"jobTemplate:spec:template:metadata:labels:app: etcd-disaster-recoveryspec:affinity:nodeAffinity:requiredDuringSchedulingIgnoredDuringExecution:nodeSelectorTerms:- matchExpressions:- key: kubernetes.io/roleoperator: Invalues:- mastercontainers:- name: etcdimage: coreos/etcd:v3.0.17command:- sh- -c- "export ETCDCTL_API=3; \etcdctl --endpoints $ENDPOINT snapshot save /snapshot/$(date +%Y%m%d_%H%M%S)_snapshot.db; \echo etcd backup sucess"env:- name: ENDPOINTvalue: "127.0.0.1:2379"volumeMounts:- mountPath: "/snapshot"name: snapshotsubPath: data/etcd-snapshot- mountPath: /etc/localtimename: lt-config- mountPath: /etc/timezonename: tz-configrestartPolicy: OnFailurevolumes:- name: snapshotpersistentVolumeClaim:claimName: cron-nas- name: lt-confighostPath:path: /etc/localtime- name: tz-confighostPath:path: /etc/timezonehostNetwork: true?
參考
- https://v1-6.docs.kubernetes.io/docs/concepts/workloads/controllers/cron-jobs/
- https://coreos.com/etcd/docs/3.0.17/op-guide/recovery.html
- Kubernetes Master節(jié)點 災(zāi)備恢復(fù)操作指南,https://yq.aliyun.com/articles/561894
- Kubernetes 備份,https://my.oschina.net/u/2306127/blog/2032463
轉(zhuǎn)載于:https://my.oschina.net/u/2306127/blog/2032457
總結(jié)
以上是生活随笔為你收集整理的Kubernetes中使用CronJob定时备份etcd集群数据的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 9.特殊权限 软连接 硬链接
- 下一篇: [洛谷P3829][SHOI2012]信