Jump to content

Any CKA experts


Recommended Posts

Posted

ETCD restore process
Hearing mixed/alternate answers. What could be the right process thats needs to performed. Can anyone help this out to find out the exact process

First create a snapshot of the existing etcd instance running at https://127.0.0.1:2379
. Next, restore an existing, previous snapshot located at /var/lib/backup/etcd-snapshotprevious.db

The Following TLS certificates/key are supplied for connecting to the server with etcdctl:

- CA Certificate: /opt/KUIN00601/ca.crt

- Client Certificate: /opt/KUIN00601/etcd-client.crt

- Client Key: /opt/KUIN00601/etcd-client.key

Answer 1:ETCDCTL_API=3 etcdctl --endpoints="https://127.0.0.1:2379
" --cacert=/opt/KUIN000601/ca.crt --cert=/opt/KUIN000601/etcd-client.crt --key=/opt/KUIN000601/etcd-client.key --data-dir=/var/lib/etcd snapshot restore /var/lib/backup/etcd-snapshotprevious.db

Answer 2:sudo -ik get pods -A -n kube-systemETCDCTL_API=3 etcdctl --endpoints="https://127.0.0.1:2379
" --cacert=/opt/KUIN000601/ca.crt --cert=/opt/KUIN000601/etcd-client.crt --key=/opt/KUIN000601/etcd-client.key --data-dir=/var/lib/etcd-backup snapshot restore /var/lib/backup/etcd-snapshotprevious.db

sudo systemctl restart etcd.service

sudo chown -R etcd:etcd /var/lib/etcd-backupcat /etc/kubernetes/manifests/etcd.yaml | grep -i '/var/lib/etcd'change the current path to /var/lib/etcd-backup

etcd pods wiill get restarted and shows as running

Posted

i am not expert in CKA... (i did only CKAD...)

but naa acloudguru lab nunchi copy paste chestunna...

 

Backing up and Restoring Kubernetes Data in etcd

Introduction

Backups are an important part of any resilient system. Kubernetes is no exception. In this lab, you will have the opportunity to practice your skills by backing up and restoring a Kubernetes cluster state stored in etcd. This will help you get comfortable with the steps involved in backing up Kubernetes data.

Solution

Log in to the provided lab server using the credentials provided:

ssh cloud_user@<PUBLIC_IP_ADDRESS>

Back Up the etcd Data

  1. Look up the value for the key cluster.name in the etcd cluster:

    ETCDCTL_API=3 etcdctl get cluster.name \
      --endpoints=https://10.0.1.101:2379 \
      --cacert=/home/cloud_user/etcd-certs/etcd-ca.pem \
      --cert=/home/cloud_user/etcd-certs/etcd-server.crt \
      --key=/home/cloud_user/etcd-certs/etcd-server.key
    

    The returned value should be beebox.

  2. Back up etcd using etcdctl and the provided etcd certificates:

    ETCDCTL_API=3 etcdctl snapshot save /home/cloud_user/etcd_backup.db \
      --endpoints=https://10.0.1.101:2379 \
      --cacert=/home/cloud_user/etcd-certs/etcd-ca.pem \
      --cert=/home/cloud_user/etcd-certs/etcd-server.crt \
      --key=/home/cloud_user/etcd-certs/etcd-server.key
    
  3. Reset etcd by removing all existing etcd data:

    sudo systemctl stop etcd
    
    sudo rm -rf /var/lib/etcd
    

Restore the etcd Data from the Backup

  1. Restore the etcd data from the backup (this command spins up a temporary etcd cluster, saving the data from the backup file to a new data directory in the same location where the previous data directory was):

    sudo ETCDCTL_API=3 etcdctl snapshot restore /home/cloud_user/etcd_backup.db \
      --initial-cluster etcd-restore=https://10.0.1.101:2380 \
      --initial-advertise-peer-urls https://10.0.1.101:2380 \
      --name etcd-restore \
      --data-dir /var/lib/etcd
    
  2. Set ownership on the new data directory:

    sudo chown -R etcd:etcd /var/lib/etcd
    
  3. Start etcd:

    sudo systemctl start etcd
    
  4. Verify the restored data is present by looking up the value for the key cluster.name again:

    ETCDCTL_API=3 etcdctl get cluster.name \
      --endpoints=https://10.0.1.101:2379 \
      --cacert=/home/cloud_user/etcd-certs/etcd-ca.pem \
      --cert=/home/cloud_user/etcd-certs/etcd-server.crt \
      --key=/home/cloud_user/etcd-certs/etcd-server.key
    

    The returned value should be beebox.

Conclusion

Congratulations on successfully completing this hands-on lab!

 


 

  • Upvote 1
Posted
9 minutes ago, dasari4kntr said:

i am not expert in CKA... (i did only CKAD...)

but naa acloudguru lab nunchi copy paste chestunna...

 

Backing up and Restoring Kubernetes Data in etcd

Introduction

Backups are an important part of any resilient system. Kubernetes is no exception. In this lab, you will have the opportunity to practice your skills by backing up and restoring a Kubernetes cluster state stored in etcd. This will help you get comfortable with the steps involved in backing up Kubernetes data.

Solution

Log in to the provided lab server using the credentials provided:

ssh cloud_user@<PUBLIC_IP_ADDRESS>

Back Up the etcd Data

  1. Look up the value for the key cluster.name in the etcd cluster:

    ETCDCTL_API=3 etcdctl get cluster.name \
      --endpoints=https://10.0.1.101:2379 \
      --cacert=/home/cloud_user/etcd-certs/etcd-ca.pem \
      --cert=/home/cloud_user/etcd-certs/etcd-server.crt \
      --key=/home/cloud_user/etcd-certs/etcd-server.key
    

    The returned value should be beebox.

  2. Back up etcd using etcdctl and the provided etcd certificates:

    ETCDCTL_API=3 etcdctl snapshot save /home/cloud_user/etcd_backup.db \
      --endpoints=https://10.0.1.101:2379 \
      --cacert=/home/cloud_user/etcd-certs/etcd-ca.pem \
      --cert=/home/cloud_user/etcd-certs/etcd-server.crt \
      --key=/home/cloud_user/etcd-certs/etcd-server.key
    
  3. Reset etcd by removing all existing etcd data:

    sudo systemctl stop etcd
    
    sudo rm -rf /var/lib/etcd
    

Restore the etcd Data from the Backup

  1. Restore the etcd data from the backup (this command spins up a temporary etcd cluster, saving the data from the backup file to a new data directory in the same location where the previous data directory was):

    sudo ETCDCTL_API=3 etcdctl snapshot restore /home/cloud_user/etcd_backup.db \
      --initial-cluster etcd-restore=https://10.0.1.101:2380 \
      --initial-advertise-peer-urls https://10.0.1.101:2380 \
      --name etcd-restore \
      --data-dir /var/lib/etcd
    
  2. Set ownership on the new data directory:

    sudo chown -R etcd:etcd /var/lib/etcd
    
  3. Start etcd:

    sudo systemctl start etcd
    
  4. Verify the restored data is present by looking up the value for the key cluster.name again:

    ETCDCTL_API=3 etcdctl get cluster.name \
      --endpoints=https://10.0.1.101:2379 \
      --cacert=/home/cloud_user/etcd-certs/etcd-ca.pem \
      --cert=/home/cloud_user/etcd-certs/etcd-server.crt \
      --key=/home/cloud_user/etcd-certs/etcd-server.key
    

    The returned value should be beebox.

Conclusion

Congratulations on successfully completing this hands-on lab!

 


Thank you ba.. but in exam if we remove the etcd directory then it might be an issue ani thinking

 

Posted
2 hours ago, spiral25 said:

 

There is no harm in deleting etcd directory. Final one you need is from backup folder.

Don't try to do the backup on the etcd node (127.0.0.1). Use worker node with remote IP of etcd node.

Posted
2 hours ago, vithanda_vadhi said:

There is no harm in deleting etcd directory. Final one you need is from backup folder.

Don't try to do the backup on the etcd node (127.0.0.1). Use worker node with remote IP of etcd node.

Ardam kaledu bro..

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...