gpt4 book ai didi

kubernetes - Minikube 错误 - "unknown field "应用程序“在 io.k8s 中”

转载 作者:行者123 更新时间:2023-12-01 18:26:29 25 4
gpt4 key购买 nike

运行后出现以下错误

kubectl apply -f node.deployment.yml  

使用以下 YAML 配置:

  1 apiVersion: apps/v1
2 kind: Deployment
3 metadata:
4 name: node-deployment
5 labels:
6 app: node-app
7 spec:
8 replicas: 2
9 selector:
10 app: node-app
11 template:
12 metadata:
13 labels:
14 app: node-app
15 spec:
16 containers:
17 - name: node-app
18 image: ubuntu/node
19 ports:
20 - containerPort: 8080

错误:

error: error validating "node.deployment.yml": error validating 
data: ValidationError(Deployment.spec.selector): unknown field "app"
in io.k8s.apimachinery.pkg.apis.meta.v1.LabelSelector;
if you choose to ignore these errors, turn validation off with --validate=fals

我使用 minikube 作为本地集群。

最佳答案

发现错误,忘记添加 matchLabels 属性:

 9   selector:
10 matchLabels:
11 app: node-app

关于kubernetes - Minikube 错误 - "unknown field "应用程序“在 io.k8s 中”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49755155/

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