Completek8s Classroomnotes 22/Aug/2023

Backup and restore etcd

  • Process for backing up etcd cluster
    Preview

Backup etcd

  • Create some k8s deployment
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
  labels:
    app: nginx
spec:
  replicas: 3
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:1.14.2
        ports:
        - containerPort: 80

Preview
* check etcdctl version

etcdctl version

Preview
* Etcd pod is deployed as a Pod in kube-sytem namespace
Preview
* Lets describe pod kubectl describe pod etcd-controlplane -n kube-system
Preview
* Refer Here for official docs
* Lets create a snapshot

sudo ETCDCTL_API=3 etcdctl --cacert=/etc/kubernetes/pki/etcd/ca.crt \
    --cert=/etc/kubernetes/pki/etcd/server.crt \
    --key=/etc/kubernetes/pki/etcd/server.key \
    snapshot save /opt/etcd-backup.db

Preview

Restore etcd

  • command to restore the snapshot
sudo ETCDCTL_API=3 etcdctl --data-dir=/var/lib/from-backup snapshot restore /opt/etcd-backup.db
  • Change the manifest file in /etc/manifests to point to new location

Published
Categorized as Uncategorized Tagged

By continuous learner

devops & cloud enthusiastic learner

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Please turn AdBlock off
Social Media Icons Powered by Acurax Web Design Company

Discover more from Direct DevOps from Quality Thought

Subscribe now to keep reading and get access to the full archive.

Continue reading

Visit Us On FacebookVisit Us On LinkedinVisit Us On Youtube