Installing Heptio-Ark (disaster recovery solution for Kubernetes) store data on local
Heptio ark gives you tools to backup and restore your Kubernetes cluster resources and persistent volume.
git clone https://github.com/sachinar/ark.git
Install ark command on kubernetes master with the help following link.
wget https://github.com/heptio/ark/releases/download/v0.9.1/ark-v0.9.1-linux-amd64.tar.gztar -xvf ark-v0.9.1-linux-amd64.tar.gzmv ark /usr/bin/ark
Now go in directory ark/minio & check file 10-minio-deployment.yaml nodeAffinity is defined in file. Change value from worker1 to node label, so that this data will be store on that node.
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: node
operator: In
values:
- worker1
This worker1 have to change.
Now deploy this directory in kubernetes cluster using,
kubectl create -f minio/
Now see it is deployed or not using,
kubectl get pods -n heptio-ark
Here heptio-ark is namespace where ark deployment is deployed.
Use to see where minio service is running,
kubectl get svc -n heptio-ark
Check NodePort where it is running & access using NodeIP.
Now for taking backup:-
Let’s consider deployment or statefulset is running in kubernetes.
This is an example of mongodb, where it is running as a statefulset,
kubectl annotate pod/mongo-0 backup.ark.heptio.com/backup-volumes=datadir
Annotate pods in kubernetes deployment or in statefulset using this command.
Here datadir is volume where deployment/statefulset are storing data.
Now take backup using command.
ark backup create mongo-backup --selector app=mongo --snapshot-volumes
To check volume details,
ark backup describe mongo-backup --volume-details
Here it will show the output of In-progress/Completed/Failed.
To check logs of backup,
ark backup logs mongo-backup
Now for Restoring backup:-
Use this
ark restore create mongo-restore --from-backup mongo-backup
Here it need from which backup we are restoring backup.
To check status,
ark restore describe mongo-restore --volume-details
To check restore logs,
ark restore logs mongo-restore