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

KEP-4292: Add custom profiling in kubectl debug #4293

Merged
merged 6 commits into from
Feb 7, 2024

Conversation

ardaguclu
Copy link
Member

  • One-line PR description: Add custom profiling support in kubectl debug
  • Other comments:

@ardaguclu ardaguclu marked this pull request as draft October 13, 2023 08:10
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. kind/kep Categorizes KEP tracking issues and PRs modifying the KEP directory labels Oct 13, 2023
@k8s-ci-robot k8s-ci-robot added sig/cli Categorizes an issue or PR as relevant to SIG CLI. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Oct 13, 2023
@ardaguclu ardaguclu mentioned this pull request Oct 13, 2023
12 tasks
@ardaguclu ardaguclu force-pushed the debug-custom-profile branch from 6fd4682 to d1b6afc Compare October 13, 2023 08:19
@ardaguclu
Copy link
Member Author

/cc @verb
could you please take a look at this proposal, when you have a chance?. Thanks.

@ardaguclu
Copy link
Member Author

I believe this KEP is ready for review for 1.30.

@ardaguclu ardaguclu force-pushed the debug-custom-profile branch 2 times, most recently from 2d2da9e to a370516 Compare November 3, 2023 06:08
Copy link

@bavarianbidi bavarianbidi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just wanted to mention, that i really like the idea. I've already hacked a bit in kubectl to have volumeMounts in my ephemeral Containers.

I've also started with an inital version of an own kubectl plugin to have some kind of "profiles" (which can be shared within my team/community) to have dedicated debug profiles for different kind of applications.

My current POC make use of a config-file where i've defined multiple "profiles" which i
can refer to when i want to debug a container:

profiles:
    application-1:
        volumeMounts: # if nil, use all volume mounts from target pod
            - name: database
              mountPath: /opt/database
        container: server
        image: my-special-debug-container:v0.0.4
    application-2:
        volumeMounts: {}
        container: sidecar
        image: another-debug-container:latest


As a restricted user, I'd be able to debug a pod to simulate the exact environment
of the problematic pod which has resource requests and limits.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe it's also worth to mention the ability to have an ephemeral Container beside a container, build from scratch/distroless/<container without shell> where not all the handy tools (curl, wget, openssl, ...) are installed.

@ardaguclu ardaguclu force-pushed the debug-custom-profile branch from a370516 to 944d657 Compare January 5, 2024 08:23
@ardaguclu ardaguclu mentioned this pull request Jan 16, 2024
4 tasks
rollout. Similarly, consider large clusters and how enablement/disablement
will rollout across nodes.
-->
No
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A bit more details, please.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated. Please let me know what you think.

checking if there are objects with field X set) may be a last resort. Avoid
logs or events for this purpose.
-->
By checking the value of `KUBECTL_DEBUG_CUSTOM_PROFILE` environment variable
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I doubt the cluster operator can find that useful. It's more of a user setting, than a cluster one.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can add a note, that this command uses GA-ed APIs, so it'll be hard to distinguish between this command invocations and not.

@ardaguclu
Copy link
Member Author

/label tide/merge-method-squash

@k8s-ci-robot k8s-ci-robot added the tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges. label Jan 22, 2024
Copy link
Contributor

@soltysh soltysh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm
/approve
from sig-cli pov

Copying pod and node debugging use built-in API endpoints. Ephemeral container functionality was
promoted to stable in 1.25. Besides custom profiling feature only relies on
`corev1.Container` type's existence differently from `kubectl debug` which is also built-in.
It is zero probability that this feature touches unavailable API endpoints in regard to
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: I'd stay way from zero probability, but rather use something lighter, like very low probability, low chances, etc.
1.25 is not that old, and based on the results from past PRR surveys show that a lot of users still keep older versions of k8s. So it's possible that someone might use older than 1.25 k8s, just very small 😉

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed you are right. I'll update this statement based on your suggestions. Thanks.

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jan 26, 2024
Copy link
Member

@BenTheElder BenTheElder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[PRR shadow]
PRR looks OK to alpha, left some minor non-blocking comments.

- Condition name:
- Other field:
- [X] Other (treat as last resort)
- Details: Checking the value of `KUBECTL_DEBUG_CUSTOM_PROFILE` environment variable
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They can run a test debug and see if their profile is respected in the resulting container?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for review @BenTheElder. I liked your comment above ^ and have added it to this section.

You can take a look at one potential example of such test in:
https://github.com/kubernetes/kubernetes/pull/97058/files#diff-7826f7adbc1996a05ab52e3f5f02429e94b68ce6bce0dc534d1be636154fded3R246-R282
-->
In alpha phase, all the tests can be done only after enabling this feature.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This answer sort of reads like it missed the question (?), but this feature doesn't change behavior of stored objects anyhow.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, updated this answer to more align with the question. Please let me know what you think.

@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Feb 6, 2024
Copy link
Member

@johnbelamaric johnbelamaric left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PRR looks good, feature looks useful :)

Many PRR questions are geared towards server side features, so, yeah, are not so applicable to CLI features.

/approve

# The milestone at which this feature was, or is targeted to be, at each stage.
milestone:
alpha: "v1.30"
beta: "TBD"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can just leave out the "TBD" ones.

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ardaguclu, johnbelamaric, soltysh

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Feb 6, 2024
@soltysh
Copy link
Contributor

soltysh commented Feb 7, 2024

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Feb 7, 2024
@k8s-ci-robot k8s-ci-robot merged commit 866854e into kubernetes:master Feb 7, 2024
4 checks passed
@k8s-ci-robot k8s-ci-robot added this to the v1.30 milestone Feb 7, 2024
@ardaguclu ardaguclu deleted the debug-custom-profile branch February 7, 2024 09:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/kep Categorizes KEP tracking issues and PRs modifying the KEP directory lgtm "Looks good to me", indicates that a PR is ready to be merged. sig/cli Categorizes an issue or PR as relevant to SIG CLI. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges.
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

6 participants