Skip to content

Commit

Permalink
tests: Cleanup logs in minikube VM after running k8s tests
Browse files Browse the repository at this point in the history
Signed-off-by: Aaron Wilson <[email protected]>
  • Loading branch information
aaronnw committed Jun 25, 2024
1 parent 0d915b0 commit 888da5d
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
29 changes: 29 additions & 0 deletions deploy/dev/k8s/kube_templates/cleanup_job_template.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
apiVersion: batch/v1
kind: Job
metadata:
name: "${JOB_NAME}"
spec:
ttlSecondsAfterFinished: 0
template:
spec:
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: kubernetes.io/hostname
operator: In
values:
- minikube
containers:
- name: delete-files
image: busybox
command: ["sh", "-c", "if [ -d ${HOST_PATH} ]; then rm -rf ${HOST_PATH}; fi"]
volumeMounts:
- name: host-volume
mountPath: "${PARENT_DIR}"
restartPolicy: Never
volumes:
- name: host-volume
hostPath:
path: "${PARENT_DIR}"
9 changes: 8 additions & 1 deletion deploy/dev/k8s/utils/cleanup_k8s_ci.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
# Kill all pods and services created by ci job and ignore errors
kubectl delete pods -l app=ais,type=ais-target || true
kubectl delete pods -l app=ais,type=ais-proxy || true
kubectl delete svc -l app=ais || true
kubectl delete svc -l app=ais || true

# Use a cleanup job to delete any AIS files mounted with hostpath inside the minikube vm
export PARENT_DIR="/tmp"
export HOST_PATH="/tmp/ais"
export JOB_NAME="test-cleanup"
envsubst < kube_templates/cleanup_job_template.yml > cleanup_job.yml
kubectl apply -f cleanup_job.yml

0 comments on commit 888da5d

Please sign in to comment.