Skip to content

Instantly share code, notes, and snippets.

@spy86
Created May 8, 2022 08:20
Show Gist options
  • Save spy86/6cd3e6c3aa851069d436dfe2a86cd512 to your computer and use it in GitHub Desktop.
Save spy86/6cd3e6c3aa851069d436dfe2a86cd512 to your computer and use it in GitHub Desktop.
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