K8S指定节点部署服务

方法一

    spec:
      containers:
        - name: container-name
          image: '102.196.12.16/hub/abc:v1'
          env:
            - name: LANG
              value: zh_CN.UTF-8
          resources:
            limits:
              memory: 4Gi
            requests:
              memory: 2Gi
      nodeSelector:
        kubernetes.io/hostname: node的IP或主机名

方法二

kubectl get node --show-labels  # 查看标签

kubectl label nodes <node-name> <label-key>=<label-value>  # 给node添加标签

kubectl label nodes <node-name> <label-key>=<label-value> --overwrite  # 修改标签的值

kubectl label nodes <node-name> <label-key>-  # 移除标签
    spec:
      containers:
        - name: container-name
          image: '102.196.12.16/hub/abc:v1'
          env:
            - name: LANG
              value: zh_CN.UTF-8
          resources:
            limits:
              memory: 4Gi
            requests:
              memory: 2Gi
      nodeSelector:
        <label-key>: <label-value>
Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐