0
0
Kubernetesdevops~10 mins

StatefulSets for stateful applications in Kubernetes - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to define a StatefulSet with the correct API version.

Kubernetes
apiVersion: apps/[1]
kind: StatefulSet
metadata:
  name: web
spec:
  selector:
    matchLabels:
      app: nginx
  serviceName: "nginx"
  replicas: 3
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:1.15.4
Drag options to blanks, or click blank then click option'
Av1
Bv1beta1
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'v1' directly without 'apps/' prefix
Using 'core/v1' which is for Pods and Services
2fill in blank
medium

Complete the code to specify the volumeClaimTemplates section for persistent storage.

Kubernetes
volumeClaimTemplates:
- metadata:
    name: [1]
  spec:
    accessModes: ["ReadWriteOnce"]
    resources:
      requests:
        storage: 1Gi
Drag options to blanks, or click blank then click option'
Apersistent
Bstorage
Cvolume
Ddata
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'storage' which is a resource request, not a name
Using 'persistent' which is not a typical volume claim name
3fill in blank
hard

Fix the error in the selector section to correctly match the pod labels.

Kubernetes
selector:
  matchLabels:
    app: [1]
Drag options to blanks, or click blank then click option'
Anginx
Bnginx-app
Capp
Dweb
Attempts:
3 left
💡 Hint
Common Mistakes
Using a different label value than the pod template
Using the key instead of the value
4fill in blank
hard

Fill both blanks to complete the container volume mount and volume claim reference.

Kubernetes
containers:
- name: nginx
  image: nginx:1.15.4
  volumeMounts:
  - name: [1]
    mountPath: [2]
Drag options to blanks, or click blank then click option'
Adata
B/usr/share/nginx/html
C/var/lib/data
Dstorage
Attempts:
3 left
💡 Hint
Common Mistakes
Mismatching volumeMount name and volumeClaimTemplates name
Using an incorrect mountPath for nginx
5fill in blank
hard

Fill all three blanks to complete the StatefulSet spec with replicas, serviceName, and pod label.

Kubernetes
spec:
  replicas: [1]
  serviceName: "[2]"
  template:
    metadata:
      labels:
        app: [3]
Drag options to blanks, or click blank then click option'
Aweb
B3
Cnginx
Dfrontend
Attempts:
3 left
💡 Hint
Common Mistakes
Using a string for replicas instead of a number
Mismatching serviceName and pod labels