How set memory limits to Kubernetes job?

9/23/2020

How to constraint a K8s Job to a maximum amount of memory? I've tried the spec below, similar to a pod, but it's not recognized as a valid descriptor:

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
-- pditommaso
jobs
kubernetes

1 Answer

9/23/2020

I didn't see any error in your job yaml file

$ kk apply -f job.yaml
job.batch/countdown created

$ kk get pod
NAME              READY   STATUS      RESTARTS   AGE
countdown-5dckl   0/1     Completed   0          95s
-- BMW
Source: StackOverflow