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

feat(kubectl): implement support for image pull secrets for debug sub command #128061

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sgaist
Copy link

@sgaist sgaist commented Oct 14, 2024

What type of PR is this?

/kind feature

What this PR does / why we need it:

The current implementation of the debug command does not support using images from private repositories. This patch adds the --pull-image-secret option that allows to set an image-pull-secret that will be added to the pod created for the debugging session.

Which issue(s) this PR fixes:

Fixes kubernetes/kubectl#1671

Special notes for your reviewer:

Does this PR introduce a user-facing change?

A new parameter has been added to the kubectl debug command: --image-pull-secret.
This parameter will add the given secret to the list of image pull secrets of the pod where the ephemeral container is created.

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:


The current implementation of the debug command does not support
using images from private repositories. This patch adds the
--pull-image-secret option that allows to set an image-pull-secret
that will be added to the pod created for the debugging session.
@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. kind/feature Categorizes issue or PR as related to a new feature. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Oct 14, 2024
@k8s-ci-robot
Copy link
Contributor

Welcome @sgaist!

It looks like this is your first PR to kubernetes/kubernetes 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes/kubernetes has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot
Copy link
Contributor

This issue is currently awaiting triage.

If a SIG or subproject determines this is a relevant issue, they will accept it by applying the triage/accepted label and provide further guidance.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Oct 14, 2024
@k8s-ci-robot
Copy link
Contributor

Hi @sgaist. Thanks for your PR.

I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added the needs-priority Indicates a PR lacks a `priority/foo` label and requires one. label Oct 14, 2024
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: sgaist
Once this PR has been reviewed and has the lgtm label, please assign brianpursley for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found 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 area/kubectl sig/cli Categorizes an issue or PR as relevant to SIG CLI. and removed do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Oct 14, 2024
@sgaist sgaist changed the title feat(kubectl): implement support for image pull secrets for debug feat(kubectl): implement support for image pull secrets for debug sub command Oct 14, 2024
@@ -205,6 +206,7 @@ func (o *DebugOptions) AddFlags(cmd *cobra.Command) {
cmd.Flags().BoolVar(&o.KeepInitContainers, "keep-init-containers", o.KeepInitContainers, i18n.T("Run the init containers for the pod. Defaults to true.(This flag only works when used with '--copy-to')"))
cmd.Flags().StringToStringVar(&o.SetImages, "set-image", o.SetImages, i18n.T("When used with '--copy-to', a list of name=image pairs for changing container images, similar to how 'kubectl set image' works."))
cmd.Flags().String("image-pull-policy", "", i18n.T("The image pull policy for the container. If left empty, this value will not be specified by the client and defaulted by the server."))
cmd.Flags().StringVar(&o.ImagePullSecret, "image-pull-secret", o.ImagePullSecret, i18n.T("The image pull secret to use for pulling image of the debug container."))
Copy link
Member

Choose a reason for hiding this comment

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

This is duplicate of kubernetes/kubectl#1567 and kubernetes/kubectl#1506. I closed them by referencing this feature kubernetes/enhancements#4292. However, we have decided to pursue another path and KEP does not fix the issue described in there.

I believe that it makes sense to have such a flag. But I think we should first update this KEP https://github.com/kubernetes/enhancements/tree/master/keps/sig-cli/1441-kubectl-debug to agree upon the design. For example, setting pull secret directly in CLI would leak the secret in terminal history and would not be sufficiently secure. If we expose this via secret, then we have to decide how does command access the secrets in other namespaces, etc.

Copy link
Member

Choose a reason for hiding this comment

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

Or what is the expected behavior for copy-to pod, ephemeral debug, debugging node, etc.

Copy link
Author

@sgaist sgaist Oct 15, 2024

Choose a reason for hiding this comment

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

@ardaguclu I haven't yet worked on a KEP so what would the best way to start the update discussion ? The README of the enhancement repository does not describe that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/kubectl cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/cli Categorizes an issue or PR as relevant to SIG CLI. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
Status: Needs Triage
Development

Successfully merging this pull request may close these issues.

Kubectl debug - allow to specify image pull secret
3 participants