Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save dehypnosis/45707b5b3176e22971da9a62e32d59eb to your computer and use it in GitHub Desktop.
Save dehypnosis/45707b5b3176e22971da9a62e32d59eb to your computer and use it in GitHub Desktop.
kubernetes remove old telepresence deployments
#!/usr/bin/env bash
kubectl get deploy --all-namespaces \
-l telepresence \
-o custom-columns=namespace:.metadata.namespace,name:.metadata.name,age:.metadata.creationTimestamp \
| awk -v yesterday=`date -u -v -1d +%FT%TZ` \
'{if ($3 < yesterday) system("kubectl delete deploy --grace-period=0 -n " $1 " " $2) }'
@dehypnosis
Copy link
Author

Modify below -1d to adjust age of deployments to remove.

yesterday=`date -u -v -1d +%FT%TZ`

@dehypnosis
Copy link
Author

dehypnosis commented Sep 18, 2019

Or deploy cronjob with docker image: https://github.com/dehypnosis/dockerfiles

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment