Skip to content

Commit

Permalink
Add periodic task to kill the worker pod
Browse files Browse the repository at this point in the history
  • Loading branch information
suever committed Sep 4, 2022
1 parent 0eb1354 commit 04808d2
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
26 changes: 26 additions & 0 deletions ops/templates/cronjob/cronjob.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
apiVersion: batch/v1
kind: CronJob
metadata:
name: worker-restart
namespace: matl-online
spec:
concurrencyPolicy: Forbid
schedule: '0 * * * *'
jobTemplate:
spec:
backoffLimit: 2
activeDeadlineSeconds: 600
template:
spec:
serviceAccountName: worker-restart
restartPolicy: Never
containers:
- name: kubectl
image: bitnami/kubectl
command:
- 'kubectl'
- 'rollout'
- 'restart'
- '-n'
- 'matl-online'
- 'deployment/worker'
30 changes: 30 additions & 0 deletions ops/templates/cronjob/rbac.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
kind: ServiceAccount
apiVersion: v1
metadata:
name: worker-restart
namespace: matl-online
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: worker-restart
namespace: matl-online
rules:
- apiGroups: ["apps", "extensions"]
resources: ["deployments"]
resourceNames: ["worker"]
verbs: ["get", "patch", "list", "watch"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: worker-restart
namespace: matl-online
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: worker-restart
subjects:
- kind: ServiceAccount
name: worker-restart
namespace: matl-online

0 comments on commit 04808d2

Please sign in to comment.