Skip to content

Conversation

tksm
Copy link
Contributor

@tksm tksm commented Jan 20, 2023

Fixes #159

This PR supports a Kubernetes resource as a query in the form <resource>/<name>. As discussed in #206, this PR supports it as a query rather than a flag.

This feature will be useful when we want to distinguish pods created by multiple deployments whose names are partly the same.

$ kubectl get deploy -n kube-system | grep cert-manager
cert-manager              1/1     1            1           63d
cert-manager-cainjector   1/1     1            1           63d
cert-manager-webhook      1/1     1            1           63d

# It is not easy to select only pods created by `deployment/cert-manager` with a regular expression
$ stern -n kube-system --tail 0 cert-manager
+ cert-manager-webhook-6c587d5b6f-x26dr › cert-manager
+ cert-manager-7ff5799cff-7gjv5 › cert-manager
+ cert-manager-cainjector-6b4cf6bdf9-rxpcn › cert-manager

# The <resource>/<name> form allows users to select only pods created by `deployment/cert-manager`.
$ stern -n kube-system --tail 0 deployment/cert-manager
+ cert-manager-7ff5799cff-7gjv5 › cert-manager

Supported Kubernetes resources are the same as kubectl logs, which are pod, replicationcontroller, service, daemonset, deployment, replicaset, statefulset and job.

I will implement a dynamic completion for this feature after this PR is merged.

@superbrothers
Copy link
Member

Thanks for the change! I will review it soon.

@superbrothers superbrothers merged commit 7bc45f0 into stern:master Jan 22, 2023
@tksm tksm deleted the resource-query branch January 22, 2023 07:24
@tksm
Copy link
Contributor Author

tksm commented Jan 22, 2023

Thank you for the review! I created PR #209, adding a dynamic completion for this feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add an option for a "deployment-query"
2 participants