I am using kubectl in a script to get the current GKE cluster name like so:
CURRENT_CLUSTER=$(kubectl run curl --rm --restart=Never -it --image=appropriate/curl -- -H "Metadata-Flavor: Google" http://metadata.google.internal/computeMetadata/v1/instance/attributes/cluster-name)
Unfortunately kubect prints pod "curl" deleted
to standard output, so the result is this:
my-cluster-us-west1pod "curl" deleted
How can I stop kubectl from printing this string?
In modern times you can just use kubectl run --quiet
.