gpt4 book ai didi

Kubernetes - 匹配标签、选择器的范围

转载 作者:行者123 更新时间:2023-12-03 08:48:50 24 4
gpt4 key购买 nike

我进行了以下部署,

    apiVersion: apps/v1
kind: Deployment
metadata:
name: hello-deploy
spec:
replicas: 10
selector:
matchLabels:
app: hello-world
minReadySeconds: 10
strategy:
type: RollingUpdate
rollingUpdate:
maxUnavailable: 1
maxSurge: 1
template:
metadata:
labels:
app: hello-world
spec:
containers:
- name: hello-pod
image: nginx:latest
ports:
- containerPort: 80

此选择器的范围是否仅适用于由部署管理的 Pod 或具有相同标签的任何 Pod - 我正在尝试了解选择器的范围

最佳答案

Your Deployment selector这里选择带有标签“app: hello-world”的 Pod,它也由您的 Deployment 管理。

总的来说,我引用的是官方文档:

Note: You must specify an appropriate selector and Pod template labels in a Deployment (in this case, app: hello-world). Do not overlap labels or selectors with other controllers (including other Deployments and StatefulSets). Kubernetes doesn’t stop you from overlapping, and if multiple controllers have overlapping selectors those controllers might conflict and behave unexpectedly.

关于Kubernetes - 匹配标签、选择器的范围,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60187869/

24 4 0