Riaan's SysAdmin Blog

My tips, howtos, gotchas, snippets and stuff. Use at your own risk!

KubernetesUncategorized

kubectl export

Since kubectl --export is deprecated it is possible to do something like this.

WARNING: I have not tested this

#!/bin/bash
d=$(date +%Y%m%d)
BACKUP_TARGET="/TANK/ARCHIVE/argocd-backups/argocd_backup_yaml"
kubectl -n argocd get cm -o=json | jq 'del(.metadata.resourceVersion,.metadata.uid,.metadata.selfLink,.metadata.creationTimestamp,.metadata.annotations,.metadata.generation,.metadata.ownerReferences,.status)' | yq eval . --prettyPrint > $BACKUP_TARGET
kubectl -n argocd get secrets -o=json | jq 'del(.metadata.resourceVersion,.metadata.uid,.metadata.selfLink,.metadata.creationTimestamp,.metadata.annotations,.metadata.generation,.metadata.ownerReferences,.status)' | yq eval . --prettyPrint >> $BACKUP_TARGET 
kubectl -n argocd get app -o=json | jq 'del(.metadata.resourceVersion,.metadata.uid,.metadata.selfLink,.metadata.creationTimestamp,.metadata.annotations,.metadata.generation,.metadata.ownerReferences,.status)' | yq eval . --prettyPrint >> $BACKUP_TARGET 
kubectl -n argocd get appproj -o=json | jq 'del(.metadata.resourceVersion,.metadata.uid,.metadata.selfLink,.metadata.creationTimestamp,.metadata.annotations,.metadata.generation,.metadata.ownerReferences,.status)' | yq eval . --prettyPrint >> $BACKUP_TARGET

admin

Bio Info for Riaan