diff --git a/Containerization & Orchestration/Kubernetes/1-Information.md b/Containerization & Orchestration/Kubernetes/1-Information.md index 5d6c9c0..869e7ba 100755 --- a/Containerization & Orchestration/Kubernetes/1-Information.md +++ b/Containerization & Orchestration/Kubernetes/1-Information.md @@ -81,3 +81,7 @@ The **Control Plane** is the core management component of a Kubernetes cluster. image pull policy in kubernetes: + + +example of all work loads: +https://k8s-examples.container-solutions.com/ \ No newline at end of file diff --git a/Containerization & Orchestration/Kubernetes/components/7-Jobs.md b/Containerization & Orchestration/Kubernetes/components/7-Jobs.md new file mode 100644 index 0000000..e145099 --- /dev/null +++ b/Containerization & Orchestration/Kubernetes/components/7-Jobs.md @@ -0,0 +1,48 @@ +# ⏳ Kubernetes Jobs + +A **Job** in Kubernetes runs a pod to completion. It ensures that a specified number of pods successfully terminate. + +Use Jobs for **batch processing**, **one-off tasks**, or **short-lived workloads**. + +--- + +## πŸ” Job Commands + +### πŸ“„ List Jobs in a Namespace +```bash +kubectl get jobs.batch -n +```` + +### ❌ Delete a Job + +```bash +kubectl delete jobs.batch -n +``` + +--- + +## 🧾 Example Job Manifest + +Here’s a minimal example of a Job that runs a simple `echo` command: + +```yaml +apiVersion: batch/v1 +kind: Job +metadata: + name: myjob + namespace: ns +spec: + template: + spec: + containers: + - name: job1 + image: alpine + command: + - echo + - "hello world" + restartPolicy: Never +``` + +> πŸ’‘ **Note:** Always set `restartPolicy` to `Never` or `OnFailure` for jobs. +> πŸ“Œ Jobs are useful for tasks like backups, report generation, or database migrations. + diff --git a/Containerization & Orchestration/Kubernetes/components/8-Cronjobs.md b/Containerization & Orchestration/Kubernetes/components/8-Cronjobs.md new file mode 100644 index 0000000..3bc64ee --- /dev/null +++ b/Containerization & Orchestration/Kubernetes/components/8-Cronjobs.md @@ -0,0 +1,51 @@ +# ⏰ Kubernetes CronJobs + +A **CronJob** in Kubernetes allows you to run jobs on a recurring schedule, similar to traditional UNIX `cron` jobs. Ideal for periodic tasks like backups, reports, or scheduled notifications. + +--- + +## πŸ” CronJob Commands + +### πŸ“„ List CronJobs in a Namespace +```bash +kubectl get cronjobs.batch -n +```` + +### ❌ Delete a CronJob + +```bash +kubectl delete cronjobs.batch -n +``` + +--- + +## 🧾 Example CronJob Manifest + +This CronJob runs every minute and prints the date followed by "Kubernetes": + +```yaml +apiVersion: batch/v1 +kind: CronJob +metadata: + name: cronjob1 + namespace: ns +spec: + schedule: "* * * * *" + jobTemplate: + spec: + template: + spec: + containers: + - name: cronjob + image: debian:bookworm + command: + - /bin/bash + - -c + - date; echo Kubernetes + restartPolicy: Never +``` + +> πŸ›  **Fix:** Changed `JobTemplate` to `jobTemplate` (YAML keys are case-sensitive). +> πŸ• The `schedule` field follows standard cron format: `minute hour day-of-month month day-of-week`. +> 🧠 **Tip:** Always test cron timing carefully to avoid unintentional frequent runs. +