我使用的是Google Cloud / Google Container Engine,而且我有基础架构脚本,可以在其中创build群集和节点池,然后在安装后在节点池上执行操作。
在我的脚本中,我需要确保节点池已经设置,集群处于就绪状态,然后再继续。
看起来gcloud container node-pools create命令没有--wait或者--no-async选项,不像gcloud container node-pools delete非常类似。 有create这样的选项吗? 否则,有没有推荐的方法来“等待”,直到节点池准备就绪?
我相信我的bash脚本,创build节点池后,我可以做一个while循环,定期检查例如gcloud container clusters describe myclustername --zone myzone | tail -n 2 | grep "status" | awk '{print $2}'的值gcloud container clusters describe myclustername --zone myzone | tail -n 2 | grep "status" | awk '{print $2}' gcloud container clusters describe myclustername --zone myzone | tail -n 2 | grep "status" | awk '{print $2}' gcloud container clusters describe myclustername --zone myzone | tail -n 2 | grep "status" | awk '{print $2}'直到我回到“ RUNNING ”,但也许有一个更优雅的方法?
(在创build和删除节点池的选项中有奇偶校验会很好!)
在撰写本文时, gcloud container node-pools create命令默认是同步的,但没有--async或--no-wait选项。 从shell脚本的angular度来看,这并不是那么糟糕,因为它足够简单地为背景命令,并且可以解决您的特定问题。
处理原始行为的替代方法是使用--log-http获取操作ID并将其提供给gcloud container operations wait (这有点麻烦,需要gcloud container operations wait输出)。 这表明另一个function,这将是很好的asynchronous命令来回显操作ID。