我读过“2021-Apress- Kubernetes”一书(第4页)。


(for i in 0 1; ){ do gcloud compute instances create worker-${i} --async --boot-disk-size 200GB --can-ip-forward --image-family ubuntu-2004-lts --image-project ubuntu-os-cloud --machine-type n1-standard-1 --private-network-ip 10.240.0.2${i} --scopes compute-rw,storage-ro,service-management,servicecontrol,logging-write,monitoring --subnet kubernetes;} done我发现错误
C:\Program Files (x86)\Google\Cloud SDK>(for i in 0 1; ){ do gcloud compute instances create worker-${i} --async --boot-disk-size 200GB --can-ip-forward --image-family ubuntu-2004-lts --image-project ubuntu-os-cloud --machine-type n1-standard-1 --private-network-ip 10.240.0.2${i} --scopes compute-rw,storage-ro,service-management,servicecontrol,logging-write,monitoring --subnet kubernetes;} done
i was unexpected at this time.
C:\Program Files (x86)\Google\Cloud SDK>如何键入并运行命令成功?我想要一行命令(为了便于复制和粘贴,而不是多行命令)
发布于 2022-01-07 07:33:01
正如其他人提到的,*nix命令与Windows之间的区别。
在PowerShell中,与此类似的内容是:
foreach ($i in 1,2) {
gcloud compute instances create worker-$i --async --boot-disk-size 200GB --can-ip-forward --image-family ubuntu-2004-lts --image-project ubuntu-os-cloud --machine-type n1-standard-1 --private-network-ip 10.240.0.2$i --scopes compute-rw,storage-ro,service-management,servicecontrol,logging-write,monitoring --subnet kubernetes
}如果您想继续学习这本书中基于Linux的示例,您可以确保您的Windows机器上运行了Docker,安装了WSL 2(用于linux的windows子系统),最后运行了一个基于linux发行版的gcloud-sdk停靠映像。
例如docker run --rm -it gcr.io/google.com/cloudsdktool/cloud-sdk:slim
发布于 2022-01-07 05:59:33
我没有尝试过,但是您应该能够使用Windows的for命令。你会想:
for %i in (0 1) do gcloud compute instances create ...您需要用${i}替换为%i
https://stackoverflow.com/questions/70616650
复制相似问题