在 EC2 实例上启动 gitlab-runner 服务时,遇到以下问题:
Nov 10 17:17:08 ip-10-180-30-96.eu-central-1.compute.internal gitlab-runner[7787]: (runner-zx178tugs-gitlab-docker-machine-1699633027-b8326ab1) Launching instance... driver=amazonec2 name=runner-zx178tugs-gitlab-docker-machine-1699633027-b8326ab1 operation=create
Nov 10 17:17:08 ip-10-180-30-96.eu-central-1.compute.internal gitlab-runner[7787]: (runner-zx178tugs-gitlab-docker-machine-1699633027-31315d91) Launching instance... driver=amazonec2 name=runner-zx178tugs-gitlab-docker-machine-1699633027-31315d91 operation=create
Nov 10 17:17:34 ip-10-180-30-96.eu-central-1.compute.internal gitlab-runner[7787]: Waiting for machine to be running, this may take a few minutes... driver=amazonec2 name=runner-zx178tugs-gitlab-docker-machine-1699633027-b8326ab1 operation=create
Nov 10 17:17:34 ip-10-180-30-96.eu-central-1.compute.internal gitlab-runner[7787]: Detecting operating system of created instance... driver=amazonec2 name=runner-zx178tugs-gitlab-docker-machine-1699633027-b8326ab1 operation=create
Nov 10 17:17:34 ip-10-180-30-96.eu-central-1.compute.internal gitlab-runner[7787]: Waiting for SSH to be available... driver=amazonec2 name=runner-zx178tugs-gitlab-docker-machine-1699633027-b8326ab1 operation=create
Nov 10 17:17:34 ip-10-180-30-96.eu-central-1.compute.internal gitlab-runner[7787]: Waiting for machine to be running, this may take a few minutes... driver=amazonec2 name=runner-zx178tugs-gitlab-docker-machine-1699633027-31315d91 operation=create
Nov 10 17:17:34 ip-10-180-30-96.eu-central-1.compute.internal gitlab-runner[7787]: Detecting operating system of created instance... driver=amazonec2 name=runner-zx178tugs-gitlab-docker-machine-1699633027-31315d91 operation=create
Nov 10 17:17:34 ip-10-180-30-96.eu-central-1.compute.internal gitlab-runner[7787]: Waiting for SSH to be available... driver=amazonec2 name=runner-zx178tugs-gitlab-docker-machine-1699633027-31315d91 operation=create
Nov 10 17:17:46 ip-10-180-30-96.eu-central-1.compute.internal gitlab-runner[7787]: Detecting the provisioner... driver=amazonec2 name=runner-zx178tugs-gitlab-docker-machine-1699633027-31315d91 operation=create
Nov 10 17:17:47 ip-10-180-30-96.eu-central-1.compute.internal gitlab-runner[7787]: Provisioning with ubuntu(systemd)... driver=amazonec2 name=runner-zx178tugs-gitlab-docker-machine-1699633027-31315d91 operation=create
Nov 10 17:17:48 ip-10-180-30-96.eu-central-1.compute.internal gitlab-runner[7787]: Detecting the provisioner... driver=amazonec2 name=runner-zx178tugs-gitlab-docker-machine-1699633027-b8326ab1 operation=create
Nov 10 17:17:50 ip-10-180-30-96.eu-central-1.compute.internal gitlab-runner[7787]: Provisioning with ubuntu(systemd)... driver=amazonec2 name=runner-zx178tugs-gitlab-docker-machine-1699633027-b8326ab1 operation=create
Nov 10 17:18:05 ip-10-180-30-96.eu-central-1.compute.internal gitlab-runner[7787]: Installing Docker... driver=amazonec2 name=runner-zx178tugs-gitlab-docker-machine-1699633027-b8326ab1 operation=create
Nov 10 17:18:05 ip-10-180-30-96.eu-central-1.compute.internal gitlab-runner[7787]: Installing Docker... driver=amazonec2 name=runner-zx178tugs-gitlab-docker-machine-1699633027-31315d91 operation=create
Nov 10 17:18:56 ip-10-180-30-96.eu-central-1.compute.internal gitlab-runner[7787]: Copying certs to the local machine directory... driver=amazonec2 name=runner-zx178tugs-gitlab-docker-machine-1699633027-31315d91 operation=create
Nov 10 17:18:56 ip-10-180-30-96.eu-central-1.compute.internal gitlab-runner[7787]: Copying certs to the local machine directory... driver=amazonec2 name=runner-zx178tugs-gitlab-docker-machine-1699633027-b8326ab1 operation=create
Nov 10 17:18:57 ip-10-180-30-96.eu-central-1.compute.internal gitlab-runner[7787]: Copying certs to the remote machine... driver=amazonec2 name=runner-zx178tugs-gitlab-docker-machine-1699633027-31315d91 operation=create
Nov 10 17:18:57 ip-10-180-30-96.eu-central-1.compute.internal gitlab-runner[7787]: Copying certs to the remote machine... driver=amazonec2 name=runner-zx178tugs-gitlab-docker-machine-1699633027-b8326ab1 operation=create
Nov 10 17:18:58 ip-10-180-30-96.eu-central-1.compute.internal gitlab-runner[7787]: Setting Docker configuration on the remote daemon... driver=amazonec2 name=runner-zx178tugs-gitlab-docker-machine-1699633027-31315d91 operation=create
Nov 10 17:18:58 ip-10-180-30-96.eu-central-1.compute.internal gitlab-runner[7787]: Setting Docker configuration on the remote daemon... driver=amazonec2 name=runner-zx178tugs-gitlab-docker-machine-1699633027-b8326ab1 operation=create
Nov 10 17:19:02 ip-10-180-30-96.eu-central-1.compute.internal gitlab-runner[7787]: Checking connection to Docker... driver=amazonec2 name=runner-zx178tugs-gitlab-docker-machine-1699633027-b8326ab1 operation=create
Nov 10 17:19:02 ip-10-180-30-96.eu-central-1.compute.internal gitlab-runner[7787]: Checking connection to Docker... driver=amazonec2 name=runner-zx178tugs-gitlab-docker-machine-1699633027-31315d91 operation=create
Nov 10 17:19:04 ip-10-180-30-96.eu-central-1.compute.internal gitlab-runner[7787]: ERROR: Error creating machine: Error checking the host: Error checking and/or regenerating the certs: There was an error validating certificates for host "10.180.26.43:2376": remote error: tls: bad certificate driver=amazonec2 name=runner-zx178tugs-gitlab-docker-machine-1699633027-b8326ab1 operation=create
我没有手动设置任何证书
我在
/etc/gitlab-runner/config.toml
中的配置是:
concurrent = 10
check_interval = 0
shutdown_timeout = 0
[session_server]
session_timeout = 1800
[[runners]]
name = "my-test-runner"
limit = 5
url = "https://gitlab.com"
id = 27483251
token = "XXXXXXXXX"
token_obtained_at = 2023-11-10T15:19:18Z
token_expires_at = 0001-01-01T00:00:00Z
executor = "docker+machine"
[runners.cache]
Type = "s3"
Shared = true
MaxUploadedArchiveSize = 0
[runners.cache.s3]
ServerAddress = "s3.amazonaws.com"
AccessKey = "XXXXXX"
SecretKey = "XXXXXX"
BucketName = "gitlab-runner-s3cache"
BucketLocation = "eu-central-1"
[runners.docker]
tls_verify = false
image = "alpine:latest"
privileged = true
disable_entrypoint_overwrite = false
oom_kill_disable = false
disable_cache = true
shm_size = 0
network_mtu = 0
[runners.machine]
IdleCount = 2
IdleScaleFactor = 0.0
IdleCountMin = 0
IdleTime = 1800
MaxBuilds = 100
MachineDriver = "amazonec2"
MachineName = "gitlab-docker-machine-%s"
MachineOptions = ["amazonec2-access-key=XXXXXXXX", "amazonec2-secret-key=XXXXXX", "amazonec2-region=eu-central-1", "amazonec2-vpc-id=vpc-XXXXXXX", "amazonec2-subnet-id=subnet-XXXXX", "amazonec2-use-private-address=true", "amazonec2-tags=runner-manager-name,gitlab-aws-autoscaler,gitlab,true,gitlab-runner-autoscale,true", "amazonec2-security-group=gitlab-runner-sec-group", "amazonec2-instance-type=t2.small", "amazonec2-request-spot-instance=true", "amazonec2-spot-price=0.05", "amazonec2-zone=a"]
使用 root (sudo) 启动 gitlab-runner
sudo systemctl start gitlab-runner
安全组权限为:
manager-security-group
:全部出站
runner-security-group
:全部入站、全部出站
[ec2-user@ip ~]$ gitlab-runner --version
Version: 16.5.0
[ec2-user@ip ~]$ sudo docker-machine ls
NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS
runner-zx178tugs-gitlab-docker-machine-1699634328-0b78b029 - amazonec2 Running tcp://ip:2376 Unknown Unable to query docker version: Get https://ip:2376/v1.15/version: remote error: tls: bad certificate
我错过了什么吗?看来,应该可以了。
解决方案是在我的 CloudFormationInit 中注册运行器之前添加
docker-machine
创建:
如果您遇到这个问题,这里有一些(希望)有用的链接: