Skip to content

Delete all pods matching the awk pattern#13821

Merged
k8s-ci-robot merged 3 commits intokubernetes:masterfrom
ismailyenigul:master
Apr 25, 2019
Merged

Delete all pods matching the awk pattern#13821
k8s-ci-robot merged 3 commits intokubernetes:masterfrom
ismailyenigul:master

Conversation

@ismailyenigul
Copy link
Copy Markdown
Contributor

Delete all pods matching the egrep pattern

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. language/en Issues or PRs related to English language sig/docs Categorizes an issue or PR as relevant to SIG Docs. labels Apr 15, 2019
@netlify
Copy link
Copy Markdown

netlify bot commented Apr 15, 2019

Deploy preview for kubernetes-io-master-staging ready!

Built with commit 7d4348f

https://deploy-preview-13821--kubernetes-io-master-staging.netlify.com

kubectl delete pods,services -l name=myLabel --include-uninitialized # Delete pods and services, including uninitialized ones, with label name=myLabel
kubectl -n my-ns delete po,svc --all # Delete all pods and services, including uninitialized ones, in namespace my-ns,
# Delete all pods matching the egrep pattern
kubectl get pods -n mynamespace --no-headers=true | egrep 'pattern1|pattern2' | awk '{print $1}' | xargs kubectl delete -n mynamespace pod $1
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.

The Kubernetes side of this command looks fine; however, I'm thinking that you could replace egrep and awk with just awk.

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.

What role does $1 play in this example?

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.

This feature request for JSONPath regular expression support might be relevant 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.

What role does $1 play in this example?

$1 is replaced with all pods names returned by egrep and awk filters.

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.

The Kubernetes side of this command looks fine; however, I'm thinking that you could replace egrep and awk with just awk.

agreed! we can use
kubectl get pods --no-headers=true | awk '/pattern1|pattern2/{print $1}'
instead of
|egrep 'pattern1|pattern2' | awk '{print $1}'

@DanyC97
Copy link
Copy Markdown
Contributor

DanyC97 commented Apr 23, 2019

thanks for the PR @ismailyenigul .
@sftim as always thanks for reviewing it

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 23, 2019
Co-Authored-By: ismailyenigul <ismailyenigul@gmail.com>
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 23, 2019
@jaredbhatti
Copy link
Copy Markdown
Contributor

/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 Apr 25, 2019
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jaredbhatti

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 Apr 25, 2019
@k8s-ci-robot k8s-ci-robot merged commit 100de28 into kubernetes:master Apr 25, 2019
@ismailyenigul ismailyenigul changed the title Delete all pods matching the egrep pattern Delete all pods matching the awk pattern Apr 25, 2019
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. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. language/en Issues or PRs related to English language lgtm "Looks good to me", indicates that a PR is ready to be merged. sig/docs Categorizes an issue or PR as relevant to SIG Docs. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants