Last active
May 14, 2019 16:20
-
-
Save stang/4c7ee4c7f58aef94b286b727435dd522 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
#!/bin/bash | |
EXISTING_PG_CLUSTERS=$(kubectl get pg --all-namespaces -o json |jq '[.items[]|{name: .metadata.name}[]]') | |
CLUSTER_NAME_LABEL="cluster-name" | |
kubectl get svc --all-namespaces -l application=spilo -o json \ | |
| jq -r --argjson EXISTING_PG_CLUSTERS "${EXISTING_PG_CLUSTERS}" \ | |
--arg CLUSTER_NAME_LABEL "${CLUSTER_NAME_LABEL}" \ | |
' | |
.items[] | |
|. as $x | |
|select($EXISTING_PG_CLUSTERS|(index($x.metadata.labels[$CLUSTER_NAME_LABEL])|not)) | |
|"kubectl -n " + .metadata.namespace + " delete svc " + .metadata.name | |
' \ | |
> patroni-headless-svc-config-cleanup.sh |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment