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
/// Replace the ephemeral containers sub resource entirely.
145
+
///
146
+
/// This functions in the same way as [`Api::replace`] except only `.spec.ephemeralcontainers` is replaced, everything else is ignored.
147
+
///
148
+
/// Note that ephemeral containers may **not** be changed or removed once attached to a pod.
149
+
///
150
+
///
151
+
/// You way want to patch the underlying resource to gain access to the main container process,
152
+
/// see the [documentation](https://kubernetes.io/docs/tasks/configure-pod-container/share-process-namespace/) for `sharedProcessNamespace`.
153
+
///
154
+
/// See the Kubernetes [documentation](https://kubernetes.io/docs/concepts/workloads/pods/ephemeral-containers/#what-is-an-ephemeral-container) for more details.
155
+
///
156
+
/// [`Api::patch_ephemeral_containers`] may be more ergonomic, as you can will avoid having to first fetch the
157
+
/// existing subresources with an approriate merge strategy, see the examples for more details.
158
+
///
159
+
/// Example of using `replace_ephemeral_containers`:
/// If an invalid patch is provided the method will **not** always return
210
+
/// an error and no changes will be made to the target object in
211
+
/// the cluster, see the examples below.
212
+
///
213
+
/// Any partial object containing the ephemeral containers
214
+
/// sub resource is valid as long as the complete structure
215
+
/// for the object is present, as shown below.
216
+
///
217
+
/// You way want to patch the underlying resource to gain access to the main container process,
218
+
/// see the [docs](https://kubernetes.io/docs/tasks/configure-pod-container/share-process-namespace/) for `sharedProcessNamespace`.
219
+
///
220
+
/// Ephemeral containers may **not** be changed or removed once attached to a pod.
221
+
/// Therefore if the chosen merge strategy overwrites the existing ephemeral containers,
222
+
/// you will have to fetch the existing ephemeral containers first.
223
+
/// In order to append your new ephemeral containers to the existing list before patching. See some examples and
224
+
/// discussion related to merge strategies in Kubernetes
225
+
/// [here](https://kubernetes.io/docs/tasks/manage-kubernetes-objects/update-api-object-kubectl-patch/#use-a-json-merge-patch-to-update-a-deployment). The example below uses a strategic merge patch which does not require
226
+
///
227
+
/// See the `Kubernetes` [documentation](https://kubernetes.io/docs/concepts/workloads/pods/ephemeral-containers/)
228
+
/// for more information about ephemeral containers.
229
+
///
230
+
/// **Valid and invalid Examples for patching a pod**
231
+
///
232
+
/// Valid as this can be merged with a complete Pod object:
233
+
/// ```rust,no_run
234
+
/// let patch = serde_json::json!({
235
+
/// "spec":{
236
+
/// "ephemeralContainers": [
237
+
/// {
238
+
/// "name": "myephemeralcontainer",
239
+
/// "image": "busybox:1.34.1",
240
+
/// "command": ["sh", "-c", "sleep 20"],
241
+
/// },
242
+
/// ]
243
+
/// }});
244
+
///
245
+
/// ```
246
+
///
247
+
/// Not valid as the outer layer of the `Pod` object is missing, instead
248
+
/// we have provided a partial `Pod` spec. Again note that no error will
249
+
/// be returned, the patch will simply have no effect.
250
+
/// ```rust,no_run
251
+
/// let patch = serde_json::json!(
252
+
/// {
253
+
/// "ephemeralContainers": [
254
+
/// {
255
+
/// "name": "myephemeralcontainer",
256
+
/// "image": "busybox:1.34.1",
257
+
/// "command": ["sh", "-c", "sleep 20"],
258
+
/// },
259
+
/// ]
260
+
/// });
261
+
/// ```
262
+
///
263
+
/// Example of using `patch_ephemeral_containers`:
264
+
///
265
+
/// ```rust,no_run
266
+
/// # use kube::{api::{Api, PatchParams, Patch}, Client};
0 commit comments