Embedded builds with k8s and kas/bitbake

Hi all,
I come across couple of issues with gitlab runner so far and managed to pass all of them with help of online content, documentation and a bit of try-catch-repeat attempts.

Lately I’ve hit a brick wall with a specific docker image which I can not really get working properly with kubernetes. It is probably mixture of the tool and executor itself. I will describe step by step what I am trying to do so you get the point.

We are trying to get CI/CD pipeline for firmware builds. This means that we are building linux filesystem image which can be deployed anywhere. Tool which does the job is called bitbake. It covers most if not all the job for us.
Build environment setup as you can imagine is its own challenge, hence people started to craft their own scripts. Eventually embedded guys we worked with brought to us tool called kas which does all the job plus automatic handling of patchfiles.
Now - kas can be executed via docker image in similar way as gitlab-runner. Similarly like runner kas accepts command line arguments. Example execution of kas:

docker run --rm -v (pwd):(pwd) -w (pwd) kasproject/kas:2.1.1 build ./kas.yml

I’ve come over couple of examples how gitlab-ci.yml for kas looks a like and most of github references just pulls the image. However this way works fine only with docker executor. It does not work with kubernetes executor. Entrypoint itself is simplistic:

After execution it should leave container with builder user and opened bash session. It does not happen for us since executor username I traced is still root. I managed to work-around issue by calling /kas/docker-entrypoint build xyz instead of kas build xyz, but it looks wrong.
Can you advise me how to get this right? Am I sentenced to use a workaround?

I would like to keep gitlab-ci.yml small and rely on existing image as much as possible cause it guarantees reproducibility of the builds, yet I can’t really get the most basic setup working.

  CI_DEBUG_TRACE: "true"

  - build

image: kasproject/kas:2.1.1

  stage: build
    - echo "Preparing env" && whoami
    - export NEXUS_HOST=$(echo $NEXUS_URL | cut -d '/' -f 3)
    - echo -e "machine ${NEXUS_HOST}\n\tlogin ${DOWNLOAD_USER}\n\tpassword ${DOWNLOAD_PASS}" >> ~/.netrc

    - cd ..
    - kas build meta-connectorio/kas.yml