Skip to content

Commit 494e7b9

Browse files
Joseph-Irvingmrbobbytables
authored andcommitted
sidecar: Add alternatives considered for sidecars
Co-Authored-By: Bob Killen <[email protected]>
1 parent a3ed3d5 commit 494e7b9

File tree

1 file changed

+96
-3
lines changed

1 file changed

+96
-3
lines changed

keps/sig-node/0753-sidecarcontainers.md

Lines changed: 96 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,12 @@ status: provisional
5555
- [Version Skew Strategy](#version-skew-strategy)
5656
- [Implementation History](#implementation-history)
5757
- [Alternatives](#alternatives)
58+
- [Add a pod.spec.SidecarContainers array](#add-a-podspecsidecarcontainers-array)
59+
- [Mark one container as the Primary Container](#mark-one-container-as-the-primary-container)
60+
- [Boolean flag on container, Sidecar: true](#boolean-flag-on-container-sidecar-true)
61+
- [Mark containers whose termination kills the pod, terminationFatalToPod: true](#mark-containers-whose-termination-kills-the-pod-terminationfataltopod-true)
62+
- [Add &quot;Depends On&quot; semantics to containers](#add-depends-on-semantics-to-containers)
63+
- [Pre-defined phases for container startup/shutdown or arbitrary numbers for ordering](#pre-defined-phases-for-container-startupshutdown-or-arbitrary-numbers-for-ordering)
5864
<!-- /toc -->
5965

6066
## Release Signoff Checklist
@@ -314,9 +320,96 @@ Older Kubelets should still be able to schedule Pods that have sidecar container
314320
[stalled]: https://github.com/kubernetes/enhancements/issues/753#issuecomment-597372056
315321

316322
## Alternatives
323+
This section contains ideas that were originally discussed but then dismissed in favour of the current design.
324+
It also includes some links to related discussion on each topic to give some extra context, however not all decisions are documented in Github prs and may have been discussed in sig-meetings or in slack etc.
325+
### Add a pod.spec.SidecarContainers array
326+
An early idea was to have a separate list of containers in a similar style to init containers, they would have behaved in the same way that the current KEP details. The reason this was dismissed was due to it being considered too large a change to the API that would require a lot of updates to tooling, for a feature that in most respects would act the same as a normal container.
317327

318-
One alternative would be to have a new field in the Pod Spec of `sidecarContainers:` where you could define a list of sidecar containers, however this would require more work in terms of updating tooling/kubelet to support this.
328+
```yaml
329+
initContainers:
330+
- name: myInit
331+
containers:
332+
- name: myApp
333+
sidecarContainers:
334+
- name: mySidecar
335+
```
336+
Discussion links:
337+
https://github.com/kubernetes/community/pull/2148#issuecomment-388813902
338+
https://github.com/kubernetes/community/pull/2148#discussion_r221103216
339+
340+
### Mark one container as the Primary Container
341+
The primary container idea was specific to solving the issue of Jobs that don't complete with a sidecar, the suggestion was to have one container marked as the primary so that the Job would get completed when that container has finished. This was dismissed as it was too specific to Jobs whereas the more generic issues of sidecars could be useful in other places.
342+
```yaml
343+
kind: Job
344+
spec:
345+
template:
346+
spec:
347+
containers:
348+
- name: worker
349+
command: ["do a job"]
350+
- name: "sidecar"
351+
command: ["help"]
352+
backoffLimit: 4
353+
primaryContainer: worker
354+
```
355+
Discussion links:
356+
https://github.com/kubernetes/community/pull/2148#discussion_r192846570
319357
320-
Another alternative would be to change the Job Spec to have a `primaryContainer` field to tell it which containers are important. However I feel this is perhaps too specific to job when this Sidecar concept could be useful in other scenarios.
358+
### Boolean flag on container, Sidecar: true
359+
```yaml
360+
containers:
361+
- name: myApp
362+
- name: mySidecar
363+
sidecar: true
364+
```
365+
A boolean flag of `sidecar: true` could be used to indicate which pods are sidecars, this was dismissed as it was considered too specific and potentially other types of container lifecycle may want to be added in the future.
321366

322-
A boolean flag of `sidecar: true` could be used to indicate which pods are sidecars, however this prevents additional ContainerLifecycles from being added in the future.
367+
### Mark containers whose termination kills the pod, terminationFatalToPod: true
368+
This suggestion was to have the ability to mark certain containers as critical to the pod, if they exited it would cause the other containers to exit. While this helped solve things like Jobs it didn't solve the wider issue of ordering startup and shutdown.
369+
370+
```yaml
371+
containers:
372+
- name: myApp
373+
terminationFatalToPod: true
374+
- name: mySidecar
375+
```
376+
Discussion links:
377+
https://github.com/kubernetes/community/pull/2148#issuecomment-414806613
378+
379+
### Add "Depends On" semantics to containers
380+
Similar to [systemd](https://www.freedesktop.org/wiki/Software/systemd/) this would allow you to specify that a container depends on another container, preventing that container from starting until the container it depends on has also started. This could also be used in shutdown to ensure that the containers which have dependent containers are only terminated after their dependents have all safely shut down.
381+
```yaml
382+
containers:
383+
- name: myApp
384+
dependsOn: mySidecar
385+
- name: mySidecar
386+
```
387+
This was rejected as the UX was considered to be overly complicated for the use cases that we were trying to solve. It also doesn't solve the problem of Job termination where you want the sidecars to be terminated once the main containers have exited, to do that you would require some additional fields that would further complicate the UX.
388+
Discussion links:
389+
https://github.com/kubernetes/community/pull/2148#discussion_r203071377
390+
391+
### Pre-defined phases for container startup/shutdown or arbitrary numbers for ordering
392+
There were a few variations of this but they all had a similar idea which was the ability to order both the shutdown and startup of containers using phases or numbers to determine the ordering.
393+
examples:
394+
```yaml
395+
containers:
396+
- name: myApp
397+
StartupPhase: default
398+
- name: mySidecar
399+
StartupPhase: post-init
400+
```
401+
402+
```yaml
403+
containers:
404+
- name: myApp
405+
startupOrder: 2
406+
shutdownOrder: 1
407+
- name: mySidecar
408+
startupOrder: 2
409+
shutdownOrder: 1
410+
```
411+
This was dismissed as the UX was considered overly complex for the use cases we were trying to enable and also lacked the semantics around container shutdown triggering for things like Jobs.
412+
Discussion links:
413+
https://github.com/kubernetes/community/pull/2148#issuecomment-424494976
414+
https://github.com/kubernetes/community/pull/2148#discussion_r221094552
415+
https://github.com/kubernetes/enhancements/pull/841#discussion_r257906512

0 commit comments

Comments
 (0)