【发布时间】:2019-05-17 15:07:04
【问题描述】:
我的问题几乎都在标题中。我想知道是否有办法通过 kubectl 在 Kubernetes 中创建对象时应用注释。
我会在上下文中为您提供更多信息。我正在 GKE 上创建一个内部负载均衡器。要使负载均衡器成为内部负载均衡器,您可以在 GKE 上向服务添加以下注释:cloud.google.com/load-balancer-type: "Internal"。
但在公开部署时,它让我可以选择仅将其设为 LoadBalancer 类型:
$ kubectl expose deploy nginx --port 80 --type LoadBalancer
有没有办法在创建服务的同时即时应用注释?
编辑
我尝试了以下命令,看起来很简洁:
kubectl expose deploy nginx --port 80 --type LoadBalancer --overrides '{ "metadata": { "annotations": { "cloud.google.com/load-balancer-type": "Internal" } } }'
...但我收到以下错误,我不知道如何解释:
error: unable to convert the internal object type *core.Service to Unstructured without providing a preferred version to convert to.
这是来自:source
【问题讨论】:
标签: kubernetes google-kubernetes-engine kubectl