如何为 Kubernetes 作业设置内存限制?
How set memory limits to Kubernetes job?
如何限制 K8s 作业的最大内存量?我试过下面的规范,类似于 pod,但它不被识别为有效的描述符:
apiVersion: batch/v1
kind: Job
metadata:
name: countdown
spec:
template:
metadata:
name: countdown
spec:
containers:
- name: counter
image: centos:7
command:
- "bin/bash"
- "-c"
- "for i in 9 8 7 6 5 4 3 2 1 ; do echo $i ; done"
resources:
limits:
memory: "1000Mi"
restartPolicy: Never
我在你的作业 yaml 文件中没有看到任何错误
$ kk apply -f job.yaml
job.batch/countdown created
$ kk get pod
NAME READY STATUS RESTARTS AGE
countdown-5dckl 0/1 Completed 0 95s
如何限制 K8s 作业的最大内存量?我试过下面的规范,类似于 pod,但它不被识别为有效的描述符:
apiVersion: batch/v1
kind: Job
metadata:
name: countdown
spec:
template:
metadata:
name: countdown
spec:
containers:
- name: counter
image: centos:7
command:
- "bin/bash"
- "-c"
- "for i in 9 8 7 6 5 4 3 2 1 ; do echo $i ; done"
resources:
limits:
memory: "1000Mi"
restartPolicy: Never
我在你的作业 yaml 文件中没有看到任何错误
$ kk apply -f job.yaml
job.batch/countdown created
$ kk get pod
NAME READY STATUS RESTARTS AGE
countdown-5dckl 0/1 Completed 0 95s