Eseguire l'addestramento come Kubernetes Job
Esegua l'addestramento batch fino al completamento nel cluster.
Eseguire l'addestramento come Kubernetes Job è una lezione MLOps Academy gratuita su CoddyKit. Questa è la lezione 4 di 4. Puoi leggere la lezione completa qui gratuitamente — poi esercitati direttamente nel browser con un editor di codice integrato e un tutor IA disponibile 24/7. Fa parte del percorso di apprendimento MLOps Academy, e i tuoi progressi si sincronizzano tra il web e l'app CoddyKit. Il corso MLOps Academy include 4 lezioni in totale.
Parti di questa lezione non sono ancora state tradotte e vengono mostrate in inglese.
Training Is Not a Server
A model server runs forever, but a training run should start, finish, and stop. Kubernetes has a different object built for that: the Job. 🏁
A Job Runs to Completion
A Job creates one or more Pods and watches them until they exit successfully. Once training succeeds, the Job is done and frees its resources.
apiVersion: batch/v1
kind: Job
metadata:
name: train-ranker
spec:
template:
spec:
restartPolicy: NeverrestartPolicy Must Not Be Always
A Job Pod must use restartPolicy Never or OnFailure. Always is for servers and Kubernetes rejects it for a Job that is meant to end.
Retries with backoffLimit
Training can fail on a flaky download. The backoffLimit sets how many times the Job retries a failing Pod before it gives up for good.
spec:
backoffLimit: 4
activeDeadlineSeconds: 3600Cap Runtime to Avoid Runaways
Set activeDeadlineSeconds so a hung training run cannot burn an expensive GPU node all weekend. The Job is killed once that limit passes. ⏱️
Request the GPU You Need
A training Job uses the same resources block as a Deployment. Add nvidia.com/gpu under limits so the run lands on a GPU node.
Parallelism for Sweeps
Set completions and parallelism to run many Pods, perfect for a hyperparameter sweep where each Pod trains one configuration at once.
Logs and Artifacts Outlive the Pod
A finished Job Pod is gone, so write your model and metrics to durable storage like S3 or a volume, never to the Pod filesystem.
CronJob for Scheduled Retraining
Wrap a Job in a CronJob to retrain on a schedule, like nightly. It creates a fresh Job each time the cron expression fires.
apiVersion: batch/v1
kind: CronJob
spec:
schedule: "0 2 * * *"Clean Up Finished Jobs
Completed Jobs linger by default and clutter the cluster. Set ttlSecondsAfterFinished so Kubernetes deletes them automatically after a grace period.
Watch Status with kubectl
Check a run with kubectl get jobs and read output with kubectl logs. The status shows succeeded or failed counts at a glance.
kubectl get jobs
kubectl logs job/train-rankerQuick Check
Why is a Job, not a Deployment, right for training?
Recap
Run finite training as a Job with restartPolicy Never, a backoffLimit, and a runtime cap, then schedule retraining with a CronJob. ✅
Domande Frequenti
La lezione «Eseguire l'addestramento come Kubernetes Job» è gratuita?
Sì — il testo completo di «Eseguire l'addestramento come Kubernetes Job» è gratuito qui sul web. Per esercitarvi in modo interattivo (un editor di codice integrato e un tutor IA 24/7) e sbloccare il resto del corso MLOps Academy, passa a CoddyKit PRO. Il corso MLOps Academy include 4 lezioni in totale.
Cosa imparerò in «Eseguire l'addestramento come Kubernetes Job»?
Esegua l'addestramento batch fino al completamento nel cluster. Eserciti MLOps Academy con codice pratico che esegui direttamente nel browser, e un tutor IA 24/7 risponde alle tue domande mentre lavori sulla lezione.
Ho bisogno di esperienza per iniziare MLOps Academy?
Non è richiesta alcuna esperienza precedente. MLOps Academy su CoddyKit è strutturato per principianti e studenti avanzati, quindi puoi iniziare da qui o dall'inizio e procedere al tuo ritmo. Questa è la lezione 4 di 4.
Quanto tempo richiede la lezione «Eseguire l'addestramento come Kubernetes Job»?
La maggior parte delle lezioni CoddyKit richiede circa 5–10 minuti. Ogni lezione è breve e interattiva, quindi fai progressi costanti e riprendi esattamente da dove hai lasciato su web e app.
Posso scrivere ed eseguire codice in questa lezione MLOps Academy?
Sì. Ogni lezione MLOps Academy include un editor di codice integrato, quindi scrivi ed esegui codice reale direttamente nel tuo browser e ricevi feedback istantaneo dall'IA — nessuna configurazione locale necessaria.
Tutte le lezioni di questo corso
- Pod, deployment e service per i modelli
- Richiedere CPU, memoria e GPU
- Configurare con ConfigMap e Secret
- Eseguire l'addestramento come Kubernetes Job