-
Notifications
You must be signed in to change notification settings - Fork 4
Elaa's solution #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,36 +30,39 @@ You are the head of your dev ops department, and you'd like to provide your engi | |
|
|
||
| Answer the following questions to test your understanding. You may want to tweak your code or add print/debug statements to test how it works. | ||
|
|
||
| 1. What are the event types that the reconciler can recieve? | ||
| 1. What are the event types that the reconciler can recieve: Controller Request | ||
|
|
||
| 1. Which controller option controls how often Level-based reconciliation occurs? | ||
| 1. Which controller option controls how often Level-based reconciliation occurs: Resync after | ||
|
|
||
| 1. Which event types are passed in on level based reconciliation? | ||
| 1. Which event types are passed in on level based reconciliation: Update, Create, Delete for edge based reconciliation but for level based it should be started periodically | ||
|
|
||
| 1. What is the difference between the `builder.Builder`'s `For`, `Owns` and `Watches` methods? | ||
| 1. What is the difference between the `builder.Builder`'s `For`, `Owns` and `Watches` methods: For is for which resource kind is used i.e MyApps, Owns: the MyApp will own the CRs instances, | ||
|
|
||
| 1. What happens if 10 updates to the same object occur in rapid succession (ie: before a single Reconcile occurs)? How many times is Reconcile called, and with which version of the object? | ||
| 1. What happens if 10 updates to the same object occur in rapid succession (ie: before a single Reconcile occurs)? How many times is Reconcile called, and with which version of the object?: The events will be added to the reconciliation queue and will be handled in order for the atest version of the object | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is that correct? That it will send 10 updates all with the newest version? I actually forget the answer here so just double checking. I thought it coalesced into a single event with the latest update. If you want help recreating this scenario we can do it :)
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe it does coalesce into a single event. I know if some of the updates include similar changes let's say 6 update change the number of replicas of the same deployment for example, the controller will go with the latest change to the number of replicas but if the remaining 4 updates include different changes they would also be included. So maybe all the updates and merged into one to reach the latest desired state. I would love to recreate it |
||
|
|
||
| 1. How can you control the speed of reconciliation? | ||
| 1. How can you control the speed of reconciliation: Requeue after or SyncPeriod | ||
|
|
||
| 1. How can you retry a failed reconiliation at a later time? | ||
| 1. How can you retry a failed reconiliation at a later time: Requeue after | ||
|
|
||
| 1. What happens to child objects if you delete a watched object? | ||
| 1. What happens to child objects if you delete a watched object: the child will also be deleted | ||
|
|
||
| 1. Does the reconciler trigger on updates to the watched object, updates to the child object, or both? | ||
| 1. Does the reconciler trigger on updates to the watched object, updates to the child object, or both? both | ||
|
|
||
| 1. Answer the above question, but for children of children? ie: 1 controller that creates a child object, that in turn creates a child object (ie: creating a deployment, will in turn create Pods) | ||
| 1. Answer the above question, but for children of children? ie: 1 controller that creates a child object, that in turn creates a child object (ie: creating a deployment, will in turn create Pods) the child will be delted but not the child of the child. The reconciler doesn't trigger on the updates for children of children. If there are ny updates that conflict with the intent they will be handled in the next reconciliation cycle | ||
|
|
||
| 1. What happens if a Reconciliation fails, and new updates come in? | ||
| 1. What happens if a Reconciliation fails, and new updates come in? the update during which the error occured would be requeued for reconciliation. In any case the controller will eventully bring the resource to the desired state | ||
|
|
||
| 1. What happens if a reconciliation fails to a child's child objects (ie: a deployments pods)? | ||
| 1. What happens if a reconciliation fails to a child's child objects (ie: a deployments pods)? the controller will retry / we see that myapp-sample-2 pods keep getting restarted because of their low time span and kubernetes thinks they're crashing | ||
|
|
||
| 1. If a single resource is in a failed state, does it block reconciliation of other objects? | ||
| 1. If a single resource is in a failed state, does it block reconciliation of other objects? No | ||
|
|
||
| 1. A ReconcileRequest only has the `NamespacedName`. How do you get the full object? Is this object cached, or result in an API call to the k8s master? | ||
| 1. A ReconcileRequest only has the `NamespacedName`. How do you get the full object? Is this object cached, or result in an API call to the k8s master?API call | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. or from the cache, which maintains the state of the most recent data.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since I added the cache option to my manager declaration I thought it wasn't enabled by default but I guess it is |
||
|
|
||
| 1. What metrics does the controller runtime emit? Describe what some of those metrics represent | ||
| 1. What metrics does the controller runtime emit? Describe what some of those metrics represent: Reconcile time: how long reconciliation took, controller_runtime_reconcile_total Total number of reconciliations per controller, go_gc_duration_seconds A summary of the pause duration of garbage collection cycles, go_goroutines Number of goroutines that currently exist, workqueue_depth Current depth of workqueue, workqueue_longest_running_processor_seconds How many seconds has the longest running processor for workqueue been running, workqueue_queue_duration_seconds How long in seconds an item stays in workqueue before being requested, workqueue_unfinished_work_seconds How many seconds of work has been done that is in progress and hasn't been observed by work_duration. Large values indicate stuck threads. One can deduce the number of stuck threads by observing the rate at which this increases, workqueue_work_duration_seconds How long in seconds processing an item from workqueue takes. | ||
| controller_runtime_terminal_reconcile_errors_total Total number of terminal reconciliation errors per controller | ||
| TYPE controller_runtime_terminal_reconcile_errors_total counter | ||
| controller_runtime_terminal_reconcile_errors_total{controller="myapp"} 0 | ||
|
|
||
| 1. What is leader election, and when would you use it? | ||
| 1. What is leader election, and when would you use it? It is used to designate one instance of a controller as the leader to perform reconciliation, change cluster state, etc... It is used in distributed systems to prevent conflicts and ensure consistency | ||
|
|
||
| 1. What is the difference between Kubebuilder and controller runtime? | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Take a look at this article https://www.redhat.com/en/blog/kubernetes-operators-best-practices#:~:text=Deriving%20from%20electronic%20circuit%20design,reacting%20to%20a%20state%20variation.
So level based reconciliation happens periodically, without an event occurring. Can you find the option for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In older versions of controller runtime there was a resync option while creating a manager it used to be directly accessible through ctrl.Options but now it has to be done through the cache option and I used it in my kubebuilder implementation. During the creation of the manager I added the following option: Cache: cache.Options{
SyncPeriod: &syncPeriod}