Last active
April 22, 2024 15:03
-
-
Save cmwylie19/2c07e0e6f0962b8f18999488d1646a4a to your computer and use it in GitHub Desktop.
Runs every 30 mins. If watch connections are being dropped after some time, this is a workaround to reconnect every so often. NOTE: use --force at your own discretion.
This file contains 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
apiVersion: v1 | |
kind: ServiceAccount | |
metadata: | |
name: watch-recycle-sa | |
namespace: pepr-system | |
--- | |
kind: Role | |
apiVersion: rbac.authorization.k8s.io/v1 | |
metadata: | |
namespace: pepr-system | |
name: watch-recycle-role | |
rules: | |
- apiGroups: [""] | |
resources: ["pods"] | |
verbs: ["delete","list"] | |
--- | |
kind: RoleBinding | |
apiVersion: rbac.authorization.k8s.io/v1 | |
metadata: | |
name: watch-recycle-binding | |
namespace: pepr-system | |
subjects: | |
- kind: ServiceAccount | |
name: watch-recycle-sa | |
roleRef: | |
kind: Role | |
name: watch-recycle-role | |
apiGroup: rbac.authorization.k8s.io | |
--- | |
apiVersion: batch/v1 | |
kind: CronJob | |
metadata: | |
name: pod-deleter-job | |
namespace: pepr-system | |
spec: | |
schedule: "*/30 * * * *" | |
jobTemplate: | |
spec: | |
template: | |
spec: | |
serviceAccountName: watch-recycle-sa | |
restartPolicy: OnFailure | |
containers: | |
- name: kubectl-container | |
image: bitnami/kubectl | |
command: | |
- /bin/bash | |
- -c | |
- > | |
kubectl delete po --force --grace-period=0 -n pepr-system -l 'pepr.dev/controller=watcher' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment