Last active
August 30, 2022 11:13
-
-
Save kirederik/b1d5e00b2f80f045d7279e651dbd7f29 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
PLATFORM_CONTEXT="${PLATFORM_CONTEXT:-"kind-platform"}" | |
WORKER_CONTEXT="${WORKER_CONTEXT:-"kind-worker"}" | |
# Delete minio deployment to wipe out the buckets | |
kubectl delete --context $PLATFORM_CONTEXT deployment minio --namespace kratix-platform-system | |
# Delete Kratix deployment to stop dynamic controllers | |
kubectl delete --context $PLATFORM_CONTEXT deployment -n kratix-platform-system kratix-platform-controller-manager | |
# Remove all kratix-related crds to remove all promises | |
kubectl delete --context $PLATFORM_CONTEXT crds \ | |
$(kubectl --context $PLATFORM_CONTEXT get crds --no-headers -o custom-columns=":metadata.name" | grep -e "kratix\|promise") | |
# Scale down postgres statefulset to zero -- tell k8s to remove the pods | |
kubectl scale --context $WORKER_CONTEXT statefulset \ | |
$(kubectl get --context $WORKER_CONTEXT statefulsets --selector application=spilo --no-headers -o custom-columns=":metadata.name") --replicas=0 | |
# Remove buckets from the worker | |
kubectl delete --all --context $WORKER_CONTEXT --namespace flux-system buckets.source.toolkit.fluxcd.io | |
kubectl delete --all --context $WORKER_CONTEXT --namespace flux-system kustomizations.kustomize.toolkit.fluxcd.io | |
# Remove all pipeline pods | |
kubectl delete --context $PLATFORM_CONTEXT pod \ | |
$(kubectl get --context $PLATFORM_CONTEXT pods --no-headers -o custom-columns=":metadata.name" | grep request-pipeline) | |
# Reinstall Kratix and re-register the worker cluster | |
kubectl apply --context $PLATFORM_CONTEXT -f https://raw.githubusercontent.com/syntasso/kratix/main/distribution/kratix.yaml | |
kubectl apply --context $PLATFORM_CONTEXT -f https://raw.githubusercontent.com/syntasso/kratix/main/hack/platform/minio-install.yaml | |
kubectl apply --context $PLATFORM_CONTEXT -f https://raw.githubusercontent.com/syntasso/kratix/main/config/samples/platform_v1alpha1_worker_cluster.yaml | |
kubectl apply --context $WORKER_CONTEXT -f https://raw.githubusercontent.com/syntasso/kratix/main/hack/worker/gitops-tk-install.yaml | |
kubectl apply --context $WORKER_CONTEXT -f https://raw.githubusercontent.com/syntasso/kratix/main/hack/worker/gitops-tk-resources.yaml | |
# Remove leftover postgres resources | |
kubectl delete --context $WORKER_CONTEXT statefulset \ | |
$(kubectl get --context $WORKER_CONTEXT statefulsets --selector application=spilo --no-headers -o custom-columns=":metadata.name") | |
kubectl delete --context $WORKER_CONTEXT services \ | |
$(kubectl get --context $WORKER_CONTEXT services --selector application=spilo --no-headers -o custom-columns=":metadata.name") | |
kubectl delete --context $WORKER_CONTEXT poddisruptionbudgets.policy \ | |
$(kubectl get --context $WORKER_CONTEXT poddisruptionbudgets.policy --selector application=spilo --no-headers -o custom-columns=":metadata.name") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment