Delete all pods matching the awk pattern#13821
Delete all pods matching the awk pattern#13821k8s-ci-robot merged 3 commits intokubernetes:masterfrom
Conversation
|
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 |
There was a problem hiding this comment.
The Kubernetes side of this command looks fine; however, I'm thinking that you could replace egrep and awk with just awk.
There was a problem hiding this comment.
What role does $1 play in this example?
There was a problem hiding this comment.
This feature request for JSONPath regular expression support might be relevant too.
There was a problem hiding this comment.
What role does
$1play in this example?
$1 is replaced with all pods names returned by egrep and awk filters.
There was a problem hiding this comment.
The Kubernetes side of this command looks fine; however, I'm thinking that you could replace
egrepandawkwith justawk.
agreed! we can use
kubectl get pods --no-headers=true | awk '/pattern1|pattern2/{print $1}'
instead of
|egrep 'pattern1|pattern2' | awk '{print $1}'
|
thanks for the PR @ismailyenigul . /lgtm |
Co-Authored-By: ismailyenigul <ismailyenigul@gmail.com>
|
/lgtm |
|
[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 DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Delete all pods matching the egrep pattern