k8s_Job - harishgorla5/K8S-HINTechnologies GitHub Wiki
A Kubernetes Job ensures that a specified number of pods complete successfully. Once the task completes, the Job tracks the pod status and retries on failure based on the restart policy.
1. One-off task: Run once and exit. 2. Retry on failure: Automatically retries if a pod fails (based on the <code>backoffLimit</code>). 3. Parallelism: Can run multiple pods in parallel (e.g., for data processing).
This example demonstrates a complete pipeline where a user uploads an image, and a Kubernetes Job processes it using ImageMagick.
1. Create PersistentVolumeClaim:
kubectl apply -f https://raw.githubusercontent.com/harishgorla5/K8S-HINTechnologies/refs/heads/main/job-pvc.yaml
2. Frontend (HTML Upload UI via Nginx): A ConfigMap is used to serve the HTML.
kubectl apply -f https://raw.githubusercontent.com/harishgorla5/K8S-HINTechnologies/refs/heads/main/job-config.yaml
3. Nginx Pod and NodePort Service:
kubectl apply -f https://raw.githubusercontent.com/harishgorla5/K8S-HINTechnologies/refs/heads/main/job-pod-nodeport.yaml
4. Backend (Flask container):
kubectl apply -f https://raw.githubusercontent.com/harishgorla5/K8S-HINTechnologies/refs/heads/main/job-deployment.yaml
5. Open the frontend in browser:
http://nodeip:30080
6. Upload an image.
7. The backend saves the image to PVC and creates a Kubernetes Job.
8. The Job runs ImageMagick to resize the image.
9. Output is saved as: /data/thumb_<filename>
on the PVC.
10. Check that the Job has been created:
kubectl get jobs
11. Check the Job Pod:
kubectl get pods
12. View logs from the Job Pod:
kubectl logs <job-pod-name>
13. Check Job status in detail:
kubectl describe job <job-name>
14. Debugging a failed Job:
kubectl get pods kubectl logs <failing-job-pod> kubectl describe pod <failing-job-pod>