Kubernetes Jobとして学習を実行する
クラスター上でバッチ学習を完了まで実行します。
「Kubernetes Jobとして学習を実行する」はCoddyKit上の無料MLOps Academyレッスンです。 これはレッスン4/4です。 下記で完全なレッスンを無料で読むことができます。その後、ブラウザ内の組み込みコードエディタと24時間対応のAIチューターでハンズオン演習できます。 これはMLOps Academy学習パスの一部であり、ウェブとCoddyKitアプリ全体で進捗が同期されます。 MLOps Academyコースには全4レッスンが含まれています。
このレッスンの一部はまだ翻訳されておらず、英語で表示されています。
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. ✅
よくある質問
「Kubernetes Jobとして学習を実行する」レッスンは無料ですか?
はい。「Kubernetes Jobとして学習を実行する」の完全なテキストはこのウェブで無料で読めます。インタラクティブに演習し(組み込みコードエディタと24時間対応のAIチューター)、MLOps Academyコースの残りをアンロックするには、CoddyKit PROにアップグレードしてください。 MLOps Academyコースには全4レッスンが含まれています。
「Kubernetes Jobとして学習を実行する」で何を学びますか?
クラスター上でバッチ学習を完了まで実行します。 ブラウザで直接実行するハンズオンコードでMLOps Academyを演習し、24時間対応のAIチューターがレッスンを進める中での質問に答えます。
MLOps Academyを始めるのに経験は必要ですか?
事前経験は必要ありません。CoddyKitのMLOps Academyは初級者から上級者向けに構成されているため、ここから始めるか最初から始めて、自分のペースで進むことができます。 これはレッスン4/4です。
「Kubernetes Jobとして学習を実行する」レッスンにはどのくらい時間がかかりますか?
ほとんどのCoddyKitレッスンは約5~10分かかります。各レッスンはコンパクトでインタラクティブなので、着実に進歩し、ウェブとアプリ全体で正確に前回の場所から再開できます。
このMLOps Academyレッスンでコードを書いて実行できますか?
はい。すべてのMLOps Academyレッスンに組み込みコードエディタが含まれているため、ブラウザでリアルコードを書いて実行し、即座のAIフィードバックを取得できます。ローカル設定は不要です。
このコースのすべてのレッスン
- モデル向けのPod、Deployment、Service
- CPU、メモリ、GPUを要求する
- ConfigMapsとSecretsで設定する
- Kubernetes Jobとして学習を実行する