Skip to content

Commit 7e393ab

Browse files
committed
Update Ephemeral Containers KEP for 1.16 release
These are changes to implementation that happened during API review. This updates the KEP to match actual implementation in 1.16.
1 parent ac738ac commit 7e393ab

File tree

1 file changed

+45
-10
lines changed

1 file changed

+45
-10
lines changed

keps/sig-node/20190212-ephemeral-containers.md

Lines changed: 45 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ approvers:
1313
- "@liggitt"
1414
editor: TBD
1515
creation-date: 2019-02-12
16-
last-updated: 2019-02-13
16+
last-updated: 2019-10-02
1717
status: implementable
1818
---
1919

@@ -96,7 +96,7 @@ Check these off as they are completed for the Release Team to track. These check
9696
## Summary
9797

9898
This proposal adds to Kubernetes a mechanism to run a container with a
99-
temporary duration that executes within namespaces of an existing pod.
99+
temporary duration that executes within namespaces of an existing pod.
100100
Ephemeral Containers are initiated by a user and intended to observe the state
101101
of other pods and containers for troubleshooting and debugging purposes.
102102

@@ -193,26 +193,37 @@ type PodSpec struct {
193193
// +optional
194194
// +patchMergeKey=name
195195
// +patchStrategy=merge
196-
EphemeralContainers []EphemeralContainer `json:"ephemeralContainers,omitempty" patchStrategy:"merge" patchMergeKey:"name" protobuf:"bytes,31,rep,name=ephemeralContainers"`
196+
EphemeralContainers []EphemeralContainer `json:"ephemeralContainers,omitempty" patchStrategy:"merge" patchMergeKey:"name" protobuf:"bytes,34,rep,name=ephemeralContainers"`
197197
}
198198
199199
type PodStatus struct {
200200
...
201201
// Status for any Ephemeral Containers that running in this pod.
202202
// This field is alpha-level and is only honored by servers that enable the EphemeralContainers feature.
203203
// +optional
204-
EphemeralContainerStatuses []ContainerStatus `json:"ephemeralContainerStatuses,omitempty" protobuf:"bytes,12,rep,name=ephemeralContainerStatuses"`
204+
EphemeralContainerStatuses []ContainerStatus `json:"ephemeralContainerStatuses,omitempty" protobuf:"bytes,13,rep,name=ephemeralContainerStatuses"`
205205
}
206206
```
207207

208208
`EphemeralContainerStatuses` resembles the existing `ContainerStatuses` and
209209
`InitContainerStatuses`, but `EphemeralContainers` introduces a new type:
210210

211211
```
212-
// An EphemeralContainer is a container which runs temporarily in a pod for human-initiated actions
213-
// such as troubleshooting. This is an alpha feature enabled by the EphemeralContainers feature flag.
212+
// An EphemeralContainer is a container that may be added temporarily to an existing pod for
213+
// user-initiated activities such as debugging. Ephemeral containers have no resource or
214+
// scheduling guarantees, and they will not be restarted when they exit or when a pod is
215+
// removed or restarted. If an ephemeral container causes a pod to exceed its resource
216+
// allocation, the pod may be evicted.
217+
// Ephemeral containers may not be added by directly updating the pod spec. They must be added
218+
// via the pod's ephemeralcontainers subresource, and they will appear in the pod spec
219+
// once added.
220+
// This is an alpha feature enabled by the EphemeralContainers feature flag.
214221
type EphemeralContainer struct {
215-
Container `json:",inline" protobuf:"bytes,1,opt,name=container"`
222+
// Ephemeral containers have all of the fields of Container, plus additional fields
223+
// specific to ephemeral containers. Fields in common with Container are in the
224+
// following inlined struct so than an EphemeralContainer may easily be converted
225+
// to a Container.
226+
EphemeralContainerCommon `json:",inline" protobuf:"bytes,1,req"`
216227
217228
// If set, the name of the container from PodSpec that this ephemeral container targets.
218229
// The ephemeral container will be run in the namespaces (IPC, PID, etc) of this container.
@@ -228,6 +239,30 @@ container within the PID namespace of another container. `TargetContainerName`
228239
allows targeting a container that doesn't share its PID namespace with the rest
229240
of the pod. We must modify the CRI to enable this functionality (see below).
230241

242+
`EphemeralContainerCommon` is an inline copy of `Container` that resolves the
243+
following contradictory requirements:
244+
245+
1. Ephemeral containers should be represented by a type that is easily
246+
convertible to `Container` so that code that operations on `Container` can
247+
also operate on ephemeral containers.
248+
1. Fields of `Container` that have different behavior for ephemeral containers
249+
should be separately and clearly documented. Since many fields of ephemeral
250+
containers have different behavior, this requires a separate type.
251+
252+
`EphemeralContainerCommon` contains fields that ephemeral containers have in
253+
common with `Container`. It's field-for-field copy of `Container`, which is
254+
enforced by the compiler:
255+
256+
```
257+
// EphemeralContainerCommon converts to Container. All fields must be kept in sync between
258+
// these two types.
259+
var _ = Container(EphemeralContainerCommon{})
260+
```
261+
262+
Since `EphemeralContainerCommon` is inlined, the API machinery hides this
263+
complexity from the end user, who sees a type, `EphemeralContainer` which has
264+
all of the fields of `Container` plus an additional field `targetContainerName`.
265+
231266
##### Alternative Considered: Omitting TargetContainerName
232267

233268
It would be simpler for the API, kubelet and kubectl if `EphemeralContainers`
@@ -293,8 +328,8 @@ The CRI requires no changes for basic functionality, but it will need to be
293328
updated to support container namespace targeting, described fully in
294329
[Targeting a Namespace].
295330

296-
[Process Namespace Sharing]: https://git.k8s.io/community/contributors/design-proposals/node/pod-pid-namespace.md
297-
[Targeting a Namespace]: https://git.k8s.io/community/contributors/design-proposals/node/pod-pid-namespace.md#targeting-a-specific-containers-namespace
331+
[Process Namespace Sharing]: https://git.k8s.io/enhancements/keps/sig-node/20190920-pod-pid-namespace.md
332+
[Targeting a Namespace]: https://git.k8s.io/enhancements/keps/sig-node/20190920-pod-pid-namespace.md#targeting-a-specific-containers-namespace
298333

299334
### Creating Ephemeral Containers
300335

@@ -798,4 +833,4 @@ other binaries from the node, making it of limited utility and a confusing user
798833
experience.
799834

800835
This couples the debug tools with the lifecycle of the node, which is worse than
801-
coupling it with container images.
836+
coupling it with container images.

0 commit comments

Comments
 (0)