我正在测试将两个Pod分别部署在主节点和一个工作节点上,以进行学习。
我有以下yaml文件,用于在主节点上的群集上部署Pod。
apiVersion: v1
kind: Pod
metadata:
name: edge-server
labels:
app: edge-server
spec:
containers:
- name: tensor-keras
image: tensor-keras:latest
command: ["sleep"]
args: ["infinity"]
imagePullPolicy: Never
ports:
- containerPort: 31700
nodeSelector:
node_type: "kmaster" #also tried without quotes
我已将主节点标记为node_type kmaster,正在检索以下错误
“错误分析行15找不到预期的密钥”
非常感谢您的帮助
答案 0 :(得分:2)
它可能不喜欢您的缩进。这有点不合时宜。一个文档中有多个缩进级别。我看到单,双和4空格缩进。 YAML缩进非常重要,否则会生成错误的JSON。试试这个:
apiVersion: v1
kind: Pod
metadata:
name: edge-server
labels:
app: edge-server
spec:
containers:
- name: tensor-keras
image: tensor-keras:latest
command: ["sleep"]
args: ["infinity"]
imagePullPolicy: Never
ports:
- containerPort: 31700
nodeSelector:
node_type: kmaster
答案 1 :(得分:1)
尝试一下,也在http://www.yamllint.com/中进行验证
apiVersion: v1
kind: Pod
metadata:
name: edge-server
labels:
app: edge-server
spec:
containers:
- name: tensor-keras
image: tensor-keras:latest
command: ["sleep"]
args: ["infinity"]
imagePullPolicy: Never
ports:
- containerPort: 31700
nodeSelector:
node_type: "kmaster"
答案 2 :(得分:1)
nodeSelector
应该与containers
处于同一级别。我们可以始终使用this K8s API reference来确认结构。
apiVersion: v1
kind: Pod
metadata:
name: edge-server
labels:
app: edge-server
spec:
containers:
- name: tensor-keras
image: tensor-keras:latest
command: ["sleep"]
args: ["infinity"]
imagePullPolicy: Never
ports:
- containerPort: 31700
nodeSelector:
node_type: "kmaster" #also tried without quotes