Can I delete multiple CRDS whose names contain the same string with a kubectl
/bash
one-liner?
For example I'd like to delete all the ones below:
kafkabridges.kafka.strimzi.io
kafkaconnectors.kafka.strimzi.io
kafkaconnects.kafka.strimzi.io
kafkamirrormaker2s.kafka.strimzi.io
kafkamirrormakers.kafka.strimzi.io
kafkarebalances.kafka.strimzi.io
kafkas.kafka.strimzi.io
kafkatopics.kafka.strimzi.io
kafkausers.kafka.strimzi.io
CodePudding user response:
All of them seem like contain/ending with kafka.strimzi.io
, so the below command should work
kubectl delete CustomResourceDefinition $(kubectl get CustomResourceDefinition -A | grep "kafka.strimzi.io" | awk '{print $1}')
CodePudding user response:
Same logic; kafka.strimzi.io is the common string:
for crd in `kubectl get crds -oname | grep kafka.strimzi.io | awk -F / '{ print $2 }'`; do kubectl delete crd $crd; done