kube/cronjobs

This commit is contained in:
Marc Beninca 2023-07-10 14:58:01 +00:00
parent ad670c36ff
commit 9872f2d6ff

View file

@ -1,5 +1,5 @@
********** **********
Kubernetes kubernetes
********** **********
* Deployment → ReplicaSet → Pods → Containers * Deployment → ReplicaSet → Pods → Containers
@ -279,3 +279,63 @@ Write
delete job my-job \ delete job my-job \
cascade=false \ cascade=false \
-n my-namespace -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