K8S安装flannel报错解决(pods with system-node-critical priorityClass is not permitted in kube-flannel namespace)
myluzh 发布于 阅读:998 Kubernetes
0x01 关于部署flannel失败
在上一个过程中,部署高可用k8s集群后,在master节点安装flannel网络插件,部署后没有pod,后面经过分析报错如下:
# 在master节点apply kube-flannel.yml 提示所有东西都已经创建了。
[root@k8s-master01 ~]# kubectl apply -f kube-flannel.yml
namespace/kube-flannel created
clusterrole.rbac.authorization.k8s.io/flannel created
clusterrolebinding.rbac.authorization.k8s.io/flannel created
serviceaccount/flannel created
configmap/kube-flannel-cfg created
daemonset.apps/kube-flannel-ds created
# 在kube-flannel里面 找不到任何pod
[root@k8s-master01 ~]# kubectl get pods -n kube-flannel
No resources found in kube-flannel namespace.
# 查看daemonset kube-flannel-ds 报错如下
[root@k8s-master01 ~]# kubectl describe daemonset kube-flannel-ds -n kube-flannel
Warning FailedCreate 111s (x17 over 7m19s) daemonset-controller Error creating: pods "kube-flannel-ds-" is forbidden: pods with system-node-critical priorityClass is not permitted in kube-flannel namespace
0x02 解决方案
kube-flannel 命名空间下的 kube-flannel-ds DaemonSet 使用了 system-node-critical 优先级类,这可能是导致 Pod 创建失败的原因。
方法一:更改优先级类
将 kube-flannel-ds DaemonSet 的 priorityClassName 字段从 system-node-critical 更改为默认的空值(即删除该字段)。这将使用默认的优先级类来创建 Flannel Pod。
方法二:创建自定义的优先级类
在 Flannel 的配置文件中,定义一个自定义的优先级类,并将其应用于 kube-flannel-ds DaemonSet 的 priorityClassName 字段。
以下是创建自定义优先级类的示例:
apiVersion: scheduling.k8s.io/v1
kind: PriorityClass
metadata:
name: flannel-priority
value: 1000000
globalDefault: false
description: "Custom priority class for Flannel"
然后,将 kube-flannel-ds DaemonSet 的 priorityClassName 字段设置为 flannel-priority。
请注意,如果您选择使用自定义的优先级类,确保您的 Kubernetes 版本支持优先级类的功能。