Last active
May 30, 2022 11:28
-
-
Save dewe/89a9368b4242a1070f9a7fdbf1c6b2e2 to your computer and use it in GitHub Desktop.
kubectl-cronjob-restarter.yaml
This file contains hidden or 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: restarter-job | |
namespace: podinfo | |
--- | |
kind: Role | |
apiVersion: rbac.authorization.k8s.io/v1 | |
metadata: | |
name: restarter-job | |
namespace: podinfo | |
rules: | |
- apiGroups: | |
- apps | |
resources: | |
- deployments | |
verbs: ["get", "patch"] | |
--- | |
kind: RoleBinding | |
apiVersion: rbac.authorization.k8s.io/v1 | |
metadata: | |
name: restarter-job | |
namespace: podinfo | |
subjects: | |
- kind: ServiceAccount | |
name: restarter-job | |
namespace: podinfo | |
roleRef: | |
kind: Role | |
name: restarter-job | |
apiGroup: "" | |
--- | |
apiVersion: batch/v1 | |
kind: CronJob | |
metadata: | |
name: restarter | |
spec: | |
schedule: '0 2 * * *' | |
jobTemplate: | |
metadata: | |
name: restarter | |
spec: | |
template: | |
spec: | |
restartPolicy: OnFailure | |
serviceAccountName: restarter-job | |
containers: | |
- name: kubectl | |
image: bitnami/kubectl:1.24.1 | |
command: | |
- /bin/sh | |
- -c | |
- kubectl rollout restart deployment podinfo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment