Gitlab-CI: How do I run a job on a specific server?

I set up Gitlab and Gitlab-CI on a k8s cluster in AWS. I have jobs that use a lot of resources. I want to run these jobs on specific instances in AWS. How can this be done?

1 answer

  • answered 2019-07-15 10:14 Nicolas Pepinster

    Kubernetes configuration

    You need to add a node selector which enable you to assign pods on specific nodes

    kubectl label nodes <node-name> gitlab=true
    

    Gitlab Runner configuration

    • Specify a tag associated to the runner. In your case, uncheck the Run untagged jobs option.
    • Specify a node selector using the keyword node_selector :
      [runners.kubernetes.node_selector]
        gitlab = "true"
    

    Check a more complete example of config.toml on gitlab website.

    Gitlab CI configuration

    Refer the tag of your runner in your .gitlab-ci.yml

    job:
      tags:
        - big_server