Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to create a Kubernetes pod that runs a machine learning container.
MLOps
apiVersion: v1
kind: Pod
metadata:
name: ml-pod
spec:
containers:
- name: ml-container
image: [1] Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a web server image like nginx instead of an ML image.
Using a database image like mysql which is unrelated to ML workloads.
✗ Incorrect
The correct image for running ML workloads is the TensorFlow image, which contains ML libraries.
2fill in blank
mediumComplete the code to specify resource limits for the ML container in the pod.
MLOps
spec:
containers:
- name: ml-container
resources:
limits:
cpu: [1] Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using memory units like '2Gi' for CPU limits.
Using plain numbers without units for CPU limits.
✗ Incorrect
CPU limits are specified in cores or millicores; '500m' means 0.5 CPU cores.
3fill in blank
hardFix the error in the YAML to mount a volume for ML data inside the container.
MLOps
spec:
containers:
- name: ml-container
volumeMounts:
- name: data-volume
mountPath: [1]
volumes:
- name: data-volume
persistentVolumeClaim:
claimName: ml-data-pvc Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using mount paths that are not directories or reserved system paths.
Using the volume name as the mount path.
✗ Incorrect
The mountPath should be a directory inside the container where data is accessed, commonly '/mnt/data'.
4fill in blank
hardFill both blanks to create a Kubernetes Job that runs an ML training script once.
MLOps
apiVersion: batch/v1
kind: Job
metadata:
name: ml-training-job
spec:
template:
spec:
containers:
- name: trainer
image: [1]
command: ["python", [2]]
restartPolicy: Never Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a generic TensorFlow image without the training script.
Using the wrong script name in the command.
✗ Incorrect
The job uses a custom ML training image and runs the 'train.py' script with python.
5fill in blank
hardFill all three blanks to define a Kubernetes Deployment for an ML model server with 3 replicas and environment variable.
MLOps
apiVersion: apps/v1 kind: Deployment metadata: name: ml-model-server spec: replicas: [1] selector: matchLabels: app: ml-server template: metadata: labels: app: ml-server spec: containers: - name: model-server image: [2] env: - name: MODEL_NAME value: [3]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Setting replicas to 1 instead of 3.
Not quoting the environment variable value.
Using wrong image names.
✗ Incorrect
The deployment runs 3 replicas of the model server container with the environment variable MODEL_NAME set to 'image-classifier'.