Create resources declaratively and backup the yaml files in git
Taking immediate backup of all resources:
kubectl get all -A -o yaml > all-resources.yaml
restore:
kubectl apply -f all-resources.yaml
use Velero (previously ARK) by HeptIO for other resource-components
Method 2: backup etcd data In etc service configuration, check the etcd Data Dir. back it up.
Also, edctd Snapshot
etcdctl snapshot save snapshot.db
Restore
service kube-apiserve stop
--data-dir /etc/restored-etcd-dir --initial-cluster master=http://masterip:port \
--initial-cluster-token etcd-cluster-new \
--initial-advertise-peer-urls https://${INTERNAL_IP}:2380
# etcd.service
# add two lines
--initial-cluster-token etcd-cluster-new \
--data-dir /etc/restored-etcd-dir
systemctl daemon-reload
service etcd restart
service kube-apiserve start