Failed to start gitlab-runner register on CentOS - gitlab

I have installed gitlab-runner on CentOS machine, but on register step it fails with "connection refused":
sudo /usr/local/bin/gitlab-runner register --non-interactive --url "https://%myGitlab%/" --registration-token "%myToken%" --executor "shell" --description "TestServerRunner" --tag-list "TestRunner, CIOnTest"
Runtime platform arch=amd64 os=linux pid=3149 revision=4b9e985a version=14.4.0
Running in system-mode.
ERROR: Registering runner... failed runner=yoqL_Qsh status=couldn't execute POST against https://%myGitlab%/api/v4/runners: Post https://%myGitlab%/api/v4/runners: dial tcp %myGitlabIp%:443: connect: **connection refused**
PANIC: Failed to register the runner. You may be having network problems.
However, if i try to connect to gitlab.com it prints out normal 'error' - wrong token:
sudo /usr/local/bin/gitlab-runner register --non-interactive --url "https://gitlab.com/" --registration-token "%myToken%" --executor "shell" --description "TestServerRunner" --tag-list "TestRunner, CIOnTest"
Runtime platform arch=amd64 os=linux pid=8259 revision=4b9e985a version=14.4.0
Running in system-mode.
ERROR: Registering runner... forbidden (check registration token) runner=yoqL_Qsh
PANIC: Failed to register the runner. You may be having network problems.
What may be wrong? Ping to %MyGitlabIp% exists.

This will be a network-related error with the connection between your runner machine and your gitlab instance. While pinging the instance may work properly, ICMP (ping) traffic uses different ports and protocols from HTTPS traffic. If you try to run curl https://<my instance domain> from your box, you will probably get an error. You should check your firewall rules on your self-hosted gitlab instance.
It sounds like this was resolved by opening up a firewall rule on the machine running the self-hosted gitlab instance.

Related

Gitlab runner status show "the service is not installed" but it was installed and run successfully

I installed Gitlab-runner in WSL Ubuntu 20. Firstly, I have registered runner and ran successfully. But when I check the status of Gitlab-runner it show:
namlb#Admin:/etc/init.d$ sudo gitlab-runner status
Runtime platform arch=amd64 os=linux pid=2170 revision=e0218c92
version=14.3.2
gitlab-runner: the service is not installed
And another thing that confused me is that my runner just execute job when I already run gitlab-runner run command, whilst in some guides they just need run gitlab-runner start and job will be execute when triggered.
Here is some info about my gitlab-runner:
namlb#Admin:~$ sudo gitlab-runner start
[sudo] password for namlb:
Runtime platform arch=amd64 os=linux pid=2563 revision=e0218c92 version=14.3.2
namlb#Admin:~$ gitlab-runner status
Runtime platform arch=amd64 os=linux pid=2609 revision=e0218c92 version=14.3.2
FATAL: The --user is not supported for non-root users
namlb#Admin:~$ sudo gitlab-runner status
Runtime platform arch=amd64 os=linux pid=2635 revision=e0218c92 version=14.3.2
gitlab-runner: the service is not installed
namlb#Admin:~$ gitlab-runner verify
Runtime platform arch=amd64 os=linux pid=2686 revision=e0218c92 version=14.3.2
WARNING: Running in user-mode.
WARNING: The user-mode requires you to manually start builds processing:
WARNING: $ gitlab-runner run
WARNING: Use sudo for system-mode:
WARNING: $ sudo gitlab-runner...
Verifying runner... is alive runner=22WNSZ6v
Run "service gitlab-runner status" for more information.
When I got the message "gitlab-runner: the service is not installed" I realized that the file /usr/lib/gitlab-runner/gitlab-runner had incorrect permissions.
for Ubuntu
Change your /etc/init.d/gitlab-runner
...
DAEMON="/usr/bin/gitlab-runner"
DESC="GitLab Runner"
USER="gitlab-runner"
...
--exec "$DAEMON" -- "run" "--working-directory" "/var/lib/gitlab-runner" "--config" "/etc/gitlab-runner/config.toml" "--service" "gitlab-runner" "--syslog" "--user" "$USER"
...
Variable $DAEMON not defined and is used
status)
status_of_proc -p "$PIDFILE" "$DAEMON" "$DESC"
;;
*)

Register GitLab runner without https

My GitLab-Repository is only accessible via SSH for my Server. https is blocked.
How can I register a GitLab Runner anway?
ERROR: Registering runner... failed
runner status couldn't execute POST against https://MY_URL/api/v4/runners: Post https://MY_URL/api/v4/runners: dial tcp: lookup MY_URL.com: no such host
PANIC: Failed to register this runner. Perhaps you are having network problems
Server: Win 10 + Powershell;
GitLab Repo: GitLab Community Edition 11.10.4

How to fix etcd cluster misconfigured error

Have two servers : pg1: 10.80.80.195 and pg2: 10.80.80.196
Version of etcd :
etcd Version: 3.2.0
Git SHA: 66722b1
Go Version: go1.8.3
Go OS/Arch: linux/amd64
I'm trying to run like this :
pg1 server :
etcd --name infra0 --initial-advertise-peer-urls http://10.80.80.195:2380 --listen-peer-urls http://10.80.80.195:2380 --listen-client-urls http://10.80.80.195:2379,http://127.0.0.1:2379 --advertise-client-urls http://10.80.80.195:2379 --initial-cluster-token etcd-cluster-1 --initial-cluster infra0=http://10.80.80.195:2380,infra1=http://10.80.80.196:2380 --initial-cluster-state new
pg2 server :
etcd --name infra1 --initial-advertise-peer-urls http://10.80.80.196:2380 --listen-peer-urls http://10.80.80.196:2380 --listen-client-urls http://10.80.80.196:2379,http://127.0.0.1:2379 --advertise-client-urls http://10.80.80.196:2379 --initial-cluster-token etcd-cluster-1 --initial-cluster infra0=http://10.80.80.195:2380,infra1=http://10.80.80.196:2380 --initial-cluster-state new
When trying to cherck health state on pg1:
etcdctl cluster-health
have an error :
cluster may be unhealthy: failed to list members
Error: client: etcd cluster is unavailable or misconfigured; error #0: client: endpoint http://127.0.0.1:2379 exceeded header timeout
; error #1: dial tcp 127.0.0.1:4001: getsockopt: connection refused
error #0: client: endpoint http://127.0.0.1:2379 exceeded header timeout
error #1: dial tcp 127.0.0.1:4001: getsockopt: connection refused
What I'm doing wrong and how to fix it ?
Both servers run on virtual machines with Bridged Adapter
I've got similar error when I set up etcd clusters using systemd according to the official tutorial from kubernetes.
It's three centos 7 of medium instances on AWS. I'm pretty sure the security groups are correct. And I've just:
$ systemctl restart network
and the
$ etcdctl cluster-health
just gives a healthy result.

Kubernetes on Azure : connectex

Followed steps from the link to create a K8s cluster using the Azure Portal. Tried using kubectl on a remote machine to check if it's working. Got this error.
Unable to connect to the server: dial tcp 13.90.35.157:443: connectex:
A connection attempt failed because the connected party did not
properly respond after a period of time, or established connection
failed because connected host has failed to respond.
I can SSH to the K8s master. Tried kubectl get nodes from the master and got similar error.
It is really hard to say from such a description what went wrong, but as this is a new cluster ( and I'm saying this because sometimes k8s cluster gets deployed but doesn't really work, so ), I would suggest deleting it and creating a new one and\or creating it using the Azure Cli\Azure Cloud Shell.
Basically its as simple as:
az acs create -n acs-cluster -g acsrg1 -d applink789 --generate-ssh-keys
if you have the resource group created, if not you can create it with:
az group create -n acsrg1 -l "westus"
According to your description, it seems you have not configured the Service Principal correctly. I use wrong service principal to deploy K8S in Azure, get the same error:
C:\Users>kubectl get nodes
Unable to connect to the server: dial tcp 13.90.27.73:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
You may need to check to ensure the credentials were provided accurately, and that the configured Service Principal has read and write permissions to the target Subscription.
If your Service Principal is misconfigured, none of the kubernetes components will come up in a healthy manner. We can check to see if this the problem:
root#k8s-master-6FEE48E1-0:~# journalctl -u kubelet | grep --text autorest
If you see output that looks like the following, it means you have not configured the service Principal correctly.
root#k8s-master-6FEE48E1-0:~# journalctl -u kubelet | grep --text autorest
Jun 01 01:58:47 k8s-master-6FEE48E1-0 docker[5522]: E0601 01:58:47.447321 6028 kubelet.go:1186] Cannot get Node info: failed to get external ID from cloud provider: autorest#WithErrorUnlessStatusCode: POST https://login.microsoftonline.com/1fcf418e-66ed-4c99-9449-d8e18bf8737a/oauth2/token?api-version=1.0 failed with 400 Bad Request: StatusCode=400
Jun 01 01:58:47 k8s-master-6FEE48E1-0 docker[5522]: E0601 01:58:47.627128 6028 kubelet_node_status.go:70] Unable to construct api.Node object for kubelet: failed to get external ID from cloud provider: autorest#WithErrorUnlessStatusCode: POST https://login.microsoftonline.com/1fcf418e-66ed-4c99-9449-d8e18bf8737a/oauth2/token?api-version=1.0 failed with 400 Bad Request: StatusCode=400
Jun 01 01:58:47 k8s-master-6FEE48E1-0 docker[5522]: E0601 01:58:47.885092 6028 kubelet_node_status.go:70] Unable to construct api.Node object for kubelet: failed to get external ID from cloud provider: autorest#WithErrorUnlessStatusCode: POST https://login.microsoftonline.com/1fcf418e-66ed-4c99-9449-d8e18bf8737a/oauth2/token?api-version=1.0 failed with 400 Bad Request: StatusCode=400
More information about how to create /configure a service principal for ACS-Engin Kubernetes cluster, please refer to this link.

I can't connect to cassandra from nodejs app in docker container

I have a nodejs app inside a docker container (node:7.8.0) using 'bridge' network. I use the cassandra driver to connect with a cassandra server, but it raises timeout exception when initialize the connection:
Error: The host 172.16.210.101:9042 did not reply before timeout 12000 ms
at OperationTimedOutError.DriverError (node_modules/cassandra-driver /lib/errors.js:14:19)
at new OperationTimedOutError (node_modules/cassandra-driver/lib/errors.js:104:33)
at Connection.onTimeout (node_modules/cassandra-driver/lib/connection.js:645:20)
at Timeout._onTimeout (node_modules/cassandra-driver/lib/connection.js:620:10)
at ontimeout (timers.js:386:14)
at tryOnTimeout (timers.js:250:5)
at Timer.listOnTimeout (timers.js:214:5)
From inside the container, I can ping the cassandra server and do a telnet connection.
Using 'host' network works, and executing the app in a "standard" environment too.
Any help is appreciate.
Ok, I found the solution.
The MTU of my host machine is 1450, and docker0 uses by default 1500. It produces an error.
So, I change the MTU for docker and it works.
I use a debian host and I followed next steps:
Copy the service file:
cp /lib/systemd/system/docker.service /etc/systemd/system/docker.service
Then, edit the "ExecStart" line like this:
ExecStart=/usr/bin/dockerd -H fd:// --mtu=1400
Finally, restart docker:
sudo systemctl daemon-reload
sudo systemctl restart docker
Source:
https://rahulait.wordpress.com/2016/02/28/modifying-default-mtu-for-docker-containers/

Resources