Skip to content

Commit 8ad75f2

Browse files
committed
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]>
1 parent d917695 commit 8ad75f2

File tree

1 file changed

+16
-17
lines changed

1 file changed

+16
-17
lines changed

keps/sig-node/0753-sidecarcontainers.md

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -472,15 +472,25 @@ any other container crashes.
472472
If this behaviour is not welcome, however, code probably can be adapted to
473473
handle the case when all containers crashed differently.
474474

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
476486

477487
The proposal can broken down into four key pieces of implementation that all relatively separate from one another:
478488

479489
* Shutdown triggering for sidecars when RestartPolicy!=Always
480490
* Sidecars are terminated after normal containers
481491
* Sidecars start before normal containers
482492

483-
#### API Changes:
493+
### API Changes:
484494
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).
485495

486496
New field `Type` will be added to the lifecycle struct:
@@ -508,15 +518,15 @@ const (
508518
```
509519
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.
510520

511-
#### Kubelet Changes:
521+
### Kubelet Changes:
512522
Broad outline of what places could be modified to implement desired behaviour:
513523

514-
##### Shutdown triggering
524+
#### Shutdown triggering
515525
Package `kuberuntime`
516526

517527
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.
518528

519-
##### Sidecars terminated last
529+
#### Sidecars terminated last
520530
Package `kuberuntime`
521531

522532
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,
527537
on preStop hooks too. See the [caveats](#notesconstraintscaveats) section for more details on why this
528538
is needed.
529539

530-
##### Sidecars started first
540+
#### Sidecars started first
531541
Package `kuberuntime`
532542

533543
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:
562572
[kinvolk-poc-sidecar-test]: https://github.com/kinvolk/kubernetes/tree/52a96112b3e7878740a0945ad3fc4c6d0a6c5227/sidecar-tests
563573
[kinvolk-poc-sidecar-test-commit]: https://github.com/kinvolk/kubernetes/commit/385a89d83df9c076963d2943507d1527ffa606f7
564574

565-
### Risks and Mitigations
566-
567-
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
576575

577576
### Test Plan
578577
* Units test in kubelet package `kuberuntime` primarily in the same style as `TestComputePodActions` to test a variety of scenarios.

0 commit comments

Comments
 (0)