You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
sidecar: Merge "Implementation Details" and "Design Details" sections
There were two sections with caveats in their name otherwise. Also, this
is more similar to the latest KEP template.
The diff looks tricky just because the text is being moved 2 sections
below. However, git creates a diff showing the unchanged section is
moved up instead.
Signed-off-by: Rodrigo Campos <[email protected]>
Copy file name to clipboardExpand all lines: keps/sig-node/0753-sidecarcontainers.md
+16-17Lines changed: 16 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -472,15 +472,25 @@ any other container crashes.
472
472
If this behaviour is not welcome, however, code probably can be adapted to
473
473
handle the case when all containers crashed differently.
474
474
475
-
### Implementation Details/Notes/Constraints
475
+
### Risks and Mitigations
476
+
477
+
You could set all containers to have `lifecycle.type: Sidecar`, this would cause strange behaviour in regards to shutting down the sidecars when all the non-sidecars have exited. To solve this the api could do a validation check that at least one container is not a sidecar.
478
+
479
+
Init containers would be able to have `lifecycle.type: Sidecar` applied to them as it's an additional field to the container spec, this doesn't currently make sense as init containers are ran sequentially. We could get around this by having the api throw a validation error if you try to use this field on an init container or just ignore the field.
480
+
481
+
Older Kubelets that don't implement the sidecar logic could have a pod scheduled on them that has the sidecar field. As this field is just an addition to the Container Spec the Kubelet would still be able to schedule the pod, treating the sidecars as if they were just a normal container. This could potentially cause confusion to a user as their pod would not behave in the way they expect, but would avoid pods being unable to schedule.
482
+
483
+
Shutdown ordering of Containers in a Pod can not be guaranteed when a node is being shutdown, this is due to the fact that the Kubelet is not responsible for stopping containers when the node shuts down, it is instead handed off to systemd (when on Linux) which would not be aware of the ordering requirements. Daemonset and static Pods would be the most effected as they are typically not drained from a node before it is shutdown. This could be seen as a larger issue with node shutdown (also effects things like termination grace period) and does not necessarily need to be addressed in this KEP , however it should be clear in the documentation what guarantees we can provide in regards to the ordering.
484
+
485
+
## Design Details
476
486
477
487
The proposal can broken down into four key pieces of implementation that all relatively separate from one another:
478
488
479
489
* Shutdown triggering for sidecars when RestartPolicy!=Always
480
490
* Sidecars are terminated after normal containers
481
491
* Sidecars start before normal containers
482
492
483
-
####API Changes:
493
+
### API Changes:
484
494
As this is a change to the Container spec we will be using feature gating, you will be required to explicitly enable this feature on the api server as recommended [here](https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api_changes.md#adding-unstable-features-to-stable-versions).
485
495
486
496
New field `Type` will be added to the lifecycle struct:
@@ -508,15 +518,15 @@ const (
508
518
```
509
519
Note that currently the `lifecycle` struct is only used for `preStop` and `postStop` so we will need to change its description to reflect the expansion of its uses.
510
520
511
-
####Kubelet Changes:
521
+
### Kubelet Changes:
512
522
Broad outline of what places could be modified to implement desired behaviour:
513
523
514
-
#####Shutdown triggering
524
+
#### Shutdown triggering
515
525
Package `kuberuntime`
516
526
517
527
Modify `kuberuntime_manager.go`, function `computePodActions`. Have a check in this function that will see if all the non-sidecars had permanently exited, if true: return all the running sidecars in `ContainersToKill`. These containers will then be killed via the `killContainer` function which sends preStop hooks, sig-terms and obeys grace period, thus giving the sidecars a chance to gracefully terminate.
518
528
519
-
#####Sidecars terminated last
529
+
#### Sidecars terminated last
520
530
Package `kuberuntime`
521
531
522
532
Modify `kuberuntime_container.go`, function `killContainersWithSyncResult`. Break up the looping over containers so that it goes through killing the non-sidecars before terminating the sidecars.
@@ -527,7 +537,7 @@ To make sure `killContainersWithSyncResult()` finishes in time,
527
537
on preStop hooks too. See the [caveats](#notesconstraintscaveats) section for more details on why this
528
538
is needed.
529
539
530
-
#####Sidecars started first
540
+
#### Sidecars started first
531
541
Package `kuberuntime`
532
542
533
543
Modify `kuberuntime_manager.go`, function `computePodActions`. If pods has sidecars it will return these first in `ContainersToStart`, until they are all ready it will not return the non-sidecars. Readiness changes do not normally trigger a pod sync, so to avoid waiting for the Kubelet's `SyncFrequency` (default 1 minute) we can modify `HandlePodReconcile` in the `kubelet.go` to trigger a sync when the sidecars first become ready (ie only during startup).
@@ -562,17 +572,6 @@ Some other things worth noting about the implementation:
You could set all containers to have `lifecycle.type: Sidecar`, this would cause strange behaviour in regards to shutting down the sidecars when all the non-sidecars have exited. To solve this the api could do a validation check that at least one container is not a sidecar.
568
-
569
-
Init containers would be able to have `lifecycle.type: Sidecar` applied to them as it's an additional field to the container spec, this doesn't currently make sense as init containers are ran sequentially. We could get around this by having the api throw a validation error if you try to use this field on an init container or just ignore the field.
570
-
571
-
Older Kubelets that don't implement the sidecar logic could have a pod scheduled on them that has the sidecar field. As this field is just an addition to the Container Spec the Kubelet would still be able to schedule the pod, treating the sidecars as if they were just a normal container. This could potentially cause confusion to a user as their pod would not behave in the way they expect, but would avoid pods being unable to schedule.
572
-
573
-
Shutdown ordering of Containers in a Pod can not be guaranteed when a node is being shutdown, this is due to the fact that the Kubelet is not responsible for stopping containers when the node shuts down, it is instead handed off to systemd (when on Linux) which would not be aware of the ordering requirements. Daemonset and static Pods would be the most effected as they are typically not drained from a node before it is shutdown. This could be seen as a larger issue with node shutdown (also effects things like termination grace period) and does not necessarily need to be addressed in this KEP , however it should be clear in the documentation what guarantees we can provide in regards to the ordering.
574
-
575
-
## Design Details
576
575
577
576
### Test Plan
578
577
* Units test in kubelet package `kuberuntime` primarily in the same style as `TestComputePodActions` to test a variety of scenarios.
0 commit comments