Task:-> Restarting pod automatically at specific time.
cronjob not working fine after manually triger, getting error- like Saw a job that the controller did not create or forgot: vijay-deployment-restart-manual-a7s16 enter image description here enter image description hereenter image description here
once manually triger cronjob , job will start for restarting pod but getting this errors — Job has reached the specified backoff limitenter image description here enter image description here
current version :-
based on this version Client Version: v1.29.4
Kustomize Version: v5.0.4-0.20230601165947-6ce0bf390ce3
Server Version: v1.29.4-eks-036c24b
how to fix this.
kind: ServiceAccount
apiVersion: v1
metadata:
name: vijay-deployment-restart
namespace: odex
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: Vijay-deployment-restart
namespace: odex`your text`
rules:
- apiGroups: ["apps", "extensions"]
resources: ["deployments"]
resourceNames: ["odex-webapp-c88ae204"]
verbs: ["get", "patch", "list", "watch"] # "list" and "watch" are only needed
# if you want to use `rollout status`
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: Vijay-deployment-restart
namespace: odex
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: vijay-deployment-restart
subjects:
- kind: ServiceAccount
name: vijay-deployment-restart
namespace: odex
cronjob
apiVersion: batch/v1
kind: CronJob
metadata:
name: vijay-deployment-restart
namespace: od
spec:
concurrencyPolicy: Forbid
schedule: '48 10 * * *' # This will run daily at
jobTemplate:
spec:
backoffLimit: 3
activeDeadlineSeconds: 800
template:
spec:
serviceAccountName: vijay-deployment-restart
restartPolicy: Never
containers:
- name: kubectl
image: bitnami/kubectl:latest # Specify the version if needed
command:
- 'kubectl'
- 'rollout'
- 'restart'
- 'deployment/mango-deployment'
22m Normal Scheduled pod/vijay-deployment-restart-manual-a7s16-6kfm4 Successfully assigned odex/vijay-deployment-restart-manual-a7s16-6kfm4 to ip-
10-1-255-31.ap-south-1.compute.internal
22m Normal Pulling pod/vijay-deployment-restart-manual-a7s16-6kfm4 Pulling image “bitnami/kubectl:latest”
22m Normal Pulled pod/vijay-deployment-restart-manual-a7s16-6kfm4 Successfully pulled image “bitnami/kubectl:latest” in 1.481434024s (1.4814430
65s including waiting)
22m Normal Created pod/vijay-deployment-restart-manual-a7s16-6kfm4 Created container kubectl
22m Normal Started pod/vijay-deployment-restart-manual-a7s16-6kfm4 Started container kubectl
25m Normal Scheduled pod/vijay-deployment-restart-manual-a7s16-7b78g Successfully assigned odex/vijay-deployment-restart-manual-a7s16-7b78g to ip-
10-1-255-31.ap-south-1.compute.internal
25m Normal Pulling pod/vijay-deployment-restart-manual-a7s16-7b78g Pulling image “bitnami/kubectl:latest”
25m Normal Pulled pod/vijay-deployment-restart-manual-a7s16-7b78g Successfully pulled image “bitnami/kubectl:latest” in 1.506635384s (1.5066520
44s including waiting)
25m Normal Created pod/vijay-deployment-restart-manual-a7s16-7b78g Created container kubectl
25m Normal Started pod/vijay-deployment-restart-manual-a7s16-7b78g Started container kubectl
26m Normal Scheduled pod/vijay-deployment-restart-manual-a7s16-cnctx Successfully assigned odex/vijay-deployment-restart-manual-a7s16-cnctx to ip-
10-1-255-31.ap-south-1.compute.internal
26m Normal Pulling pod/vijay-deployment-restart-manual-a7s16-cnctx Pulling image “bitnami/kubectl:latest”
26m Normal Pulled pod/vijay-deployment-restart-manual-a7s16-cnctx Successfully pulled image “bitnami/kubectl:latest” in 1.436445321s (1.4364548
92s including waiting)
26m Normal Created pod/vijay-deployment-restart-manual-a7s16-cnctx Created container kubectl
26m Normal Started pod/vijay-deployment-restart-manual-a7s16-cnctx Started container kubectl
27m Normal Scheduled pod/vijay-deployment-restart-manual-a7s16-m98hb Successfully assigned odex/vijay-deployment-restart-manual-a7s16-m98hb to ip-
10-1-255-31.ap-south-1.compute.internal
27m Normal Pulling pod/vijay-deployment-restart-manual-a7s16-m98hb Pulling image “bitnami/kubectl:latest”
27m Normal Pulled pod/vijay-deployment-restart-manual-a7s16-m98hb Successfully pulled image “bitnami/kubectl:latest” in 1.49095318s (1.49096263
s including waiting)
27m Normal Created pod/vijay-deployment-restart-manual-a7s16-m98hb Created container kubectl
27m Normal Started pod/vijay-deployment-restart-manual-a7s16-m98hb Started container kubectl
27m Normal Scheduled pod/vijay-deployment-restart-manual-a7s16-twx82 Successfully assigned odex/vijay-deployment-restart-manual-a7s16-twx82 to ip-
10-1-255-31.ap-south-1.compute.internal
27m Normal Pulling pod/vijay-deployment-restart-manual-a7s16-twx82 Pulling image “bitnami/kubectl:latest”
27m Normal Pulled pod/vijay-deployment-restart-manual-a7s16-twx82 Successfully pulled image “bitnami/kubectl:latest” in 1.446334384s (1.4463481
54s including waiting)
27m Normal Created pod/vijay-deployment-restart-manual-a7s16-twx82 Created container kubectl
27m Normal Started pod/vijay-deployment-restart-manual-a7s16-twx82 Started container kubectl
27m Normal Scheduled pod/vijay-deployment-restart-manual-a7s16-zr894 Successfully assigned odex/vijay-deployment-restart-manual-a7s16-zr894 to ip-
10-1-255-31.ap-south-1.compute.internal
27m Normal Pulling pod/vijay-deployment-restart-manual-a7s16-zr894 Pulling image “bitnami/kubectl:latest”
27m Normal Pulled pod/vijay-deployment-restart-manual-a7s16-zr894 Successfully pulled image “bitnami/kubectl:latest” in 1.547233824s (1.5472634
65s including waiting)
27m Normal Created pod/vijay-deployment-restart-manual-a7s16-zr894 Created container kubectl
27m Normal Started pod/vijay-deployment-restart-manual-a7s16-zr894 Started container kubectl
27m Normal SuccessfulCreate job/vijay-deployment-restart-manual-a7s16 Created pod: vijay-deployment-restart-manual-a7s16-zr894
27m Normal SuccessfulCreate job/vijay-deployment-restart-manual-a7s16 Created pod: vijay-deployment-restart-manual-a7s16-twx82
27m Normal SuccessfulCreate job/vijay-deployment-restart-manual-a7s16 Created pod: vijay-deployment-restart-manual-a7s16-m98hb
26m Normal SuccessfulCreate job/vijay-deployment-restart-manual-a7s16 Created pod: vijay-deployment-restart-manual-a7s16-cnctx
25m Normal SuccessfulCreate job/vijay-deployment-restart-manual-a7s16 Created pod: vijay-deployment-restart-manual-a7s16-7b78g
22m Normal SuccessfulCreate job/vijay-deployment-restart-manual-a7s16 Created pod: vijay-deployment-restart-manual-a7s16-6kfm4
22m Warning BackoffLimitExceeded job/vijay-deployment-restart-manual-a7s16 Job has reached the specified backoff limit
22m Warning UnexpectedJob cronjob/vijay-deployment-restart Saw a job that the controller did not create or forgot: vijay-deployment-rest
art-manual-a7s16
PS C:UsersVijay.kumark8 yaml file>
how to fix this issue.
Vijaykumar Jawale is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.