-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added cronjob for deleting failed flinkdeployments
- Loading branch information
Showing
1 changed file
with
35 additions
and
0 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
src/templates/flink-k8s-operator/cleanup-finished-deployments.yaml
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
{{- $originalContext := . -}} | ||
{{- with .Values.enterprise -}} | ||
{{- with .flinkK8sOperatorDeploymentManager -}} | ||
{{- if .enabled }} | ||
{{- if not (and (hasKey . "disableCleanupOfFinishedDeployments") (.disableCleanupOfFinishedDeployments)) }} | ||
apiVersion: batch/v1 | ||
kind: CronJob | ||
metadata: | ||
name: cleanup-finished-deployments | ||
labels: | ||
{{ include "nussknacker.labels" $originalContext | nindent 4 }} | ||
spec: | ||
schedule: "*/10 * * * *" # Run every 10 minutes | ||
jobTemplate: | ||
spec: | ||
template: | ||
spec: | ||
containers: | ||
- name: cleanup | ||
image: bitnami/kubectl:latest | ||
command: | ||
- /bin/sh | ||
- "-c" | ||
- | | ||
kubectl get flinkdeployments -o json | jq -r ' | ||
.items[] | | ||
select(.status.jobStatus.state == "FAILED" or | ||
(.status.jobStatus.state == "FINISHED" and .status.lifecycleState == "STABLE")) | | ||
.metadata.name' | | ||
xargs -r kubectl delete flinkdeployment | ||
restartPolicy: Never | ||
{{- end }} | ||
{{- end }} | ||
{{- end }} | ||
{{- end }} |