Skip to content

Latest commit

 

History

History
71 lines (60 loc) · 1.61 KB

03 - .etcd.md

File metadata and controls

71 lines (60 loc) · 1.61 KB

ETCD

  • ETCD stores info from:

    • Nodes
    • PODs
    • Configs
    • Secrets
    • Accounts
    • Roles
    • Bindings
    • Others...
  • Some commands:

    • etcdctl snapshot save /path/bkp.db
    • etcdctl endpoint health
    • etcdctl get
    • etcdctl put
  • bkp and restore:

    • ./backup-restore.md
  • to check if the conf is external:

    • go to /etc/kubernetes/manifests/
    • open the file kube-apiserver.yaml
      • and look for --etcd-servers=https://some-ip:2379
  • Check conf from a etcd-server:

    • ps -ef | grep etcd
  • List Cluster Nodes:

    export ETCDCTL_API=3
    etcdctl \
        --endpoints=https://127.0.0.1:2379 \
        --cert=/etc/etcd/pki/etcd.pem \
        --key=/etc/etcd/pki/etcd-key.pem  \
        --cacert=/etc/etcd/pki/ca.pem \
        member list
    

Backup and Restore

  • Backup:

    export ETCDCTL_API=3 
    etcdctl --endpoints $ENDPOINTS \
      --cert=/etc/kubernetes/pki/etcd/server.crt \
      --key=/etc/kubernetes/pki/etcd/server.key \
      --cacert=/etc/kubernetes/pki/etcd/ca.crt \
      snapshot save <output>
    
  • Restore:

    export ETCDCTL_API=3 
    etcdctl --endpoints $ENDPOINTS \
      --cert=/etc/kubernetes/pki/etcd/server.crt \
      --key=/etc/kubernetes/pki/etcd/server.key \
      --cacert=/etc/kubernetes/pki/etcd/ca.crt \
      --data-dir=/var/lib/etcd-my-bkp \
      snapshot restore <output>
    
    • Go to /etc/kubernetes/manifests/etcd.yaml, edit it and change the Volume with ETCD path to the new one(--data-dir) /var/lib/etcd-my-bkp, save it and wait some time.
      • Example:
        - hostPath:
          path: /var/lib/etcd-my-bkp # here
          type: DirectoryOrCreate