k8s中默认发布的优先级级别有哪些?
在k8s发布的时候,默认携带了如下的优先级级别配置:
- system-cluster-critical
- system-node-critical
可以通过如下的命令进行查询
[root@nccztsjb-node-23 ~]# kubectl get priorityclass
NAME VALUE GLOBAL-DEFAULT AGE
system-cluster-critical 2000000000 false 72d
system-node-critical 2000001000 false 72d
可以看到这2个优先级别的值,都是很大的,20亿+
这些优先级别主要是给系统组件来使用的,用于确保重要的组件优先被调度。
OK,那么我们继续,看下,是哪些组件使用了这些优先级别:
[root@nccztsjb-node-23 ~]# kubectl get deployment -A -o yaml | grep -i priorityclass
{"apiVersion":"apps/v1","kind":"Deployment","metadata":{"annotations":{},"name":"nginx-priority","namespace":"default"},"spec":{"progressDeadlineSeconds":600,"replicas":1,"selector":{"matchLabels":{"app":"nginx-priority"}},"template":{"metadata":{"labels":{"app":"nginx-priority"}},"spec":{"containers":[{"image":"172.20.58.152/middleware/nginx:1.21.4","imagePullPolicy":"IfNotPresent","name":"nginx"}],"dnsPolicy":"ClusterFirst","priorityClassName":"high-priority","restartPolicy":"Always"}}}}
priorityClassName: high-priority
{"apiVersion":"apps/v1","kind":"Deployment","metadata":{"annotations":{},"labels":{"k8s-app":"calico-kube-controllers"},"name":"calico-kube-controllers","namespace":"kube-system"},"spec":{"replicas":1,"selector":{"matchLabels":{"k8s-app":"calico-kube-controllers"}},"strategy":{"type":"Recreate"},"template":{"metadata":{"labels":{"k8s-app":"calico-kube-controllers"},"name":"calico-kube-controllers","namespace":"kube-system"},"spec":{"containers":[{"env":[{"name":"ENABLED_CONTROLLERS","value":"node"},{"name":"DATASTORE_TYPE","value":"kubernetes"}],"image":"docker.io/calico/kube-controllers:v3.21.4","livenessProbe":{"exec":{"command":["/usr/bin/check-status","-l"]},"failureThreshold":6,"initialDelaySeconds":10,"periodSeconds":10,"timeoutSeconds":10},"name":"calico-kube-controllers","readinessProbe":{"exec":{"command":["/usr/bin/check-status","-r"]},"periodSeconds":10}}],"nodeSelector":{"kubernetes.io/os":"linux"},"priorityClassName":"system-cluster-critical","serviceAccountName":"calico-kube-controllers","tolerations":[{"key":"CriticalAddonsOnly","operator":"Exists"},{"effect":"NoSchedule","key":"node-role.kubernetes.io/master"}]}}}}
priorityClassName: system-cluster-critical
priorityClassName: system-cluster-critical
{"apiVersion":"apps/v1","kind":"Deployment","metadata":{"annotations":{},"labels":{"k8s-app":"metrics-server"},"name":"metrics-server","namespace":"kube-system"},"spec":{"selector":{"matchLabels":{"k8s-app":"metrics-server"}},"strategy":{"rollingUpdate":{"maxUnavailable":0}},"template":{"metadata":{"labels":{"k8s-app":"metrics-server"}},"spec":{"containers":[{"args":["--cert-dir=/tmp","--secure-port=4443","--kubelet-preferred-address-types=InternalIP,ExternalIP,Hostname","--kubelet-use-node-status-port","--kubelet-insecure-tls","--metric-resolution=15s"],"image":"172.20.58.152/kubernetes/metrics-server:0.6.0","imagePullPolicy":"IfNotPresent","livenessProbe":{"failureThreshold":3,"httpGet":{"path":"/livez","port":"https","scheme":"HTTPS"},"periodSeconds":10},"name":"metrics-server","ports":[{"containerPort":4443,"name":"https","protocol":"TCP"}],"readinessProbe":{"failureThreshold":3,"httpGet":{"path":"/readyz","port":"https","scheme":"HTTPS"},"initialDelaySeconds":20,"periodSeconds":10},"resources":{"requests":{"cpu":"100m","memory":"200Mi"}},"securityContext":{"allowPrivilegeEscalation":false,"readOnlyRootFilesystem":true,"runAsNonRoot":true,"runAsUser":1000},"volumeMounts":[{"mountPath":"/tmp","name":"tmp-dir"}]}],"nodeSelector":{"kubernetes.io/os":"linux"},"priorityClassName":"system-cluster-critical","serviceAccountName":"metrics-server","volumes":[{"emptyDir":{},"name":"tmp-dir"}]}}}}
priorityClassName: system-cluster-critical
我们可以看到像metrics-server,calico-kube-controllers,calico-node都是使用了这样的优先级级别的。
这样,就能保证在出现资源紧张的时候,这些关键的组件,可以被优先的调度。