I'm looking for a bash script that could backup all the kubernetes in a yaml format or json it's good too:) I already backup the kubernetes conf files already.
/etc/kubernetes
/etc/systemd/system/system/kubelet.service.d
etc...
Now I'm just looking to save the
namespaces
deployment
etc...
try the below command. you can include all the namespaces that you want to backup
mkdir -p /root/k8s-backup
kubectl cluster-info dump --namespaces default,kube-system --output-directory=/root/k8s-backup
You can dump your entire cluster info into one file using:
kubectl cluster-info dump > cluster_dump.txt
The above command will dump all the yaml and container logs into one file
Or if you just want yaml files, you can write a script of some commands which includes
kubectl get deployment -o yaml > deployment.yaml
kubectl get statefulset -o yaml > statefulset.yaml
kubectl get daemonset -o yaml > daemonset.yaml
Then you have to keep the namespace also in mind while creating the script. This gives you fair idea what to do