Skip to content

Commit

Permalink
Merge pull request #266 from AmpersandTarski/feature/delete_student_r…
Browse files Browse the repository at this point in the history
…esources_cronjob

Feature/delete student resources cronjob
  • Loading branch information
Michiel-s committed Apr 14, 2023
2 parents bc87951 + 3330d27 commit cf50756
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ kind: Deployment
metadata:
name: {{student}}
namespace: {{namespace}}
labels:
app: {{student}}
container-image: student-prototype
spec:
replicas: 1
selector:
Expand All @@ -13,6 +16,7 @@ spec:
metadata:
labels:
app: {{student}}
container-image: student-prototype
spec:
containers:
- name: {{student}}
Expand Down
20 changes: 10 additions & 10 deletions deployment/resources/elevated-rights-service-account.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,45 +3,45 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: rap4svcaccount
name: elevated-rights-service-account
namespace: rap
---
# # Role that is used to give a pod elevated rights in the Kubernetes cluster
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: modify-pods
name: elevated-rights-role
namespace: rap
rules:
- apiGroups: [""]
resources: ["pods"]
verbs: ["create", "delete", "get", "watch", "list"]
verbs: ["get", "watch", "list", "create", "delete", "patch"]
- apiGroups: ["networking.k8s.io"]
resources: ["ingresses"]
verbs: ["get", "watch", "list", "create"]
verbs: ["get", "watch", "list", "create", "delete", "patch"]
- apiGroups: [""]
resources: ["services"]
verbs: ["get", "watch", "list", "create"]
verbs: ["get", "watch", "list", "create", "delete", "patch"]
- apiGroups: [""]
resources: ["configmaps"]
verbs: ["get", "watch", "list", "create"]
verbs: ["get", "watch", "list", "create", "delete", "patch"]
- apiGroups: ["apps"]
resources: ["deployments"]
verbs: ["get", "watch", "list", "create"]
verbs: ["get", "watch", "list", "create", "delete", "patch"]

---
# # Role that is used to give a pod elevated rights in the Kubernetes cluster

apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: modifypods
name: elevated-rights-rolebinding
namespace: rap
subjects:
- kind: ServiceAccount
name: rap4svcaccount
name: elevated-rights-service-account
namespace: rap
roleRef:
kind: Role
name: modify-pods
name: elevated-rights-role
apiGroup: rbac.authorization.k8s.io
2 changes: 1 addition & 1 deletion deployment/resources/rap-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ spec:
labels:
app: rap
spec:
serviceAccountName: rap4svcaccount
serviceAccountName: elevated-rights-service-account
containers:
- image: ampersandrap.azurecr.io/ampersand-rap:2023-22-03-v5
name: ampersand-rap
Expand Down
40 changes: 40 additions & 0 deletions deployment/resources/student-prototype-cleanup.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
apiVersion: batch/v1
kind: CronJob
metadata:
name: student-prototype-cleanup
namespace: rap
spec:
schedule: "0 * * * *"
successfulJobsHistoryLimit: 1
failedJobsHistoryLimit: 1
jobTemplate:
spec:
template:
spec:
serviceAccountName: elevated-rights-service-account
containers:
- name: student-prototype-cleanup
image: bitnami/kubectl:latest
command:
- /bin/sh
- "-c"
- |
# loop all deployments with label: container-image=student-prototype
for deployment in $(kubectl get deployment -n rap -l container-image=student-prototype -o jsonpath='{.items[*].metadata.name}'); do
# calculate age in seconds
deployment_age=$(($(date +%s) - $(date +%s -d $(kubectl get deployment $deployment -n rap -o jsonpath='{.metadata.creationTimestamp}'))))
# delete deployment, service and ingress if age > 1 hour
if [ $deployment_age -gt 3600 ]; then
echo "Deleting deployment $deployment"
kubectl delete deployment $deployment -n rap
kubectl delete service $deployment -n rap
kubectl delete ingress $deployment-ingress -n rap
# TODO: delete database tables?
else
echo "Deployment $deployment is not older than 1 hour"
fi
done
envFrom:
- secretRef:
name: db-secrets
restartPolicy: OnFailure

648 comments on commit cf50756

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass %
1 0 0 1 100

Passed Tests

Name ⏱️ Duration Suite
Should be able to access the Home page 3.266 s RAPLive

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass %
1 0 0 1 100

Passed Tests

Name ⏱️ Duration Suite
Should be able to access the Home page 3.238 s RAPLive

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass %
1 0 0 1 100

Passed Tests

Name ⏱️ Duration Suite
Should be able to access the Home page 3.629 s RAPLive

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass %
1 0 0 1 100

Passed Tests

Name ⏱️ Duration Suite
Should be able to access the Home page 3.197 s RAPLive

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass %
1 0 0 1 100

Passed Tests

Name ⏱️ Duration Suite
Should be able to access the Home page 3.226 s RAPLive

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass %
1 0 0 1 100

Passed Tests

Name ⏱️ Duration Suite
Should be able to access the Home page 3.753 s RAPLive

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass %
1 0 0 1 100

Passed Tests

Name ⏱️ Duration Suite
Should be able to access the Home page 3.702 s RAPLive

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass %
1 0 0 1 100

Passed Tests

Name ⏱️ Duration Suite
Should be able to access the Home page 3.309 s RAPLive

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass %
1 0 0 1 100

Passed Tests

Name ⏱️ Duration Suite
Should be able to access the Home page 3.198 s RAPLive

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass %
1 0 0 1 100

Passed Tests

Name ⏱️ Duration Suite
Should be able to access the Home page 4.053 s RAPLive

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass %
1 0 0 1 100

Passed Tests

Name ⏱️ Duration Suite
Should be able to access the Home page 3.536 s RAPLive

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass %
1 0 0 1 100

Passed Tests

Name ⏱️ Duration Suite
Should be able to access the Home page 4.163 s RAPLive

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass %
1 0 0 1 100

Passed Tests

Name ⏱️ Duration Suite
Should be able to access the Home page 3.234 s RAPLive

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass %
1 0 0 1 100

Passed Tests

Name ⏱️ Duration Suite
Should be able to access the Home page 4.166 s RAPLive

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass %
1 0 0 1 100

Passed Tests

Name ⏱️ Duration Suite
Should be able to access the Home page 3.306 s RAPLive

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass %
1 0 0 1 100

Passed Tests

Name ⏱️ Duration Suite
Should be able to access the Home page 3.316 s RAPLive

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass %
1 0 0 1 100

Passed Tests

Name ⏱️ Duration Suite
Should be able to access the Home page 3.232 s RAPLive

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass %
1 0 0 1 100

Passed Tests

Name ⏱️ Duration Suite
Should be able to access the Home page 3.667 s RAPLive

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass %
1 0 0 1 100

Passed Tests

Name ⏱️ Duration Suite
Should be able to access the Home page 4.129 s RAPLive

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass %
1 0 0 1 100

Passed Tests

Name ⏱️ Duration Suite
Should be able to access the Home page 3.216 s RAPLive

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass %
1 0 0 1 100

Passed Tests

Name ⏱️ Duration Suite
Should be able to access the Home page 3.719 s RAPLive

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass %
1 0 0 1 100

Passed Tests

Name ⏱️ Duration Suite
Should be able to access the Home page 3.338 s RAPLive

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass %
1 0 0 1 100

Passed Tests

Name ⏱️ Duration Suite
Should be able to access the Home page 3.282 s RAPLive

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass %
1 0 0 1 100

Passed Tests

Name ⏱️ Duration Suite
Should be able to access the Home page 3.238 s RAPLive

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass %
1 0 0 1 100

Passed Tests

Name ⏱️ Duration Suite
Should be able to access the Home page 4.192 s RAPLive

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass %
1 0 0 1 100

Passed Tests

Name ⏱️ Duration Suite
Should be able to access the Home page 3.6029999999999998 s RAPLive

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass %
1 0 0 1 100

Passed Tests

Name ⏱️ Duration Suite
Should be able to access the Home page 3.564 s RAPLive

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass %
1 0 0 1 100

Passed Tests

Name ⏱️ Duration Suite
Should be able to access the Home page 3.247 s RAPLive

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass %
1 0 0 1 100

Passed Tests

Name ⏱️ Duration Suite
Should be able to access the Home page 3.337 s RAPLive

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass %
1 0 0 1 100

Passed Tests

Name ⏱️ Duration Suite
Should be able to access the Home page 3.768 s RAPLive

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass %
1 0 0 1 100

Passed Tests

Name ⏱️ Duration Suite
Should be able to access the Home page 3.221 s RAPLive

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass %
1 0 0 1 100

Passed Tests

Name ⏱️ Duration Suite
Should be able to access the Home page 3.557 s RAPLive

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass %
1 0 0 1 100

Passed Tests

Name ⏱️ Duration Suite
Should be able to access the Home page 3.283 s RAPLive

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass %
1 0 0 1 100

Passed Tests

Name ⏱️ Duration Suite
Should be able to access the Home page 3.534 s RAPLive

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass %
1 0 0 1 100

Passed Tests

Name ⏱️ Duration Suite
Should be able to access the Home page 3.651 s RAPLive

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass %
1 0 0 1 100

Passed Tests

Name ⏱️ Duration Suite
Should be able to access the Home page 4.263 s RAPLive

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass %
1 0 0 1 100

Passed Tests

Name ⏱️ Duration Suite
Should be able to access the Home page 3.225 s RAPLive

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass %
1 0 0 1 100

Passed Tests

Name ⏱️ Duration Suite
Should be able to access the Home page 3.268 s RAPLive

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass %
1 0 0 1 100

Passed Tests

Name ⏱️ Duration Suite
Should be able to access the Home page 3.598 s RAPLive

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass %
1 0 0 1 100

Passed Tests

Name ⏱️ Duration Suite
Should be able to access the Home page 3.769 s RAPLive

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass %
1 0 0 1 100

Passed Tests

Name ⏱️ Duration Suite
Should be able to access the Home page 3.268 s RAPLive

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass %
1 0 0 1 100

Passed Tests

Name ⏱️ Duration Suite
Should be able to access the Home page 3.568 s RAPLive

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass %
1 0 0 1 100

Passed Tests

Name ⏱️ Duration Suite
Should be able to access the Home page 3.207 s RAPLive

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass %
1 0 0 1 100

Passed Tests

Name ⏱️ Duration Suite
Should be able to access the Home page 3.892 s RAPLive

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass %
1 0 0 1 100

Passed Tests

Name ⏱️ Duration Suite
Should be able to access the Home page 4.078 s RAPLive

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass %
1 0 0 1 100

Passed Tests

Name ⏱️ Duration Suite
Should be able to access the Home page 3.208 s RAPLive

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass %
1 0 0 1 100

Passed Tests

Name ⏱️ Duration Suite
Should be able to access the Home page 3.208 s RAPLive

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass %
1 0 0 1 100

Passed Tests

Name ⏱️ Duration Suite
Should be able to access the Home page 3.2800000000000002 s RAPLive

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass %
1 0 0 1 100

Passed Tests

Name ⏱️ Duration Suite
Should be able to access the Home page 4.057 s RAPLive

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass %
1 0 0 1 100

Passed Tests

Name ⏱️ Duration Suite
Should be able to access the Home page 3.752 s RAPLive

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass %
1 0 0 1 100

Passed Tests

Name ⏱️ Duration Suite
Should be able to access the Home page 3.205 s RAPLive

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass %
1 0 0 1 100

Passed Tests

Name ⏱️ Duration Suite
Should be able to access the Home page 3.339 s RAPLive

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass %
1 0 0 1 100

Passed Tests

Name ⏱️ Duration Suite
Should be able to access the Home page 4.1 s RAPLive

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass %
1 0 0 1 100

Passed Tests

Name ⏱️ Duration Suite
Should be able to access the Home page 3.265 s RAPLive

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass %
1 0 0 1 100

Passed Tests

Name ⏱️ Duration Suite
Should be able to access the Home page 3.218 s RAPLive

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass %
1 0 0 1 100

Passed Tests

Name ⏱️ Duration Suite
Should be able to access the Home page 3.924 s RAPLive

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass %
1 0 0 1 100

Passed Tests

Name ⏱️ Duration Suite
Should be able to access the Home page 3.221 s RAPLive

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass %
1 0 0 1 100

Passed Tests

Name ⏱️ Duration Suite
Should be able to access the Home page 3.996 s RAPLive

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass %
1 0 0 1 100

Passed Tests

Name ⏱️ Duration Suite
Should be able to access the Home page 4.204 s RAPLive

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass %
1 0 0 1 100

Passed Tests

Name ⏱️ Duration Suite
Should be able to access the Home page 3.299 s RAPLive

Please sign in to comment.