我知道 k8s 中的 Priority 类是什么,但经过大量搜索后找不到任何关于优先级对象的信息。
所以问题是我在我的 k8s 集群中创建了一个 PriorityClass 对象并将其值设置为 -100000 并创建了一个具有此 priorityClass 的 pod。现在当我做 kubectl describe Pod 我得到两个不同的领域
Priority: 0
PriorityClassName: imagebuild-priority
我的准入控制器抛出以下错误
Error from server (Forbidden): error when creating "/tmp/tmp.4tJSpSU0dy/app.yml":
pods "pod-name" is forbidden: the integer value of priority (0) must not be provided in pod spec;
priority admission controller computed -1000000 from the given PriorityClass name
它在某处将 Priority 设置为 0,而 PriorityClass 试图将其设置为 -10000。
PriorityClass 对象具有 globalDefault: False
命令运行
kubectl create -f app.yml
yaml 文件
---
apiVersion: v1
kind: Pod
metadata:
name: image-builder-serviceacc
spec:
securityContext:
runAsUser: 0
serviceAccountName: {{ serviceaccount }}
automountServiceAccountToken: false
containers:
- name: container
image: ....
imagePullPolicy: Always
env:
- name: PATH
value: "$PATH:/bin:/busybox/"
command: [ "sh", "-c", "--" ]
args: [ "while true; do sleep 30; done;" ]
initContainers:
- name: init-container
image: ....
imagePullPolicy: Always
env:
- name: PATH
value: "$PATH:/bin:/busybox/"
command: [ "sh", "-c", "--" ]
args: [ "ls" ]
restartPolicy: Always
受控的变异将附加 PriorityClass