Merge commit 'fe564d72279f4ab061b961dd528623f0ed272667' as 'cluster-config'

This commit is contained in:
2025-03-30 15:46:16 -05:00
346 changed files with 11754 additions and 0 deletions

View File

@@ -0,0 +1,3 @@
Cronjob that periodically removes completed jobs, based on KCS here:
https://access.redhat.com/solutions/6934861

View File

@@ -0,0 +1,40 @@
apiVersion: batch/v1
kind: CronJob
metadata:
name: completed-pod-cleanup
spec:
jobTemplate:
metadata:
name: completed-pod-cleanup
spec:
template:
spec:
containers:
- command:
- /bin/bash
- -c
- |
set -euo pipefail
echo "// Listed Completed Pod."
oc get pods -o wide --all-namespaces --sort-by='{.metadata.creationTimestamp}','{.metadata.namespace}','{.metadata.name}' --field-selector=status.phase==Succeeded
COMPLETED_POD=`oc get pods -o jsonpath="{range .items[*]}{.metadata.namespace}{'\t'}{.metadata.name}{'\n'}{end}" --all-namespaces --field-selector=metadata.namespace!=ocp-completed-pod-cleanup,status.phase==Succeeded`
if [ -n "$COMPLETED_POD" ]; then
echo "// Deleted Completed Pod."
while read NS_NAME POD_NAME
do
oc -n $NS_NAME delete pod $POD_NAME;
done <<< "$COMPLETED_POD"
fi
image: registry.redhat.io/openshift4/ose-cli:latest # change the image in disconnected environment
imagePullPolicy: IfNotPresent
name: completed-pod-cleanup
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
dnsPolicy: ClusterFirst
restartPolicy: OnFailure
serviceAccount: completed-pod-cleanup
serviceAccountName: completed-pod-cleanup
terminationGracePeriodSeconds: 30
schedule: "0 11 * * *"
suspend: false
status: {}

View File

@@ -0,0 +1,6 @@
namespace: clean-completed-pods
resources:
- namespace.yaml
- clean-completed-pods-cronjob.yaml
- sa-rbac.yaml

View File

@@ -0,0 +1,4 @@
apiVersion: v1
kind: Namespace
metadata:
name: clean-completed-pods

View File

@@ -0,0 +1,31 @@
kind: ServiceAccount
apiVersion: v1
metadata:
name: completed-pod-cleanup
labels:
app: completed-pod-cleanup
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: cluster-completed-pod-cleanup
rules:
- apiGroups: [""]
resources:
- "pods"
verbs: ["get", "list", "create", "delete", "watch"]
---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: completed-pod-cleanup
labels:
app: completed-pod-cleanup
subjects:
- kind: ServiceAccount
name: completed-pod-cleanup
namespace: clean-completed-pods
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: cluster-completed-pod-cleanup