Wednesday, January 27, 2021

Fix Openshift build pod was killed due to an out of memory condition

I was doing a large build using oc build command in Openshift dedicated cluster. This build has many steps in Dockefile and it fails somewhere in copying blobs. Error was "The build pod was killed due to an out-of-memory condition.". 

I found two solutions for this. 

1. Increase build pod resources.
resources: 
 requests: 
   cpu: "100m" 
   memory: "1024Mi" 

2. Build locally using docker build and push the image to the image stream.

- Build locally
docker build -t myapi 

- Tag build
docker tag myapi default-route-openshift-image-registry.apps.ca-central-1.starter.openshift-online.com/apis/myapi

- Login to an openshift registry
docker login default-route-openshift-image-registry.apps.ca-central-1.starter.openshift-online.com -u $(oc whoami) -p $(oc whoami -t)

- Push the image to the registry
docker push default-route-openshift-image-registry.apps.ca-central-1.starter.openshift-online.com/apis/myapi