Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add pod ephemeral containers operations #4758

Closed
cronik opened this issue Jan 12, 2023 Discussed in #4743 · 0 comments · Fixed by #4763
Closed

Add pod ephemeral containers operations #4758

cronik opened this issue Jan 12, 2023 Discussed in #4743 · 0 comments · Fixed by #4763
Assignees
Milestone

Comments

@cronik
Copy link
Contributor

cronik commented Jan 12, 2023

Discussed in #4743

Originally posted by cronik January 7, 2023
Is it possible to call the EphemeralContainers Operations on a Pod resource?

PATCH /api/v1/namespaces/{namespace}/pods/{name}/ephemeralcontainers

It does not appear to be supported directly in the dsl api, but I'm wondering if there is some workaround that might allow me to call the patch operation (maybe by constructing a operations context or something).

Are there plans to support these operations in the dsl? I'd be happy to contribute a PR if it will be welcomed.

Proposed API

Ephemeral containers operations supports PATCH and REPLACE as sub resource of Pod. I propose a new EphemeralContainersResource that exposes the operations supported on this resource.

interface PodResource {
  // ...
  EphemeralContainersResource ephemeralContainers();
}

interface EphemeralContainersResource extends EditReplacePatchable<Pod> { }

class PodOperationsImpl implements EphemeralContainersResource {
    EphemeralContainersResource ephemeralContainers() {
        return new PodOperationsImpl(getContext(), context.withSubresource("ephemeralcontainers"));
    }
}

Example client usage

PodResource resource = client.pods().withName("pod-standard");
resource.ephemeralContainers()
  .edit(p -> new PodBuilder(p)
    .editSpec()
    .addNewEphemeralContainer()
    .withName("debugger-3")
    .withImage("busybox")
    .withCommand("sleep", "36000")
    .endEphemeralContainer()
    .endSpec()
    .build());

resource.waitUntilCondition(p -> {
  return p.getStatus()
      .getEphemeralContainerStatuses()
      .stream()
      .filter(s -> s.getName().equals("debugger-3"))
      .anyMatch(s -> s.getState().getRunning() != null);
  }, 2, TimeUnit.MINUTES);

ByteArrayOutputStream out = new ByteArrayOutputStream();
try (ExecWatch watch = resource.inContainer("debugger-3")
  .writingOutput(out)
  .exec("sh", "-c", "echo 'hello world!'")) {
  assertEquals(0, watch.exitCode().join());
  assertEquals("hello world!", out.toString());
}

https://kubernetes.io/docs/concepts/workloads/pods/ephemeral-containers/

cronik added a commit to cronik/fabric8io-kubernetes-client that referenced this issue Jan 12, 2023
Add new method to PodResource to manager ephemeral containers sub-resource.

Add new interface EphemeralContainersResource to expose operations on this
new operation context and is returned by a new method on PodResource.

OperationContext and OperationSupport have been updated to support implementing operations on named resource sub-resources.

Fixes fabric8io#4758
cronik added a commit to cronik/fabric8io-kubernetes-client that referenced this issue Jan 12, 2023
Add new method to PodResource to manager ephemeral containers sub-resource.

Add new interface EphemeralContainersResource to expose operations on this
new operation context and is returned by a new method on PodResource.

OperationContext and OperationSupport have been updated to support implementing operations on named resource sub-resources.

Fixes fabric8io#4758
cronik added a commit to cronik/fabric8io-kubernetes-client that referenced this issue Jan 12, 2023
Add new interface EphemeralContainersResource to expose operations on this
new operation context and is returned by a new method on PodResource.

OperationContext and OperationSupport have been updated to support implementing operations on named resource sub-resources.

Fixes fabric8io#4758
cronik added a commit to cronik/fabric8io-kubernetes-client that referenced this issue Jan 12, 2023
Add new interface EphemeralContainersResource to expose operations on this
new operation context and is returned by a new method on PodResource.

OperationContext and OperationSupport have been updated to support implementing operations on named resource sub-resources.

Fixes fabric8io#4758
cronik added a commit to cronik/fabric8io-kubernetes-client that referenced this issue Jan 13, 2023
Add new interface EphemeralContainersResource to expose operations on this
new operation context and is returned by a new method on PodResource.

OperationContext and OperationSupport have been updated to support implementing operations on named resource sub-resources.

Fixes fabric8io#4758
cronik added a commit to cronik/fabric8io-kubernetes-client that referenced this issue Jan 15, 2023
Add new interface EphemeralContainersResource to expose operations on this
new operation context and is returned by a new method on PodResource.

OperationContext and OperationSupport have been updated to support implementing operations on named resource sub-resources.

Fixes fabric8io#4758
cronik added a commit to cronik/fabric8io-kubernetes-client that referenced this issue Jan 16, 2023
Add new interface EphemeralContainersResource to expose operations on this
new operation context and is returned by a new method on PodResource.

OperationContext and OperationSupport have been updated to support implementing operations on named resource sub-resources.

Fixes fabric8io#4758
cronik added a commit to cronik/fabric8io-kubernetes-client that referenced this issue Jan 16, 2023
Add new interface EphemeralContainersResource to expose operations on this
new operation context and is returned by a new method on PodResource.

OperationContext and OperationSupport have been updated to support implementing operations on named resource sub-resources.

Fixes fabric8io#4758
cronik added a commit to cronik/fabric8io-kubernetes-client that referenced this issue Jan 17, 2023
Add new interface EphemeralContainersResource to expose operations on this
new operation context and is returned by a new method on PodResource.

OperationContext and OperationSupport have been updated to support implementing operations on named resource sub-resources.

Fixes fabric8io#4758
cronik added a commit to cronik/fabric8io-kubernetes-client that referenced this issue Jan 17, 2023
Add new interface EphemeralContainersResource to expose operations on this
new operation context and is returned by a new method on PodResource.

OperationContext and OperationSupport have been updated to support implementing operations on named resource sub-resources.

Fixes fabric8io#4758
cronik added a commit to cronik/fabric8io-kubernetes-client that referenced this issue Jan 19, 2023
Add new interface EphemeralContainersResource to expose operations on this
new operation context and is returned by a new method on PodResource.

OperationContext and OperationSupport have been updated to support implementing operations on named resource sub-resources.

Fixes fabric8io#4758
@manusa manusa added this to the 6.5.0 milestone Feb 13, 2023
manusa pushed a commit to cronik/fabric8io-kubernetes-client that referenced this issue Feb 13, 2023
Add new interface EphemeralContainersResource to expose operations on this
new operation context and is returned by a new method on PodResource.

OperationContext and OperationSupport have been updated to support implementing operations on named resource sub-resources.

Fixes fabric8io#4758
manusa pushed a commit to cronik/fabric8io-kubernetes-client that referenced this issue Feb 13, 2023
Add new interface EphemeralContainersResource to expose operations on this
new operation context and is returned by a new method on PodResource.

OperationContext and OperationSupport have been updated to support implementing operations on named resource sub-resources.

Fixes fabric8io#4758
manusa pushed a commit that referenced this issue Feb 13, 2023
Add new interface EphemeralContainersResource to expose operations on this
new operation context and is returned by a new method on PodResource.

OperationContext and OperationSupport have been updated to support implementing operations on named resource sub-resources.

Fixes #4758
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants