This is a common problem that happens on Openshift / Kubernetes with the pod has reached it's memory limit for memory and is killed by Kubernetes


Openshift Build Pods have OOMKilled error


Here is an example of pods being killed in Openshift because it run out of memory.


oc get po | grep OOMKilled

debs-quotes-engine-321-build       0/1       OOMKilled   0          1h
debs-quotes-engine-322-build       0/1       OOMKilled   0          1h
debs-quotes-web-373-build          0/1       OOMKilled   0          2h
debs-quotes-web-374-build          0/1       OOMKilled   0          39m


Let us get more information from the Build Config for "debs-quotes-engine"


oc get buildconfig debs-quotes-engine -oyaml

apiVersion: build.openshift.io/v1
kind: BuildConfig
metadata:
  annotations:
    openshift.io/generated-by: OpenShiftNewApp
  creationTimestamp: "2019-04-30T08:13:25Z"
  labels:
    app: debs-quotes
    component: common
    createdByTemplate: debs-quotes-common
  name: debs-quotes-engine
  namespace: eb-dev
spec:
  failedBuildsHistoryLimit: 2
  nodeSelector: null
  output:
    to:
      kind: ImageStreamTag
      name: debs-quotes-engine:latest
  postCommit: {}
  resources:
    limits:
      cpu: 500m
      memory: 1000Mi
    requests:
      cpu: 250m
      memory: 100Mi
  runPolicy: SerialLatestOnly
  source:
    git:
      ref: develop
      uri: ssh://git@XXXXXXXXXXX:7999/debs/debs-quote.git
    sourceSecret:
      name: debs-quotes-ssh-secret
    type: Git
  strategy:
    dockerStrategy:
      dockerfilePath: src/engine/Dockerfile.rhel
      from:
        kind: ImageStreamTag
        name: debs-quotes-debs-common:latest
    type: Docker


The important section is this


  resources:
    limits:
      cpu: 500m
      memory: 1000Mi
    requests:
      cpu: 250m
      memory: 100Mi


The resource.limits.memory states that the pod will be allowed to use a maximum of 1000Mi. If it tries to use more memory than 1000Mi it will be killed. Would you like to know more?


To fix the problem increased the 1000Mi to something larger and try your build again


oc edit buildconfig debs-quotes-engine

  resources:
    limits:
      cpu: 500m
      memory: 2Gi
    requests:
      cpu: 250m
      memory: 512Mi


And run your build again


oc start-build debs-quotes-engine