0
0
Kubernetesdevops~10 mins

Why operators extend Kubernetes - Test Your Understanding

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

Complete the code to create a custom resource definition (CRD) in Kubernetes.

Kubernetes
kubectl apply -f [1]
Drag options to blanks, or click blank then click option'
Adeployment.yaml
Bcrd.yaml
Cservice.yaml
Dpod.yaml
Attempts:
3 left
💡 Hint
Common Mistakes
Using a deployment.yaml file instead of a CRD file.
Applying a service.yaml which does not define custom resources.
2fill in blank
medium

Complete the command to check the status of custom resources managed by an operator.

Kubernetes
kubectl get [1]
Drag options to blanks, or click blank then click option'
Amyresources
Bcustomresourcedefinitions
Cservices
Dpods
Attempts:
3 left
💡 Hint
Common Mistakes
Listing pods instead of custom resources.
Using 'customresourcedefinitions' which lists the definitions, not instances.
3fill in blank
hard

Fix the error in the operator deployment YAML by completing the missing field.

Kubernetes
apiVersion: apps/v1
kind: Deployment
metadata:
  name: my-operator
spec:
  replicas: 1
  selector:
    matchLabels:
      name: my-operator
  template:
    metadata:
      labels:
        name: my-operator
    spec:
      containers:
      - name: operator
        image: my-operator-image:latest
        [1]: ["--enable-leader-election"]
Drag options to blanks, or click blank then click option'
Acommand
Benv
Cargs
Dports
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'command' which overrides the container's default command.
Using 'env' which is for environment variables, not command arguments.
4fill in blank
hard

Fill both blanks to complete the reconciliation loop function signature in a Kubernetes operator.

Kubernetes
func (r *ReconcileMyResource) Reconcile(ctx context.Context, [1] ctrl.Request) ([2], error) {
Drag options to blanks, or click blank then click option'
Areq
Bresult
Cctrl.Result
Derror
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'result' as the parameter name instead of 'req'.
Returning 'error' as the first return value instead of 'ctrl.Result'.
5fill in blank
hard

Fill all three blanks to complete the operator's watch setup code.

Kubernetes
return ctrl.NewControllerManagedBy(mgr).
  For(&mygroupv1.MyResource{}).
  [1](&source.Kind{Type: &corev1.Pod{}}).
  [2](handler.EnqueueRequestForOwner(mgr.GetScheme(), [3])).
  Complete(r)
Drag options to blanks, or click blank then click option'
AWatches
BIsController
DOwnerType
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'IsController' as the first method instead of 'Watches'.
Confusing 'OwnerType' with 'IsController' in the wrong place.