unip-controller/controller/templates/repository/delete-robots-tokens-secrets-job.yaml
2025-04-15 20:56:15 +03:00

50 lines
1.7 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# ============================================================
# Система: Единая библиотека, Центр ИИ НИУ ВШЭ
# Модуль: Repository
# Авторы: Полежаев В.А., Хританков А.С.
# Дата создания: 2025 г.
# ============================================================
apiVersion: batch/v1
kind: CronJob
metadata:
name: {{ job_name }}
namespace: {{ namespace }}
spec:
schedule: "{{ schedule }}"
jobTemplate:
spec:
template:
spec:
containers:
- name: delete-robots-token-secret
image: bitnami/kubectl:1.32.3
imagePullPolicy: IfNotPresent
env:
- name: NAMESPACE
value: {{ secrets_namespace }}
- name: LABEL
value: {{ secrets_label }}
command:
- /bin/sh
- -c
- |-
secrets=$(kubectl get secret -o jsonpath='{.items[*].metadata.name}' -n $NAMESPACE -l $LABEL)
if [ -z "${secrets}" ]; then
echo "No secrets with label '$LABEL' found"
exit
fi
for secret in $secrets; do
result=$(kubectl delete secret $secret -n $NAMESPACE 2>&1)
result_code=$?
if [ $result_code -eq "0" ]; then
echo "Secret $NAMESPACE.$secret deleted";
else
echo "Secret $NAMESPACE.$secret not deleted. $result";
fi
done
resources:
limits:
memory: 64M
cpu: 100m
restartPolicy: OnFailure