Skip to content

kubectl: allow to preselect interesting container in logs - #87809

Merged
k8s-ci-robot merged 1 commit into
kubernetes:masterfrom
mfojtik:kubectl-logs-preselect
Feb 5, 2020
Merged

kubectl: allow to preselect interesting container in logs#87809
k8s-ci-robot merged 1 commit into
kubernetes:masterfrom
mfojtik:kubectl-logs-preselect

Conversation

@mfojtik

@mfojtik mfojtik commented Feb 4, 2020

Copy link
Copy Markdown
Contributor

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

mfojtik commented Feb 4, 2020

Copy link
Copy Markdown
Contributor Author

/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
@mfojtik
mfojtik force-pushed the kubectl-logs-preselect branch from 22dfc3a to 439f93c Compare February 4, 2020 12:51
@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

mfojtik commented Feb 4, 2020

Copy link
Copy Markdown
Contributor Author

/retest

@soltysh soltysh left a comment

Copy link
Copy Markdown
Contributor

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 "Looks good to me", indicates that a PR is ready to be merged. label Feb 4, 2020
@k8s-ci-robot

Copy link
Copy Markdown
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

Details 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

soltysh commented Feb 4, 2020

Copy link
Copy Markdown
Contributor

/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

mfojtik commented Feb 4, 2020

Copy link
Copy Markdown
Contributor Author

/retest

2 similar comments
@mfojtik

mfojtik commented Feb 4, 2020

Copy link
Copy Markdown
Contributor Author

/retest

@mfojtik

mfojtik commented Feb 4, 2020

Copy link
Copy Markdown
Contributor Author

/retest

@mfojtik

mfojtik commented Feb 4, 2020

Copy link
Copy Markdown
Contributor Author

/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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Contributor

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

@mfojtik

mfojtik commented Feb 4, 2020

Copy link
Copy Markdown
Contributor Author

/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
mhan8796 pushed a commit to mhan8796/kubernetes that referenced this pull request Jun 26, 2026
kubectl: allow to preselect interesting container in logs
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 "Looks good to me", 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.

4 participants