Closed DilaraOflaz closed 2 years ago
Before we merge this can we squash a lot of these commits? For example a lot of the "cleaning", and "testing" ones could be pushed into one or merged with feature commits. Sam will be covering exactly this in the git meeting tomorrow, but here's a general tutorial on it: https://www.baeldung.com/ops/git-squash-commits
It keeps the commit tree in a readable state when looking through history, so a commit should be named exactly as it is "Adding functionality X to support feature Y" - as an example.
Let me know if you have questions about it or want to go over it together.
I found this parameter 'ttlSecondsAfterFinished': X
, to remove the pods automatically X
seconds after completion
I can add it inside the file kubetools/kubernetes/config/cronjob.py
inside the cronjob spec: spec.jobTemplate.spec
So Kubernetes will handle the deletion of the completed pods, we won't have to modify the delete_cronjob
function
Please let me know your thoughts ?
PR looks good to me, I think we maybe we should also consider these parameters for job history retention spec.successfulJobsHistoryLimit
and spec.failedJobsHistoryLimit
? By default, successfulJobsHistoryLimit
is set to 3 and failedJobsHistoryLimit
is set to 1 for Kubernetes
Great stuff!
## Purpose of PR I added CronJob object to Kubetools.
## Parts of the app this will impact With this Branch we can run the following commands:
kubetools deploy ...
kubetools remove ...
kubetools show ...
kubetools cleanup ...
## How to test it
if you have a Mac, you can test it locally by enabling Kubernetes in Docker-Desktop ( Open Docker -> Preferences -> Kubernetes -> Check Enable Kubernetes -> Apply & Restart) Otherwise, by pointing to the staging Kubernetes cluster
To get the name of the context, run this following command:
kubectl config current-context
Checkout to this branch, create a python Virtual Environment, run the following command:
pip install -e .[dev]
Note: Runpip install -e ".[dev]"
if you use zshCreate a kubetools.yml file. Content example:
Run this command:
kubetools --context <CONTEXT NAME> deploy cronjob-test
This command can take 20s to finish running (it waits until the first job is created)The
deploy
command should create thecronjob-test
namespace and themy-cronjob
CronJob, you can check by running this command:kubetools --context <CONTEXT NAME> show cronjob-test
Run this command to delete the CronJob:
kubetools --context <CONTEXT NAME> remove cronjob-test
After running this command, if you run this following commandkubetools --context <CONTEXT NAME> show cronjob-test
, the output should beNothing to be found here 👀!
To clean the succeeded/completed pods, you can run this following command:
kubetools --context <CONTEXT NAME> cleanup cronjob-test
## Additional information With the current code, the
kubetools cleanup
command cleans only if the pods (created by the CronJob) are orphaned. If the CronJob still exists (Not removed), even if the pods are completed they are not cleaned.