I'm using Google Cloud / Google Container Engine, and I have infrastructure scripts where I create a cluster and node pools and then perform operations on the node pools once they're setup.
In my scripts, I need to make sure that the node pools are setup and the cluster is in a ready state before proceeding.
It appears that the gcloud container node-pools create
command has no --wait
or --no-async
option, unlike the very similar gcloud container node-pools delete
. Is there such an option for create
? Else, is there a recommended way to "wait" until the node pool is ready?
I believe in my bash scripts, after creating a node pool, I can do a while loop, periodically checking the value of e.g. gcloud container clusters describe myclustername --zone myzone | tail -n 2 | grep "status" | awk '{print $2}'
until I get "RUNNING
" back, but perhaps there is a more elegant approach?
(It would be nice to have parity in options for creating and deleting node pools!)
Best Answer
As of this writing the
gcloud container node-pools create
command is sync by default but doesn't have an--async
or--no-wait
option. This isn't so bad from a shell scripting perspective as it's easy enough to background a command, and would solve your particular issue.An alternative to deal with the original behavior would have been to use
--log-http
to grab the operation ID and feed it togcloud container operations wait
(which is a bit messy and requires scraping the output). This suggests another feature which would be nice to have, which is for async commands to echo the operation ID.