terraform-aws-gitlab-runner icon indicating copy to clipboard operation
terraform-aws-gitlab-runner copied to clipboard

Modify hosts file of machine (and agent)

Open veshant opened this issue 2 years ago • 1 comments

I need to append to the hosts files of the machine so that traffic is routed locally instead of the public ip. Is there a configuration option that would allow this? Or possibly to execute a script that could echo into the hosts file.

veshant avatar Sep 28 '22 00:09 veshant

Could you please give us more details on that use case please?

Sounds like userdata_pre_install or userdata_post_install if it is related to the Agent. If it is related to the Runners before_script in the .gitlab-ci.yml would be a good choice.

kayman-mk avatar Oct 13 '22 07:10 kayman-mk

@veshant Does the above mentioned solution fit your needs?

kayman-mk avatar Nov 27 '22 15:11 kayman-mk

Sorry didn't see this earlier. I'm trying to have traffic all routed through AWS instead of public internet (GL instance and runners in AWS), this specific issue is related to adding into the container registry. the before_script would work, however that would need to be added into every project and future projects too. Was hoping there was a way to have it globally set for the runners.

veshant avatar Nov 29 '22 20:11 veshant

Sounds that #547 could fix your issue. There is a new parameter runners_extra_hosts available.

kayman-mk avatar Nov 30 '22 06:11 kayman-mk

@kayman-mk I actually committed that haha. Unfortunately it adds to the docker machine and not the docker container. I'm thinking I might try building an image with the hosts, but i'll need to look into that more.

veshant avatar Dec 01 '22 07:12 veshant

Shouldn't we enhance #547 to pass the hosts to the docker container? We could inject it into the pre_build_script or pre_clone_script, right?

kayman-mk avatar Dec 01 '22 10:12 kayman-mk

Example script:

xyz:
  stage: verify
  script:
    - echo "127.0.0.1 ppp" >> /etc/hosts
    - ping ppp

kayman-mk avatar Dec 12 '22 18:12 kayman-mk

Yes that would make sense. I was waiting for the new GitLab Runner Autoscaling architecture to see if there were any other improvements that would allow this with a better approach. Is there any plan to support the new taskscaler + aws fleeting plugin since they are moving away from docker machine?

Refs: https://docs.gitlab.com/ee/architecture/blueprints/runner_scaling/index.html https://gitlab.com/gitlab-org/gitlab-runner/-/issues/29312 https://gitlab.com/gitlab-org/gitlab-runner/-/issues/29219#note_1169146211

veshant avatar Dec 14 '22 18:12 veshant

We should definitely support that. I created a new issue #624 for that and close this issue as answered.

kayman-mk avatar Jan 01 '23 16:01 kayman-mk