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

default container behavior with annotation kubectl.kubernetes.io/default-container #97099

Merged
merged 2 commits into from
Feb 26, 2021

Conversation

pacoxu
Copy link
Member

@pacoxu pacoxu commented Dec 7, 2020

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.

There was a discussion in #95293 which is in process.

Does this PR introduce a user-facing change?:

Users might specify the `kubectl.kubernetes.io/default-container` annotation in a Pod to preselect container for kubectl commands.

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

- [KEP] https://github.com/kubernetes/enhancements/blob/master/keps/sig-cli/2227-kubectl-default-container/README.md

@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. kind/feature Categorizes issue or PR as related to a new feature. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. 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. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Dec 7, 2020
@k8s-ci-robot k8s-ci-robot added area/kubectl kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API 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 Dec 7, 2020
@fejta-bot
Copy link

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.

@pacoxu
Copy link
Member Author

pacoxu commented Dec 7, 2020

/retest
fail for etcd mvcc exceed.

@pacoxu
Copy link
Member Author

pacoxu commented Dec 8, 2020

@kubernetes/sig-cli-pr-reviews @kubernetes/api-reviewers
@zhouya0

@pacoxu
Copy link
Member Author

pacoxu commented Dec 9, 2020

/label api-review

@k8s-ci-robot k8s-ci-robot added the api-review Categorizes an issue or PR as actively needing an API review. label Dec 9, 2020
@liggitt
Copy link
Member

liggitt commented Dec 9, 2020

/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:

  • The goal of the proposed change has agreement from the appropriate sub-project owners and/or SIG leads
  • A KEP and tracking issue in kubernetes/enhancements has been created

@k8s-ci-robot k8s-ci-robot removed the api-review Categorizes an issue or PR as actively needing an API review. label Dec 9, 2020
@pacoxu pacoxu changed the title feature: add exec default container according to annotation [Need KEP/sig approve]feature: add exec default container according to annotation Dec 12, 2020
@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed release-note-none Denotes a PR that doesn't merit a release note. labels Dec 16, 2020
@pacoxu pacoxu changed the title [Need KEP/sig approve]feature: add exec default container according to annotation feature: add exec default container according to annotation Dec 24, 2020
@pacoxu
Copy link
Member Author

pacoxu commented Dec 24, 2020

/retest

@pacoxu
Copy link
Member Author

pacoxu commented Feb 14, 2021

/hold cancel
As the KEP is merged.

Currently, it is implemented for logs/exec in this PR as before. I will work on it for other commands later.

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Feb 14, 2021
@pacoxu pacoxu force-pushed the fix/96986 branch 3 times, most recently from e45158d to 9c052a0 Compare February 14, 2021 06:20
Copy link
Member

@dougsland dougsland left a 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>
@pacoxu
Copy link
Member Author

pacoxu commented Feb 20, 2021

@dougsland squashed and add comments.

/cc @soltysh
The change request is missing and the KEP is merged.

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.
As I need to work on several other KEPs next week for 1.21:

  • deprecate cAdvisor json metrics, almost done. (a manually test task)
  • sysctl to GA: walk though ga criteria. (WIP by wgahnagl.)
  • dual-stack feature gate update for kubeadm. almost done
  • dual-stack docs for kubeadm. add example and docs.

🥱 I will get back ASAP.

@pacoxu

This comment has been minimized.

@pacoxu
Copy link
Member Author

pacoxu commented Feb 20, 2021

/retest

1 similar comment
@pacoxu
Copy link
Member Author

pacoxu commented Feb 20, 2021

/retest

@pacoxu
Copy link
Member Author

pacoxu commented Feb 24, 2021

@dougsland squashed and add comments.

/cc @soltysh
The change request is missing and the KEP is merged.

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.
As I need to work on several other KEPs next week for 1.21:

  • deprecate cAdvisor json metrics, almost done. (a manually test task)
  • sysctl to GA: walk though ga criteria. (WIP by wgahnagl.)
  • dual-stack feature gate update for kubeadm. almost done
  • dual-stack docs for kubeadm. add example and docs.

🥱 I will get back ASAP.

I will start to work on this tommorrow.

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.

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"
Copy link
Contributor

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)
Copy link
Contributor

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.

@k8s-ci-robot
Copy link
Contributor

[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 /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 26, 2021
@zhouya0
Copy link
Contributor

zhouya0 commented Feb 26, 2021

/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 26, 2021
@k8s-ci-robot k8s-ci-robot merged commit 3cb61de into kubernetes:master Feb 26, 2021
@k8s-ci-robot k8s-ci-robot added this to the v1.21 milestone Feb 26, 2021
@jrsapi
Copy link

jrsapi commented Mar 2, 2021

Greetings @soltysh,
The enhancement team is tracking the following PR:

#97099

With the PR merged, can we mark this enhancement complete for code freeze, or do you have other PR(s) that are being worked on as part of the release?

@pacoxu
Copy link
Member Author

pacoxu commented Mar 2, 2021

@jrsapi

Almost done for development. I am working on testing it. Two small PRs are for reviewing.

@pacoxu pacoxu deleted the fix/96986 branch June 23, 2021 05:36
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. area/kubectl cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-priority Indicates a PR lacks a `priority/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. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add exec equivalent to kubectl.kubernetes.io/default-logs-container
10 participants