我在家用电脑上安装了minikube k8s(ubuntu20.4,amd 3950x,128gb RAM(。
capacity:
cpu: '32'
ephemeral-storage: 1967435760Ki
hugepages-1Gi: '0'
hugepages-2Mi: '0'
memory: 131897524Ki
pods: '110'
allocatable:
cpu: '32'
ephemeral-storage: 1967435760Ki
hugepages-1Gi: '0'
hugepages-2Mi: '0'
memory: 131897524Ki
pods: '110'
A已创建了2个部署和3个复制副本。每个吊舱可以使用1个核心CPU。这是部署之一:
spec:
replicas: 3
selector:
matchLabels:
app: another-server
template:
metadata:
creationTimestamp: null
labels:
app: another-server
spec:
containers:
- name: server
image: 'server:v6'
resources:
limits:
cpu: '2'
requests:
cpu: '2'
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
imagePullPolicy: IfNotPresent
restartPolicy: Always
terminationGracePeriodSeconds: 30
dnsPolicy: ClusterFirst
securityContext: {}
schedulerName: default-scheduler
所有pod的总CPU使用量始终限制为2个CPU。看起来有某种全局设置来限制CPU的使用。
pc:~$ kubectl top pod
NAME CPU(cores) MEMORY(bytes)
another-server-5477557cd-7fmqh 301m 15Mi
another-server-5477557cd-ddcht 304m 16Mi
another-server-5477557cd-lp9vk 276m 15Mi
worker-6889bcc6f5-45zjt 332m 3Mi
worker-6889bcc6f5-b977s 326m 3Mi
worker-6889bcc6f5-s2rsc 326m 3Mi
是否可以启动多个吊舱,每个吊舱的CPU限制为1?
Minikube作为docker容器启动,默认cpu限制为2。你应该用新的限制重新创建迷你库贝:
minikube stop
minikube delete
minikube start --cpus 16