定期defrag
apiVersion: batch/v1
kind: CronJob
metadata:
name: etcd-snapshot
namespace: kube-system
spec:
concurrencyPolicy: Forbid
failedJobsHistoryLimit: 1
jobTemplate:
metadata:
creationTimestamp: null
spec:
completions: 3
parallelism: 3
template:
metadata:
creationTimestamp: null
labels:
app: etcd-snapshot
spec:
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: node-role.kubernetes.io/master
operator: Exists
podAntiAffinity:
- requiredDuringSchedulingIgnoredDuringExecution:
labelSelector:
matchLabels:
app: etcd-snapshot
namespaces:
- kube-system
topologyKey: kubernetes.io/hostname
containers:
- command:
- sh
- -c
- ETCDCTL_API=3 etcdctl defrag --endpoints localhost:2379 --cert=/etc/kubernetes/pki/etcd/server.crt
--key=/etc/kubernetes/pki/etcd/server.key --cacert=/etc/kubernetes/pki/etcd/ca.crt
image: registry.cn-hangzhou.aliyuncs.com/google_containers/etcd:3.5.8
imagePullPolicy: IfNotPresent
name: etcd
resources: {}
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- mountPath: /snapshot
name: snapshot
subPath: backup
- mountPath: /etc/kubernetes
name: kubernetes
- mountPath: /etc/localtime
name: lt-localtime
- mountPath: /etc/timezone
name: timezone
dnsPolicy: ClusterFirst
hostNetwork: true
restartPolicy: OnFailure
schedulerName: default-scheduler
securityContext: {}
terminationGracePeriodSeconds: 30
tolerations:
- operator: Exists
volumes:
- hostPath:
path: /data
type: ""
name: snapshot
- hostPath:
path: /etc/localtime
type: ""
name: localtime
- hostPath:
path: /etc/timezone
type: ""
name: timezone
- hostPath:
path: /etc/kubernetes
type: ""
name: kubernetes
schedule: 0 */1 * * *
successfulJobsHistoryLimit: 3
suspend: false
定期snapshot
apiVersion: batch/v1
kind: CronJob
metadata:
name: etcd-defrag
namespace: kube-system
spec:
concurrencyPolicy: Forbid
failedJobsHistoryLimit: 1
jobTemplate:
metadata:
creationTimestamp: null
spec:
completions: 3
parallelism: 3
template:
metadata:
creationTimestamp: null
labels:
app: etcd-defrag
spec:
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: node-role.kubernetes.io/master
operator: Exists
podAntiAffinity:
- requiredDuringSchedulingIgnoredDuringExecution:
labelSelector:
matchLabels:
app: etcd-defrag
namespaces:
- kub-system
topologyKey: kubernetes.io/hostname
containers:
- command:
- sh
- -c
- ETCDCTL_API=3 etcdctl snapshot save /snapshot/etcd_snapshot.db --endpoints localhost:2379
--cert=/etc/kubernetes/pki/etcd/server.crt --key=/etc/kubernetes/pki/etcd/server.key
--cacert=/etc/kubernetes/pki/etcd/ca.crt
image: registry.cn-hangzhou.aliyuncs.com/google_containers/etcd:3.5.8
imagePullPolicy: IfNotPresent
name: etcd
resources: {}
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- mountPath: /snapshot
name: snapshot
subPath: backup
- mountPath: /etc/kubernetes
name: kubernetes
- mountPath: /etc/localtime
name: lt-localtime
- mountPath: /etc/timezone
name: timezone
dnsPolicy: ClusterFirst
hostNetwork: true
restartPolicy: OnFailure
schedulerName: default-scheduler
securityContext: {}
terminationGracePeriodSeconds: 30
tolerations:
- operator: Exists
volumes:
- hostPath:
path: /data
type: ""
name: snapshot
- hostPath:
path: /etc/localtime
type: ""
name: localtime
- hostPath:
path: /etc/timezone
type: ""
name: timezone
- hostPath:
path: /etc/kubernetes
type: ""
name: kubernetes
schedule: 0 */1 * * *
successfulJobsHistoryLimit: 3
suspend: false
网友评论