我是靠谱客的博主 含蓄麦片,最近开发中收集的这篇文章主要介绍k8s master 打上污点不许被调度,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

 查看节点信息

[root@k8s-master-61 ~]# kubectl get node
NAME          STATUS   ROLES    AGE   VERSION
k8s-master1   Ready    <none>   10d   v1.20.4
k8s-node1     Ready    <none>   10d   v1.20.4
k8s-node2     Ready    <none>   10d   v1.20.4
k8s-node3     Ready    <none>   10d   v1.20.4
k8s-node4     Ready    <none>   12h   v1.20.4
k8s-node5     Ready    <none>   12h   v1.20.4
k8s-node6     Ready    <none>   12h   v1.20.4
k8s-node7     Ready    <none>   12h   v1.20.4

 查看master 的详细信息:可以看到 Taints:             <none> 现在为none  是允许被调度的

[root@k8s-master-61 ~]# kubectl describe node k8s-master1
Name:               k8s-master1
Roles:              <none>
Labels:             beta.kubernetes.io/arch=amd64
                    beta.kubernetes.io/os=linux
                    kubernetes.io/arch=amd64
                    kubernetes.io/hostname=k8s-master1
                    kubernetes.io/os=linux
Annotations:        node.alpha.kubernetes.io/ttl: 0
                    projectcalico.org/IPv4Address: 10.12.12.61/24
                    projectcalico.org/IPv4IPIPTunnelAddr: 10.244.159.128
                    volumes.kubernetes.io/controller-managed-attach-detach: true
CreationTimestamp:  Mon, 05 Jul 2021 16:43:36 +0800
Taints:             <none>
Unschedulable:      false
Lease:
  HolderIdentity:  k8s-master1
  AcquireTime:     <unset>
  RenewTime:       Thu, 15 Jul 2021 22:39:45 +0800
Conditions:
  Type                 Status  LastHeartbeatTime                 LastTransitionTime                Reason                       Message
  ----                 ------  -----------------                 ------------------                ------                       -------
  NetworkUnavailable   False   Tue, 06 Jul 2021 17:46:45 +0800   Tue, 06 Jul 2021 17:46:45 +0800   CalicoIsUp                   Calico is running on this node
  MemoryPressure       False   Thu, 15 Jul 2021 22:36:04 +0800   Mon, 05 Jul 2021 16:43:36 +0800   KubeletHasSufficientMemory   kubelet has sufficient memory available
  DiskPressure         False   Thu, 15 Jul 2021 22:36:04 +0800   Mon, 05 Jul 2021 16:43:36 +0800   KubeletHasNoDiskPressure     kubelet has no disk pressure
  PIDPressure          False   Thu, 15 Jul 2021 22:36:04 +0800   Mon, 05 Jul 2021 16:43:36 +0800   KubeletHasSufficientPID      kubelet has sufficient PID available
  Ready                True    Thu, 15 Jul 2021 22:36:04 +0800   Mon, 05 Jul 2021 16:57:02 +0800   KubeletReady                 kubelet is posting ready status
Addresses:
  InternalIP:  10.12.12.61
  Hostname:    k8s-master1
Capacity:
  cpu:                8
  ephemeral-storage:  296935Mi
  hugepages-1Gi:      0
  hugepages-2Mi:      0
  memory:             16265976Ki
  pods:               110
Allocatable:
  cpu:                8
  ephemeral-storage:  280223022641
  hugepages-1Gi:      0
  hugepages-2Mi:      0
  memory:             16163576Ki
  pods:               110
System Info:
  Machine ID:                 f89478ac0ca640ab9594001e03138a40
  System UUID:                EA2C0F42-991C-2078-E06A-55925AF61AB0
  Boot ID:                    a8a395d5-7836-43d4-9cc5-0e4729b4762d
  Kernel Version:             3.10.0-1062.el7.x86_64
  OS Image:                   CentOS Linux 7 (Core)
  Operating System:           linux
  Architecture:               amd64
  Container Runtime Version:  docker://19.3.9
  Kubelet Version:            v1.20.4
  Kube-Proxy Version:         v1.20.4
PodCIDR:                      10.244.0.0/24
PodCIDRs:                     10.244.0.0/24
Non-terminated Pods:          (13 in total)
  Namespace                   Name                                        CPU Requests  CPU Limits  Memory Requests  Memory Limits  AGE
  ---------                   ----                                        ------------  ----------  ---------------  -------------  ---
  default                     edu-service-operate-5ccf547fcd-njzjk        500m (6%)     1 (12%)     500Mi (3%)       1Gi (6%)       2d8h
  default                     educationcrm-echo-6494fcd8cd-rh6wf          500m (6%)     1 (12%)     500Mi (3%)       1Gi (6%)       2d7h
  default                     go-filestorage-b7d49844b-v7lk2              500m (6%)     1 (12%)     500Mi (3%)       1Gi (6%)       2d4h
  default                     zhiyue-pc-program-7d44f969d6-jnbrt          0 (0%)        0 (0%)      0 (0%)           0 (0%)         37h
  default                     zhiyueappgw-749bdfb57c-8ckrf                500m (6%)     1 (12%)     500Mi (3%)       1Gi (6%)       2d3h
  ingress-nginx               nginx-ingress-controller-5dc64b58f-224qk    100m (1%)     0 (0%)      90Mi (0%)        0 (0%)         10d
  java-test2                  scm-finance-88fd7d86f-nxhkt                 500m (6%)     1 (12%)     500Mi (3%)       1Gi (6%)       7d11h
  java-test2                  scm-report-669b5bdd87-j652f                 500m (6%)     1 (12%)     500Mi (3%)       1Gi (6%)       7d7h
  java-test2                  scm-warehouse-99d7dc885-6jpqb               500m (6%)     1 (12%)     500Mi (3%)       1Gi (6%)       7d11h
  kube-system                 calico-node-nqf9z                           250m (3%)     0 (0%)      0 (0%)           0 (0%)         10d
  kube-system                 node-exporter-wh9bw                         10m (0%)      10m (0%)    50Mi (0%)        50Mi (0%)      31h
  kube-system                 prometheus-0                                210m (2%)     210m (2%)   1010Mi (6%)      1010Mi (6%)    31h
  pre                         scm-finance-795f7db7bf-fk92l                500m (6%)     1 (12%)     500Mi (3%)       1Gi (6%)       2d11h
Allocated resources:
  (Total limits may be over 100 percent, i.e., overcommitted.)
  Resource           Requests      Limits
  --------           --------      ------
  cpu                4570m (57%)   8220m (102%)
  memory             5150Mi (32%)  9252Mi (58%)
  ephemeral-storage  0 (0%)        0 (0%)
  hugepages-1Gi      0 (0%)        0 (0%)
  hugepages-2Mi      0 (0%)        0 (0%)
Events:              <none>

给master 打上污点:NoSchedule: 一定不能被调度

[root@k8s-master-61 ~]#  kubectl taint nodes k8s-master1  node-role.kubernetes.io/master=:NoSchedule
node/k8s-master1 tainted

kubectl taint node [node] key=value[effect]   
     其中[effect] 可取值: [ NoSchedule | PreferNoSchedule | NoExecute ]
      NoSchedule: 一定不能被调度
      PreferNoSchedule: 尽量不要调度
      NoExecute: 不仅不会调度, 还会驱逐Node上已有的Pod

[root@k8s-master-61 ~]# kubectl describe node k8s-master1  | grep Taints
Taints:             node-role.kubernetes.io/master:NoSchedule

 去掉污点,再次查看

[root@k8s-master-61 ~]# kubectl describe node k8s-master1  | grep Taints
Taints:             node-role.kubernetes.io/master:NoSchedule
[root@k8s-master-61 ~]# 
[root@k8s-master-61 ~]# 
[root@k8s-master-61 ~]# kubectl taint nodes --all node-role.kubernetes.io/master-
node/k8s-master1 untainted
taint "node-role.kubernetes.io/master" not found
taint "node-role.kubernetes.io/master" not found
taint "node-role.kubernetes.io/master" not found
taint "node-role.kubernetes.io/master" not found
taint "node-role.kubernetes.io/master" not found
taint "node-role.kubernetes.io/master" not found
taint "node-role.kubernetes.io/master" not found
[root@k8s-master-61 ~]# kubectl describe node k8s-master1  | grep Taints
Taints:             <none>

如果需要在master 上跑pod  , pod 的 spec 中设置 tolerations 字段

tolerations:
- key: "node-role.kubernetes.io/master"
  operator: "Equal"
  value: ""
  effect: "NoSchedule"

最后

以上就是含蓄麦片为你收集整理的k8s master 打上污点不许被调度的全部内容,希望文章能够帮你解决k8s master 打上污点不许被调度所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(42)

评论列表共有 0 条评论

立即
投稿
返回
顶部