how to perform rolling update from gitlab-runner

7/24/2018

I want to perform kubernetes rolling update from Gitlab CI. My idea is running some kubectl commands from Gitlab CI pipeline on my kubernetes AWS machine which has been registered as gitlab-runner.

Below is my .gitlab-ci.yml config.

rolling-update:
    script:
        -  kubectl set image deployment web-server web=web:latest
    stage: deploy
    tags:
        - k8s
    when: manual

However, every time I run the pipeline, I get error

error: You must be logged in to the server (Unauthorized)

I guess the more general question is how can I run kubectl on gitlab-runner?

-- Jiashen Cao
gitlab
kubernetes

1 Answer

7/25/2018

Found the issue. The gitlab-runner environment config is not correctly set. I add those commands to my pipeline and it works fine.

sudo cp /etc/kubernetes/admin.conf $HOME/
sudo chown $(id -u):$(id -g) $HOME/admin.conf
export KUBECONFIG=$HOME/admin.conf
-- Jiashen Cao
Source: StackOverflow