-1

在 pod 定义中,我们将 nodeSelector 添加为 spec 的子节点。但我不确定如何在部署 yaml 文件中添加它

我们应该将它添加到模板的规范中吗?

apiVersion: apps/v1
kind: Deployment
metadata: 
  name: first-deployment
  labels: 
    app: first
spec:
  replicas: 1
  template:
    metadata:
      name: first-deployment-pod
      label: 
        app: first
    spec:
      containers:
      - name: test
        image: test/test
    nodeSelector:
      testkey: testvalue

 

还是我们需要在部署规范中添加它 -

apiVersion: apps/v1
kind: Deployment
metadata: 
  name: first-deployment
  labels: 
    app: first
spec:
  replicas: 1
  nodeSelector:
    testkey: testvalue
  template:
    metadata:
      name: first-deployment-pod
      label: 
        app: first
    spec:
      containers:
      - name: test
        image: test/test
    
 
4

1 回答 1

3

它应该与您的容器数组处于同一级别:

apiVersion: apps/v1
kind: Deployment
metadata: 
  name: first-deployment
  labels: 
    app: first
spec:
  replicas: 1
  template:
    metadata:
      name: first-deployment-pod
      label: 
        app: first
    spec:
      containers:
      - name: test
        image: test/test
      nodeSelector:
        testkey: testvalue
于 2021-08-12T07:06:13.547 回答