且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

为什么要在单个Kubernetes配置文件中部署之前指定服务?

更新时间:2023-11-25 14:36:46

如果将DNS用作服务发现,则创建的顺序无关紧要.

If you use DNS as service discovery, the order of creation doesn't matter.

对于Environment Vars(K8S提供服务发现的第二种方式),顺序很重要,因为一旦将var传递到 starting 窗格后,如果服务定义发生更改,便无法在以后修改它们

In case of Environment Vars (the second way K8S offers service discovery) the order matters, because once that vars are passed to the starting pod, they cannot be modified later if the service definition changes.

因此,如果之前部署了您的服务,则启动您的Pod,服务环境将注入到链接的Pod中.

So if your service is deployed before you start your pod, the service envvars are injected inside the linked pod.

如果您创建带有标签的Pod/Deployment资源,则一旦创建了最后一个(使用适当的选择器指示要公开的资源),该资源就会通过服务公开.

If you create a Pod/Deployment resource with labels, this resource will be exposed through a service once this last is created (with proper selector to indicate what resource to expose).