pod容忍(toleration)

污点就是拒绝,容忍就是忽略,Node通过污点拒绝pod调度上去,Pod通过容忍忽略拒绝

apiVersion: apps/v1
kind: Deployment
metadata:
  name: my-deployment
  namespace: test
spec:
  replicas: 1
  selector:
    matchLabels:
      environment: stg
  template:
    metadata:
      labels:
        environment: stg
    spec:
      containers:
      - name: nginx-container
        image: nginx:latest
        imagePullPolicy: IfNotPresent
        ports:
        - name: nginx-port
          containerPort: 80
          protocol: TCP
        lifecycle:
          postStart:
            exec:
              command: ["/bin/sh","-c","echo jiayouba!!!!!>/usr/share/nginx/html/index.html"]
      affinity:  #亲和性设置
        nodeAffinity: #设置node亲和性
          preferredDuringSchedulingIgnoredDuringExecution: #软限制
          - weight: 1 
            preference: 
              matchExpressions: 
              - key: env
                operator: In
                values: ["aaaa","bbbb"]
      tolerations:
      - key: tag
        operator: "Equal"
        value: "ceshi"
        effect: NoExecute

posted @ 2022-11-02 18:46  弩哥++  阅读(33)  评论(0编辑  收藏  举报