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

kubectl: allow to preselect interesting container in logs #87809

Merged
merged 1 commit into from Feb 5, 2020

Conversation

mfojtik
Copy link
Contributor

@mfojtik mfojtik commented Feb 4, 2020

What type of PR is this?

/kind feature

What this PR does / why we need it:

This PR introduces the kubectl.kubernetes.io/default-logs-container annotation that can be placed on a Pod. This annotation will cause kubectl logs to preselect the container specified as value for this annotation. This helps in case the Pod has multiple containers, but only one container is interesting for logs. In that case, users don't have to pick the container name manually, by using the -c option or --all-containers.

NONE

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

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

@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/XS Denotes a PR that changes 0-9 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Feb 4, 2020
@mfojtik
Copy link
Contributor Author

mfojtik commented Feb 4, 2020

/assign @soltysh

@k8s-ci-robot k8s-ci-robot added area/kubectl sig/cli Categorizes an issue or PR as relevant to SIG CLI. and removed needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Feb 4, 2020
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Feb 4, 2020
@mfojtik
Copy link
Contributor Author

mfojtik commented Feb 4, 2020

/retest

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

@k8s-ci-robot k8s-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Feb 4, 2020
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: mfojtik, 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 4, 2020
@soltysh
Copy link
Contributor

soltysh commented Feb 4, 2020

/priority backlog

@k8s-ci-robot k8s-ci-robot added priority/backlog Higher priority than priority/awaiting-more-evidence. and removed needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Feb 4, 2020
@mfojtik
Copy link
Contributor Author

mfojtik commented Feb 4, 2020

/retest

2 similar comments
@mfojtik
Copy link
Contributor Author

mfojtik commented Feb 4, 2020

/retest

@mfojtik
Copy link
Contributor Author

mfojtik commented Feb 4, 2020

/retest

@mfojtik
Copy link
Contributor Author

mfojtik commented Feb 4, 2020

/retest

// container. This gives users ability to preselect the most interesting container in pod.
if annotations := t.GetAnnotations(); annotations != nil && len(opts.Container) == 0 && len(annotations[defaultLogsContainerAnnotationName]) > 0 {
containerName := annotations[defaultLogsContainerAnnotationName]
if exists, _ := findContainerByName(t, containerName); exists != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we exclude init and ephemeral containers or there are some use-cases for them too?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah, i would leave it to pod creator to define what he think is the most important container logs he want to see.

@php-coder
Copy link
Contributor

/test pull-kubernetes-kubemark-e2e-gce-big
/test pull-kubernetes-e2e-gce

@mfojtik
Copy link
Contributor Author

mfojtik commented Feb 4, 2020

/retest

@k8s-ci-robot k8s-ci-robot merged commit 7e8f31b into kubernetes:master Feb 5, 2020
@k8s-ci-robot k8s-ci-robot added this to the v1.18 milestone Feb 5, 2020
wking pushed a commit to wking/kubernetes that referenced this pull request Jul 21, 2020
kubectl: allow to preselect interesting container in logs

Kubernetes-commit: 7e8f31b
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/feature Categorizes issue or PR as related to a new feature. lgtm Indicates that a PR is ready to be merged. priority/backlog Higher priority than priority/awaiting-more-evidence. release-note-none Denotes a PR that doesn't merit a release note. 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
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants