Gitlab+gitlab-runner+k8s
First, install gitlab-runner
Docker run-d-- name gitlab-runner-- restart always-v / srv/gitlab-runner/config:/etc/gitlab-runner-v / var/run/docker.sock:/var/run/docker.sock gitlab/gitlab-runner:latest
Registration:
Docker run-- rm-v / srv/gitlab-runner/config:/etc/gitlab-runner gitlab/gitlab-runner register-- non-interactive-- executor "docker"-- docker-image "docker:19.03.1"-- url "http://gitlab.com/"-- registration-token" xZLaGbMzcSaGy-gjPvAv "- description" hyh gitlab-runner "- docker-privileged-- docker-volumes" / certs/client "
Add k8s cluster to gitlab
Get the api address
# API address:
Kubectl cluster-info | grep 'Kubernetes master' | awk' / http/ {print $NF}'
Get the ca certificate
# CA certificate:
Kubectl get secrets
# copy the token name with name similar to default-token-xxxxx in the result to the following command:
Kubectl get secret-o jsonpath= "{['data'] [' ca.crt']}" | base64-- decode
Get service token
Kubectl-n kube-system describe secret $(kubectl-n kube-system get secret | grep gitlab-admin | awk'{print $1}')
Advanced settings, otherwise there is no permission to execute the k8s command