-
Notifications
You must be signed in to change notification settings - Fork 39.7k
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
default container behavior with annotation kubectl.kubernetes.io/default-container
#97099
Conversation
This PR may require API review. If so, when the changes are ready, complete the pre-review checklist and request an API review. Status of requested reviews is tracked in the API Review project. |
/retest |
@kubernetes/sig-cli-pr-reviews @kubernetes/api-reviewers |
/label api-review |
/remove-label api-review Thanks for tagging for API review. I don't see an accepted KEP for adding annotations to control kubectl behavior, per the pre-review checklist:
|
/retest |
/hold cancel Currently, it is implemented for logs/exec in this PR as before. I will work on it for other commands later. |
e45158d
to
9c052a0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pacoxu do you mind to squash the patches and rebase as the KEP has been merged?
- update according to KEP: move getContainerName to helper Signed-off-by: pacoxu <paco.xu@daocloud.io>
@dougsland squashed and add comments. /cc @soltysh This pr is a fix for #96986 (logs) standalone. I will work to make it aligned with the KEP in a new PR if this PR is merged. Or I will work on the KEP into this PR later.
🥱 I will get back ASAP. |
This comment has been minimized.
This comment has been minimized.
/retest |
1 similar comment
/retest |
I will start to work on this tommorrow. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small nits and this is good to go.
/approve
@@ -95,6 +95,10 @@ const ( | |||
// configuration of a resource for use in a three way diff by UpdateApplyAnnotation. | |||
LastAppliedConfigAnnotation = kubectlPrefix + "last-applied-configuration" | |||
|
|||
// DefaultContainerAnnotationName is an annotation name that can be used to preselect the interesting container | |||
// from a pod when running kubectl. | |||
DefaultContainerAnnotationName = kubectlPrefix + "default-container" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I think there's no need to put that in the API package. Let's keep it inside kubectl only.
var containerName string | ||
if len(annotations[defaultLogsContainerAnnotationName]) > 0 { | ||
containerName = annotations[defaultLogsContainerAnnotationName] | ||
fmt.Fprintf(os.Stderr, "Found deprecated `kubectl.kubernetes.io/default-logs-container` annotation %v in pod/%v\n", containerName, t.Name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggest the new annotation name in this warning.
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: pacoxu, 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 |
/lgtm |
Almost done for development. I am working on testing it. Two small PRs are for reviewing.
|
What type of PR is this?
/kind feature
What this PR does / why we need it:
specify the default container for kubectl exec, mirroring
kubectl.kubernetes.io/default-logs-container
.more details can be seen in the KEP KEP-2227: default container behavior
Which issue(s) this PR fixes:
/sig cli
Fixes #96986
Special notes for your reviewer:
KEP is created in kubernetes/enhancements#2189, and the KEP is merged for milestone 1.21.
Does this PR introduce a user-facing change?:
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.: