Skip to content

Commit

Permalink
adding a cronjob to restart OLM pods (#2376)
Browse files Browse the repository at this point in the history
  • Loading branch information
manish-jangra authored Sep 8, 2023
1 parent 0f3db0b commit e733ba7
Show file tree
Hide file tree
Showing 7 changed files with 79 additions and 2 deletions.
32 changes: 32 additions & 0 deletions components/sandbox/base/olm-restart/cronjob.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@

apiVersion: batch/v1
kind: CronJob
metadata:
name: olm-restart
spec:
schedule: "0 2 * * *"
concurrencyPolicy: "Replace"
startingDeadlineSeconds: 200
suspend: false
successfulJobsHistoryLimit: 3
failedJobsHistoryLimit: 1
jobTemplate:
spec:
template:
metadata:
labels:
provider: "codeready-toolchain"
spec:
serviceAccountName: sandbox-sre-olm-restart-sa
containers:
- name: olm-restart
image: quay.io/codeready-toolchain/oc-client-base:latest
imagePullPolicy: IfNotPresent
command:
- /bin/sh
- -c
- echo "Restarting OLM..." &&
oc delete pod --all -n openshift-operator-lifecycle-manager --ignore-not-found --wait &&
oc delete pod --all -n openshift-marketplace --ignore-not-found --wait &&
echo "Completed restart"
restartPolicy: OnFailure
5 changes: 5 additions & 0 deletions components/sandbox/base/olm-restart/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- cronjob.yaml
- sandbox-sre-olm-restart.yaml
32 changes: 32 additions & 0 deletions components/sandbox/base/olm-restart/sandbox-sre-olm-restart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: sandbox-sre-olm-restart-sa
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: restart-pods
rules:
- apiGroups:
- ""
resources:
- "pods"
verbs:
- "get"
- "watch"
- "list"
- "delete"
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: olm-restart-global
subjects:
- kind: ServiceAccount
name: sandbox-sre-olm-restart-sa
roleRef:
kind: ClusterRole
name: restart-pods
apiGroup: rbac.authorization.k8s.io
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namespace: toolchain-host-operator
resources:
- ../../base
- ../../base/olm-restart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ../../base
- ../base
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ../../base
- ../base
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namespace: toolchain-member-operator
resources:
- ../../base
- ../../base/olm-restart
- ./rbac/inspect-pods.yaml

0 comments on commit e733ba7

Please sign in to comment.