The data-restore is a custom kubernetes controller written in Go. Following are the key features of this controller:
- Watch on newly create CR(Snap, Restore).
- On Addition of custom(Snap) CR, it takes snapshot of PVC.
- On Addition of custom(restore) CR, it takes the backup the snapshot created into a new PVC.
Below instruction will help in setting up project locally as well as up and running in cluster:
To run the controller on Local System,need to install following Software Dependencies.
To run the data-restore controller on local machine:
- Open a terminal and run below commands:
go build
./data-restore
- Create a snapCR custom resource by following command:
cd manifests/kubectl create -f snapCR.yaml
- Create a restoreCR custom resource by following command:
cd manifests/kubectl create -f restoreCR.yaml
Start cluster and enable addon:
minikube start
minikube addons enable volumesnapshots
minikube addons enable csi-hostpath-driver
To run application on cluster:
- Dockerize application by writing Dockerfile. Build and push image to docker hub repository here.
- Create service account, clusterrole and clusterrolebinding to access custom resource and watch it by running following command:
cd manifests/kubectl create -f sa.yaml
cd manifests/kubectl create -f role.yaml
- Deploy the application by running following command:
cd manifests/kubectl create -f deployment.yaml
- exec into pod and run:
./data-restore
- https://pkg.go.dev/k8s.io/client-go
- https://pkg.go.dev/k8s.io/apimachinery
- https://pkg.go.dev/github.com/mitchellh/go-homedir
- https://minikube.sigs.k8s.io/docs/tutorials/volume_snapshots_and_csi/
- https://pkg.go.dev/github.com/kubernetes-csi/external-snapshotter/v6
- docker build -t data-restore:10.0.0 .
- docker tag data-restore:10.0.0 sultanasaima/data-restore:10.0.0
- docker push sultanasaima/data-restore:10.0.0