gpt4 book ai didi

kubernetes - Kubernetes-为什么选择器字段无法验证部署?

转载 作者:行者123 更新时间:2023-12-03 14:38:36 24 4
gpt4 key购买 nike

使用Kubernetes 1.2.4,为什么我的下面Deployment定义(redis.yaml)导致以下错误?

$ kubectl apply -f redis.yaml
error validating "redis.yaml": error validating data: found invalid field name for v1beta1.LabelSelector; if you choose to ignore these errors, turn validation off with --validate=false

redis.yaml:
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: redis
spec:
replicas: 3
selector:
name: redis
template:
metadata:
labels:
name: redis
spec:
containers:
- name: redis
image: kubernetes/redis:v1
ports:
- containerPort: 6379
resources:
limits:
cpu: "0.1"
volumeMounts:
- mountPath: /redis-master-data
name: data
volumes:
- name: data
emptyDir: {}

最佳答案

在Deployments require中的选择器指令可以使用matchLabelsmatchExpressions的子字段,因此在我的情况下,我需要使用matchLabels:

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: redis
spec:
replicas: 3
selector:
matchLabels:
name: redis
template:
metadata:
labels:
name: redis
spec:
containers:
- name: redis
image: kubernetes/redis:v1
ports:
- containerPort: 6379
resources:
limits:
cpu: "0.1"
volumeMounts:
- mountPath: /redis-master-data
name: data
volumes:
- name: data
emptyDir: {}

关于kubernetes - Kubernetes-为什么选择器字段无法验证部署?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37351504/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com