From 06d052af4854cb62e8f05aacefa83170511522a7 Mon Sep 17 00:00:00 2001 From: Naga Ravi Chaitanya Elluri Date: Fri, 6 Aug 2021 01:09:05 -0400 Subject: [PATCH] Run tasks in pod using Job object type This commit switches the object type from Deployment to Job to be able to display the status after executing all the scenarios specified in the Kraken config instead of crashing which is expected in Deployments. Fixes https://github.com/cloud-bulldozer/kraken/issues/135 --- containers/README.md | 2 +- containers/kraken.yml | 15 ++++++--------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/containers/README.md b/containers/README.md index ca556937..0bfeb855 100644 --- a/containers/README.md +++ b/containers/README.md @@ -23,6 +23,6 @@ To run containerized Kraken as a Kubernetes/OpenShift Deployment, follow these s 6. Create a ConfigMap named scenarios-config using `kubectl create configmap scenarios-config --from-file=` 7. Create a serviceaccount to run the kraken pod `kubectl create serviceaccount useroot`. 8. In Openshift, add privileges to service account and execute `oc adm policy add-scc-to-user privileged -z useroot`. -9. Create a Deployment and a NodePort Service using `kubectl apply -f kraken.yml` +9. Create a Job using `kubectl apply -f kraken.yml` and monitor the status using `oc get jobs` and `oc get pods`. NOTE: It is not recommended to run Kraken internal to the cluster as the pod which is running Kraken might get disrupted. diff --git a/containers/kraken.yml b/containers/kraken.yml index 383b32d5..7bafd19b 100644 --- a/containers/kraken.yml +++ b/containers/kraken.yml @@ -1,13 +1,11 @@ --- -apiVersion: apps/v1 -kind: Deployment +apiVersion: batch/v1 +kind: Job metadata: - name: kraken-deployment + name: kraken spec: - replicas: 1 - selector: - matchLabels: - tool: Kraken + parallelism: 1 + completions: 1 template: metadata: labels: @@ -21,8 +19,6 @@ spec: image: quay.io/openshift-scale/kraken command: ["/bin/sh", "-c"] args: ["python3 run_kraken.py -c config/config.yaml"] - ports: - - containerPort: 8080 volumeMounts: - mountPath: "/root/.kube" name: config @@ -30,6 +26,7 @@ spec: name: kraken-config - mountPath: "/root/kraken/scenarios" name: scenarios-config + restartPolicy: Never volumes: - name: config configMap: