Complete the code to create a custom resource definition (CRD) in Kubernetes.
kubectl apply -f [1]The crd.yaml file defines a custom resource definition, which is essential for extending Kubernetes with operators.
Complete the command to check the status of custom resources managed by an operator.
kubectl get [1]The operator manages custom resources, which have their own names like myresources. This command lists those resources.
Fix the error in the operator deployment YAML by completing the missing field.
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"]
The args field passes arguments to the container command, such as enabling leader election in operators.
Fill both blanks to complete the reconciliation loop function signature in a Kubernetes operator.
func (r *ReconcileMyResource) Reconcile(ctx context.Context, [1] ctrl.Request) ([2], error) {
The Reconcile function takes a ctrl.Request named req and returns a ctrl.Result and an error.
Fill all three blanks to complete the operator's watch setup code.
return ctrl.NewControllerManagedBy(mgr). For(&mygroupv1.MyResource{}). [1](&source.Kind{Type: &corev1.Pod{}}). [2](handler.EnqueueRequestForOwner(mgr.GetScheme(), [3])). Complete(r)
The operator watches Pods with Watches, filters with IsController, and sets the owner type with OwnerType.