Use gitlab-ci (or any CI) with kubernetes or google container engine (gitlab-runner won't find kubectl)

2/25/2016

I want to use gitlab-ci (or any other CI, whatever works) to deploy to google container engine using kubectl run

I have a working gitlab runner on google compute engine but can't figure out how to install gcloud and kubectl in so the runner has their executable and config in their path.

Running pwd through th gitlab ci file shows /home/gitlab-runner and running whoami shows root, so I installed kubectl as user gitlab-runner and as user root but gitlab-ci-multirunner still complains

$ gcloud config list
bash: line 35: gcloud: command not found

ERROR: Build failed with: exit code 1

same for kubectl. I probably have a flawed understanding on how gitlab-runner spawns the builds, but it can access the docker install so how do I get it to access the gcloud / kubectl install?

Is there a more straightforward version to deploy to kubernetes / google container engine?

Thanks so much!

-- heapoverflow
gitlab-ci
gitlab-ci-runner
google-kubernetes-engine
kubernetes
linux

2 Answers

5/31/2016

You could try the new integration using spread. From the blog post:

To use Spread with GitLab CI:

  1. Add the correct image to .gitlab-ci.yml:

    deploy:
      stage: deploy
      image: redspreadapps/gitlabci
      script:
      - null-script
  2. Set the environment variables to what makes sense. See the documentation of the environment variables.

-- Mark Pundsack
Source: StackOverflow

3/2/2016

You didn't mention what gitlab image you used. It might be useful to look at others', such as: https://github.com/sameersbn/docker-gitlab/

It looks like that configures several paths explicitly via environment variables.

If you're using Docker containers on your runner, you'd need to install kubectl in your Docker image rather than use an executable from the host. https://github.com/gitlabhq/gitlabhq/blob/master/doc/ci/docker/using_docker_images.md

-- briangrant
Source: StackOverflow