I am using gitlab.com and my runners are running in my local on-premise infrastructure.
I have the following stage in my gitlab-ci file
deploy:
image: dtzar/helm-kubectl
stage: deploy
only:
- tags
before_script:
- mkdir -p /root/.kube/ && touch /root/.kube/config
- echo ${KUBERNETES_KUBE_CONFIG} | base64 -d > ${KUBECONFIG}
script:
- ping 192.168.10.50 -c 4
- kubectl get pods -v7
- kubectl apply -f kubernetes/deployment.yaml
kubectl has been failing with the error
Unable to connect to the server: dial tcp 192.168.10.50:443: i/o timeout
I put the ping
debug in to check that I could at least see the server, but get back the following
PING 192.168.10.50 (192.168.10.50): 56 data bytes
--- 192.168.10.50 ping statistics ---
4 packets transmitted, 0 packets received, 100% packet loss
If I run the following command manually on the same VM that gitlab-runner is on
docker run -it -v ~/.kube:/root/.kube dtzar/helm-kubectl
it mounts the same kube config as in my deploy script and drops me in to a bash shell and I can successfully run
bash-5.1# kubectl get pods
NAME READY STATUS RESTARTS AGE
gitlab-runner-6cb5bcc665-s9hhf 1/1 Running 0 34h
nginx-hello-54bc7788-8ccgn 1/1 Running 1 7d6h
nginx-hello-54bc7788-h2qcm 1/1 Running 1 7d6h
nginx-hello-54bc7788-nvmwj 1/1 Running 1 7d6h
nginx-hello-54bc7788-wm9f6 1/1 Running 1 7d6h
vuejs-release-5cbff5955b-22gr6 1/1 Running 0 23m
vuejs-release-5cbff5955b-p7rrj 1/1 Running 0 23m
So in summary, the same Docker container that can see the local network when run manually is not able to see the network when started by the gitlab-runner