cleanup: EphemeralContainers feature gate related codes

This commit is contained in:
Paco Xu 2022-12-16 23:46:47 +08:00
parent c9ed04762f
commit 70e56fa71a
13 changed files with 15 additions and 43 deletions

View File

@ -116,7 +116,6 @@ func ephemeralContainerStartSpec(ec *v1.EphemeralContainer) *startSpec {
// targeting. The target is stored as EphemeralContainer.TargetContainerName, which must be
// resolved to a ContainerID using podStatus. The target container must already exist, which
// usually isn't a problem since ephemeral containers aren't allowed at pod creation time.
// This always returns nil when the EphemeralContainers feature is disabled.
func (s *startSpec) getTargetID(podStatus *kubecontainer.PodStatus) (*kubecontainer.ContainerID, error) {
if s.ephemeralContainer == nil || s.ephemeralContainer.TargetContainerName == "" {
return nil, nil

View File

@ -496,7 +496,7 @@ var (
&metrics.GaugeOpts{
Subsystem: KubeletSubsystem,
Name: ManagedEphemeralContainersKey,
Help: "Current number of ephemeral containers in pods managed by this kubelet. Ephemeral containers will be ignored if disabled by the EphemeralContainers feature gate, and this number will be 0.",
Help: "Current number of ephemeral containers in pods managed by this kubelet.",
StabilityLevel: metrics.ALPHA,
},
)

View File

@ -1458,7 +1458,7 @@
"type": "object"
},
"io.k8s.api.core.v1.EphemeralContainer": {
"description": "An EphemeralContainer is a container that may be added temporarily to an existing pod for user-initiated activities such as debugging. Ephemeral containers have no resource or scheduling guarantees, and they will not be restarted when they exit or when a pod is removed or restarted. If an ephemeral container causes a pod to exceed its resource allocation, the pod may be evicted. Ephemeral containers may not be added by directly updating the pod spec. They must be added via the pod's ephemeralcontainers subresource, and they will appear in the pod spec once added. This is an alpha feature enabled by the EphemeralContainers feature flag.",
"description": "An EphemeralContainer is a container that may be added temporarily to an existing pod for user-initiated activities such as debugging. Ephemeral containers have no resource or scheduling guarantees, and they will not be restarted when they exit or when a pod is removed or restarted. If an ephemeral container causes a pod to exceed its resource allocation, the pod may be evicted. Ephemeral containers may not be added by directly updating the pod spec. They must be added via the pod's ephemeralcontainers subresource, and they will appear in the pod spec once added.",
"properties": {
"args": {
"description": "Arguments to the entrypoint. The container image's CMD is used if this is not provided. Variable references $(VAR_NAME) are expanded using the container's environment. If a variable cannot be resolved, the reference in the input string will be unchanged. The $(VAR_NAME) syntax can be escaped with a double $$, ie: $$(VAR_NAME). Escaped references will never be expanded, regardless of whether the variable exists or not. Cannot be updated. More info: https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#running-a-command-in-a-shell",
@ -2436,7 +2436,7 @@
"type": "boolean"
},
"ephemeralContainers": {
"description": "List of ephemeral containers run in this pod. Ephemeral containers may be run in an existing pod to perform user-initiated actions such as debugging. This list cannot be specified when creating a pod, and it cannot be modified by updating the pod spec. In order to add an ephemeral container to an existing pod, use the pod's ephemeralcontainers subresource. This field is alpha-level and is only honored by servers that enable the EphemeralContainers feature.",
"description": "List of ephemeral containers run in this pod. Ephemeral containers may be run in an existing pod to perform user-initiated actions such as debugging. This list cannot be specified when creating a pod, and it cannot be modified by updating the pod spec. In order to add an ephemeral container to an existing pod, use the pod's ephemeralcontainers subresource.",
"items": {
"$ref": "#/definitions/io.k8s.api.core.v1.EphemeralContainer"
},
@ -2618,7 +2618,7 @@
"type": "array"
},
"ephemeralContainerStatuses": {
"description": "Status for any ephemeral containers that have run in this pod. This field is alpha-level and is only populated by servers that enable the EphemeralContainers feature.",
"description": "Status for any ephemeral containers that have run in this pod.",
"items": {
"$ref": "#/definitions/io.k8s.api.core.v1.ContainerStatus"
},

View File

@ -6103,7 +6103,7 @@
"type": "object"
},
"io.k8s.api.core.v1.EphemeralContainer": {
"description": "An EphemeralContainer is a temporary container that you may add to an existing Pod for user-initiated activities such as debugging. Ephemeral containers have no resource or scheduling guarantees, and they will not be restarted when they exit or when a Pod is removed or restarted. The kubelet may evict a Pod if an ephemeral container causes the Pod to exceed its resource allocation.\n\nTo add an ephemeral container, use the ephemeralcontainers subresource of an existing Pod. Ephemeral containers may not be removed or restarted.\n\nThis is a beta feature available on clusters that haven't disabled the EphemeralContainers feature gate.",
"description": "An EphemeralContainer is a temporary container that you may add to an existing Pod for user-initiated activities such as debugging. Ephemeral containers have no resource or scheduling guarantees, and they will not be restarted when they exit or when a Pod is removed or restarted. The kubelet may evict a Pod if an ephemeral container causes the Pod to exceed its resource allocation.\n\nTo add an ephemeral container, use the ephemeralcontainers subresource of an existing Pod. Ephemeral containers may not be removed or restarted.",
"properties": {
"args": {
"description": "Arguments to the entrypoint. The image's CMD is used if this is not provided. Variable references $(VAR_NAME) are expanded using the container's environment. If a variable cannot be resolved, the reference in the input string will be unchanged. Double $$ are reduced to a single $, which allows for escaping the $(VAR_NAME) syntax: i.e. \"$$(VAR_NAME)\" will produce the string literal \"$(VAR_NAME)\". Escaped references will never be expanded, regardless of whether the variable exists or not. Cannot be updated. More info: https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#running-a-command-in-a-shell",
@ -8592,7 +8592,7 @@
"type": "boolean"
},
"ephemeralContainers": {
"description": "List of ephemeral containers run in this pod. Ephemeral containers may be run in an existing pod to perform user-initiated actions such as debugging. This list cannot be specified when creating a pod, and it cannot be modified by updating the pod spec. In order to add an ephemeral container to an existing pod, use the pod's ephemeralcontainers subresource. This field is beta-level and available on clusters that haven't disabled the EphemeralContainers feature gate.",
"description": "List of ephemeral containers run in this pod. Ephemeral containers may be run in an existing pod to perform user-initiated actions such as debugging. This list cannot be specified when creating a pod, and it cannot be modified by updating the pod spec. In order to add an ephemeral container to an existing pod, use the pod's ephemeralcontainers subresource.",
"items": {
"$ref": "#/definitions/io.k8s.api.core.v1.EphemeralContainer"
},
@ -8788,7 +8788,7 @@
"type": "array"
},
"ephemeralContainerStatuses": {
"description": "Status for any ephemeral containers that have run in this pod. This field is beta-level and available on clusters that haven't disabled the EphemeralContainers feature gate.",
"description": "Status for any ephemeral containers that have run in this pod.",
"items": {
"$ref": "#/definitions/io.k8s.api.core.v1.ContainerStatus"
},

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -75,11 +75,9 @@ var (
debugExample = templates.Examples(i18n.T(`
# Create an interactive debugging session in pod mypod and immediately attach to it.
# (requires the EphemeralContainers feature to be enabled in the cluster)
kubectl debug mypod -it --image=busybox
# Create a debug container named debugger using a custom automated debugging image.
# (requires the EphemeralContainers feature to be enabled in the cluster)
kubectl debug --image=myproj/debug-tools -c debugger mypod
# Create a copy of mypod adding a debug container and attach to it
@ -296,9 +294,6 @@ func (o *DebugOptions) Validate() error {
return fmt.Errorf("--target is incompatible with --copy-to. Use --share-processes instead.")
}
if !o.Quiet {
// If the runtime doesn't support container namespace targeting this will fail silently, which has caused
// some confusion (ex: https://issues.k8s.io/98362), so print a warning. This can be removed when
// EphemeralContainers are generally available.
fmt.Fprintf(o.Out, "Targeting container %q. If you don't see processes from this container it may be because the container runtime doesn't support this feature.\n", o.TargetContainer)
// TODO(verb): Add a list of supported container runtimes to https://kubernetes.io/docs/concepts/workloads/pods/ephemeral-containers/ and then link here.
}
@ -447,7 +442,7 @@ func (o *DebugOptions) debugByEphemeralContainer(ctx context.Context, pod *corev
// The apiserver will return a 404 when the EphemeralContainers feature is disabled because the `/ephemeralcontainers` subresource
// is missing. Unlike the 404 returned by a missing pod, the status details will be empty.
if serr, ok := err.(*errors.StatusError); ok && serr.Status().Reason == metav1.StatusReasonNotFound && serr.ErrStatus.Details.Name == "" {
return nil, "", fmt.Errorf("ephemeral containers are disabled for this cluster (error from server: %q).", err)
return nil, "", fmt.Errorf("ephemeral containers are disabled for this cluster (error from server: %q)", err)
}
// The Kind used for the /ephemeralcontainers subresource changed in 1.22. When presented with an unexpected

View File

@ -712,14 +712,10 @@ msgid ""
"\n"
"\t\t# Create an interactive debugging session in pod mypod and immediately "
"attach to it.\n"
"\t\t# (requires the EphemeralContainers feature to be enabled in the "
"cluster)\n"
"\t\tkubectl debug mypod -it --image=busybox\n"
"\n"
"\t\t# Create a debug container named debugger using a custom automated "
"debugging image.\n"
"\t\t# (requires the EphemeralContainers feature to be enabled in the "
"cluster)\n"
"\t\tkubectl debug --image=myproj/debug-tools -c debugger mypod\n"
"\n"
"\t\t# Create a copy of mypod adding a debug container and attach to it\n"
@ -746,14 +742,10 @@ msgstr ""
"\n"
"\t\t# Create an interactive debugging session in pod mypod and immediately "
"attach to it.\n"
"\t\t# (requires the EphemeralContainers feature to be enabled in the "
"cluster)\n"
"\t\tkubectl debug mypod -it --image=busybox\n"
"\n"
"\t\t# Create a debug container named debugger using a custom automated "
"debugging image.\n"
"\t\t# (requires the EphemeralContainers feature to be enabled in the "
"cluster)\n"
"\t\tkubectl debug --image=myproj/debug-tools -c debugger mypod\n"
"\n"
"\t\t# Create a copy of mypod adding a debug container and attach to it\n"

View File

@ -712,14 +712,10 @@ msgid ""
"\n"
"\t\t# Create an interactive debugging session in pod mypod and immediately "
"attach to it.\n"
"\t\t# (requires the EphemeralContainers feature to be enabled in the "
"cluster)\n"
"\t\tkubectl debug mypod -it --image=busybox\n"
"\n"
"\t\t# Create a debug container named debugger using a custom automated "
"debugging image.\n"
"\t\t# (requires the EphemeralContainers feature to be enabled in the "
"cluster)\n"
"\t\tkubectl debug --image=myproj/debug-tools -c debugger mypod\n"
"\n"
"\t\t# Create a copy of mypod adding a debug container and attach to it\n"
@ -746,14 +742,10 @@ msgstr ""
"\n"
"\t\t# Create an interactive debugging session in pod mypod and immediately "
"attach to it.\n"
"\t\t# (requires the EphemeralContainers feature to be enabled in the "
"cluster)\n"
"\t\tkubectl debug mypod -it --image=busybox\n"
"\n"
"\t\t# Create a debug container named debugger using a custom automated "
"debugging image.\n"
"\t\t# (requires the EphemeralContainers feature to be enabled in the "
"cluster)\n"
"\t\tkubectl debug --image=myproj/debug-tools -c debugger mypod\n"
"\n"
"\t\t# Create a copy of mypod adding a debug container and attach to it\n"

View File

@ -409,14 +409,10 @@ msgid ""
"\n"
"\t\t# Create an interactive debugging session in pod mypod and immediately "
"attach to it.\n"
"\t\t# (requires the EphemeralContainers feature to be enabled in the "
"cluster)\n"
"\t\tkubectl debug mypod -it --image=busybox\n"
"\n"
"\t\t# Create a debug container named debugger using a custom automated "
"debugging image.\n"
"\t\t# (requires the EphemeralContainers feature to be enabled in the "
"cluster)\n"
"\t\tkubectl debug --image=myproj/debug-tools -c debugger mypod\n"
"\n"
"\t\t# Create a copy of mypod adding a debug container and attach to it\n"

View File

@ -6447,7 +6447,7 @@
"type": "object"
},
"io.k8s.api.core.v1.EphemeralContainer": {
"description": "An EphemeralContainer is a container that may be added temporarily to an existing pod for user-initiated activities such as debugging. Ephemeral containers have no resource or scheduling guarantees, and they will not be restarted when they exit or when a pod is removed or restarted. If an ephemeral container causes a pod to exceed its resource allocation, the pod may be evicted. Ephemeral containers may not be added by directly updating the pod spec. They must be added via the pod's ephemeralcontainers subresource, and they will appear in the pod spec once added. This is an alpha feature enabled by the EphemeralContainers feature flag.",
"description": "An EphemeralContainer is a container that may be added temporarily to an existing pod for user-initiated activities such as debugging. Ephemeral containers have no resource or scheduling guarantees, and they will not be restarted when they exit or when a pod is removed or restarted. If an ephemeral container causes a pod to exceed its resource allocation, the pod may be evicted. Ephemeral containers may not be added by directly updating the pod spec. They must be added via the pod's ephemeralcontainers subresource, and they will appear in the pod spec once added.",
"properties": {
"args": {
"description": "Arguments to the entrypoint. The container image's CMD is used if this is not provided. Variable references $(VAR_NAME) are expanded using the container's environment. If a variable cannot be resolved, the reference in the input string will be unchanged. The $(VAR_NAME) syntax can be escaped with a double $$, ie: $$(VAR_NAME). Escaped references will never be expanded, regardless of whether the variable exists or not. Cannot be updated. More info: https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#running-a-command-in-a-shell",
@ -8819,7 +8819,7 @@
"type": "boolean"
},
"ephemeralContainers": {
"description": "List of ephemeral containers run in this pod. Ephemeral containers may be run in an existing pod to perform user-initiated actions such as debugging. This list cannot be specified when creating a pod, and it cannot be modified by updating the pod spec. In order to add an ephemeral container to an existing pod, use the pod's ephemeralcontainers subresource. This field is alpha-level and is only honored by servers that enable the EphemeralContainers feature.",
"description": "List of ephemeral containers run in this pod. Ephemeral containers may be run in an existing pod to perform user-initiated actions such as debugging. This list cannot be specified when creating a pod, and it cannot be modified by updating the pod spec. In order to add an ephemeral container to an existing pod, use the pod's ephemeralcontainers subresource.",
"items": {
"$ref": "#/definitions/io.k8s.api.core.v1.EphemeralContainer"
},
@ -9005,7 +9005,7 @@
"type": "array"
},
"ephemeralContainerStatuses": {
"description": "Status for any ephemeral containers that have run in this pod. This field is alpha-level and is only populated by servers that enable the EphemeralContainers feature.",
"description": "Status for any ephemeral containers that have run in this pod.",
"items": {
"$ref": "#/definitions/io.k8s.api.core.v1.ContainerStatus"
},

View File

@ -778,9 +778,7 @@
stabilityLevel: ALPHA
- name: managed_ephemeral_containers
subsystem: kubelet
help: Current number of ephemeral containers in pods managed by this kubelet. Ephemeral
containers will be ignored if disabled by the EphemeralContainers feature gate,
and this number will be 0.
help: Current number of ephemeral containers in pods managed by this kubelet.
type: Gauge
stabilityLevel: ALPHA
- name: node_name

View File

@ -1521,7 +1521,7 @@ components using an HTTP scrape, and fetch the current metrics data in Prometheu
<tr class="metric"><td class="metric_name">kubelet_managed_ephemeral_containers</td>
<td class="metric_stability_level" data-stability="alpha">ALPHA</td>
<td class="metric_type" data-type="gauge">Gauge</td>
<td class="metric_description">Current number of ephemeral containers in pods managed by this kubelet. Ephemeral containers will be ignored if disabled by the EphemeralContainers feature gate, and this number will be 0.</td>
<td class="metric_description">Current number of ephemeral containers in pods managed by this kubelet.</td>
<td class="metric_labels_varying"></td>
<td class="metric_labels_constant"></td>
<td class="metric_deprecated_version"></td></tr>