jq – Use kubectl find out how many Deployments don’t have a container called “main”
[*]
The below command would print the deployment name and the container names. grep -v
would filter out whatever you need to remove.
kubectl get deployment -o custom-columns=""DEPLOYMENT-NAME":.metadata.name,"CONTAINER-NAME":.spec.template.spec.containers[*].name"
DEPLOYMENT-NAME CONTAINER-NAME
foo httpd
foobar nginx
foobar007 nginx
foobar123 nginx
zoo nginx,main
zoo1 busybox,main
The above command may be further modified to trim the output header.
kubectl get deployment --no-headers -o custom-columns=""":.metadata.name,"":.spec.template.spec.containers[*].name"
foo httpd
foobar nginx
foobar007 nginx
foobar123 nginx
zoo nginx,main
zoo1 busybox,main
[*]
[*]
Read more here: Source link