Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preview/cleaning up finished deployments #175

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions src/templates/flink-k8s-operator/cleanup-finished-deployments.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{{- $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:
serviceAccountName: {{ include "nussknacker.serviceAccountName" $originalContext }}
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 }}
Loading