【问题标题】:How to add nodeSelector to Deployment yaml file?如何将 nodeSelector 添加到部署 yaml 文件?
【发布时间】:2021-10-15 13:31:27
【问题描述】:

在 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
    
 

【问题讨论】:

    标签: kubernetes deployment devops nodeselector


    【解决方案1】:

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

    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
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-12-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-07-08
      • 2012-02-28
      相关资源
      最近更新 更多