Bird
0
0

Which of the following is the correct way to define a watch in an Operator's controller code?

easy📝 Syntax Q3 of 15
Kubernetes - Operators and Custom Resources
Which of the following is the correct way to define a watch in an Operator's controller code?
Acontroller.Observe(&source.Kind{Type: &corev1.Service{}}, &handler.EnqueueRequestForObject)
Bcontroller.Listen(&source.Pod{Type: &corev1.Pod{}}, &handler.EnqueueRequestForObject)
Ccontroller.Monitor(&source.Kind{Type: &corev1.Namespace{}}, &handler.EnqueueRequestForObject)
Dcontroller.Watch(&source.Kind{Type: &appsv1.Deployment{}}, &handler.EnqueueRequestForObject)
Step-by-Step Solution
Solution:
  1. Step 1: Recall correct watch syntax

    In Operator SDK, watching a resource uses controller.Watch with source.Kind and handler.EnqueueRequestForObject.
  2. Step 2: Validate options

    Only controller.Watch(&source.Kind{Type: &appsv1.Deployment{}}, &handler.EnqueueRequestForObject) uses correct method and types; others use invalid methods or types.
  3. Final Answer:

    controller.Watch(&source.Kind{Type: &appsv1.Deployment{}}, &handler.EnqueueRequestForObject) -> Option D
  4. Quick Check:

    Watch syntax = controller.Watch + source.Kind [OK]
Quick Trick: Use controller.Watch with source.Kind to watch resources [OK]
Common Mistakes:
  • Using non-existent methods like Listen or Monitor
  • Passing resource types incorrectly
  • Confusing source.Kind with source.Pod

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kubernetes Quizzes