From 9872f2d6ff46bf78d0b3f7013ceed2788bad9d25 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 10 Jul 2023 14:58:01 +0000 Subject: [PATCH] kube/cronjobs --- rtfd/public/kubernetes/index.rst | 62 +++++++++++++++++++++++++++++++- 1 file changed, 61 insertions(+), 1 deletion(-) diff --git a/rtfd/public/kubernetes/index.rst b/rtfd/public/kubernetes/index.rst index e0a5727..83f083d 100644 --- a/rtfd/public/kubernetes/index.rst +++ b/rtfd/public/kubernetes/index.rst @@ -1,5 +1,5 @@ ********** -Kubernetes +kubernetes ********** * Deployment → ReplicaSet → Pods → Containers @@ -279,3 +279,63 @@ Write delete job my-job \ cascade=false \ -n my-namespace + +CronJobs +======== + +Read +---- + +.. code:: shell + + kubectl \ + get cronjobs \ + -n my-namespace + +Write +----- + +.. code:: shell + + kubectl \ + create cronjob my-cronjob \ + --image my-image \ + --schedule '*/4 * * * *' \ + -n my-namespace + +.. code:: yaml + + apiVersion: batch/v1 + kind: CronJob + metadata: + name: my-cronjob + spec: + schedule: '*/4 * * * *' + jobTemplate: + spec: + template: + spec: + containers: + - name: my-container + image: my-image + imagePullPolicy: IfNotPresent + command: + - /usr/bin/bash + - -c + - command + failedHistoryLimit: 2 + successfulJobsHistoryLimit: 1 + restartPolicy: OnFailure + +.. code:: shell + + kubectl \ + patch cronjob my-cronjob \ + -p '{"spec":{"schedule": "*/4 * * * *"}}' \ + -n my-namespace + +.. code:: shell + + kubectl \ + delete cronjob my-cronjob \ + -n my-namespace