Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
kind: ServiceAccount
apiVersion: v1
metadata:
name: restart-deploy
namespace: testns
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: restart-deployment
namespace: testns
rules:
- apiGroups: ["apps", "extensions"]
resources: ["deployments"]
resourceNames: ["test-pod"]
verbs: ["get", "patch", "list", "watch"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: restart-deployment
namespace: prod
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: restart-deployment
subjects:
- kind: ServiceAccount
name: restart-deployment
namespace: testns
---
apiVersion: batch/v1
kind: CronJob
metadata:
name: restart-deployment
namespace: testns
spec:
successfulJobsHistoryLimit: 1
failedJobsHistoryLimit: 2
concurrencyPolicy: Forbid
schedule: '0 * * * *'
jobTemplate:
spec:
backoffLimit: 2
activeDeadlineSeconds: 600
template:
spec:
serviceAccountName: restart-deployment
restartPolicy: Never
containers:
- name: kubectl
image: bitnami/kubectl
command:
- 'kubectl'
- 'rollout'
- 'restart'
- 'deployment/test'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment