Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrates GitLab Runner into DTaaS #1082

Closed
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
8855306
Integrates GitLab Runner into DTaaS
aryanpingle Nov 26, 2024
c0fa797
Add localhost access to runner
aryanpingle Dec 5, 2024
0f3a1b3
Use foo.com for template server dns
aryanpingle Dec 5, 2024
a164780
Update runner documentation
aryanpingle Dec 5, 2024
42d14dd
Update gitlab variable in documentation
aryanpingle Dec 5, 2024
8fd59d0
Refactor runner code
aryanpingle Dec 10, 2024
721271f
Update GITLAB-RUNNER.md
aryanpingle Dec 10, 2024
4c6b680
Switch to instance runners
aryanpingle Dec 11, 2024
21cb714
Updates runner documentation on the admin page
aryanpingle Dec 11, 2024
3d00eb8
Fix typo in INTEGRATION.md
aryanpingle Dec 12, 2024
495e2d1
Minor changes
aryanpingle Dec 12, 2024
7d4b4fd
Instance + group + project runners
aryanpingle Dec 12, 2024
ca3527a
Finishes up runner guides
aryanpingle Dec 15, 2024
488cca8
Adds DevOps developer guide
aryanpingle Dec 16, 2024
86f33ed
Adds executor information to GITLAB-RUNNER.md
aryanpingle Dec 16, 2024
1ebe54a
Add DevOps Framework to developer documentation
aryanpingle Dec 17, 2024
e16245a
Rename implemented-classes.md
aryanpingle Dec 17, 2024
0e31d1b
Fix codeclimate issues (devops files)
aryanpingle Dec 17, 2024
741a057
Fix codeclimate issues
aryanpingle Dec 18, 2024
b074227
Edits api.md
aryanpingle Dec 18, 2024
7d0a847
Add citations
aryanpingle Dec 18, 2024
20bf31c
Remove GitlabDriver reference
aryanpingle Dec 18, 2024
402b086
Add TS implementation
aryanpingle Dec 18, 2024
1fe8d81
GitLab parent-child pipeline
aryanpingle Dec 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion deploy/services/gitlab/.env
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
GITLAB_HOME='/Users/<Username>/DTaaS/deploy/services/gitlab'
DTAAS_DIR='/Users/<username>/DTaaS'
SERVER_DNS='foo.com'
2 changes: 1 addition & 1 deletion deploy/services/gitlab/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Edit the `.env` file available in this directory to contain the following variab

| Variable | Example Value | Explanation |
| :---------- | :------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------- |
| GITLAB_HOME | '/home/Desktop/DTaaS/deploy/services/gitlab' | Full path to the DTaaS gitlab directory. This is an absolute path with no trailing slash. |
| DTAAS_DIR | '/Users/<username>/DTaaS' | Full path to the DTaaS directory. This is an absolute path with no trailing slash. |
| SERVER_DNS | either `foo.com` or `localhost` | The server DNS, if you are deploying with a dedicated server. Remember not use _http(s)_ at the beginning of the DNS string. |

**NOTE**: The DTaaS client uses the `react-oidc-context` node package, which
Expand Down
6 changes: 3 additions & 3 deletions deploy/services/gitlab/compose.gitlab.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ services:
nginx['redirect_http_to_https'] = false
letsencrypt['enable'] = false
volumes:
- '${GITLAB_HOME}/config:/etc/gitlab'
- '${GITLAB_HOME}/logs:/var/log/gitlab'
- '${GITLAB_HOME}/data:/var/opt/gitlab'
- '${DTAAS_DIR}/deploy/services/gitlab/config:/etc/gitlab'
- '${DTAAS_DIR}/deploy/services/gitlab/logs:/var/log/gitlab'
- '${DTAAS_DIR}/deploy/services/gitlab/data:/var/opt/gitlab'
shm_size: '256m'
labels:
- "traefik.enable=true"
Expand Down
106 changes: 106 additions & 0 deletions deploy/services/runner/GITLAB-RUNNER.md
prasadtalasila marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
# GitLab Runners

GitLab Runners are agents that execute the tasks defined in GitLab CI/CD
pipelines. A runner is connected to a GitLab instance (may be
`https://gitlab.com` or a local instance such as `https://foo.com/gitlab`),
and executes jobs for a single project, or any project within a GitLab group.

This document outlines the steps needed to create a Docker container named
`gitlab-runner` which will contain a single runner that will be responsible for
the execution of Digital Twins. There are two installation scenarios:

1. Localhost Installation - You are using the integrated runner locally with
a GitLab server hosted at `https://localhost/gitlab`.
2. Server Installation - You are using the integrated runner with a GitLab
instance hosted on a production server. This server may be a remote server
prasadtalasila marked this conversation as resolved.
Show resolved Hide resolved
and not necessarily your own, and may have TLS enabled with a self-signed
certificate.

In either case, follow the steps as outlined below.

## Obtaining A Registration Token

First, we will obtain the token necessary to register the runner for the GitLab
instance.

1. On the __Admin__ dashboard, navigate to __CI / CD > Runners__.
1. Select __New instance runner__.
1. Under __Platform__, select the Linux operating system.
1. Under __Tags__, add a `linux` tag.
1. Select __Create runner__. A runner authentication token will be generated,
be sure to save it somewhere.

You should see the following screen:

![Runner Registration Screen](./runner-registration.png)

## Configuring the Runner

Depending on your installation scenario, the runner setup reads certain
configurations settings:

1. Localhost Installation - uses `deploy/docker/.env.local`
1. Server Installation - uses `deploy/docker/.env.server`

Ensure these files are properly set up.

We need to register the runner with the GitLab instance so that they may
communicate with each other. In this directory, the file `runner-config.toml`
has the following template:

```toml
[[runners]]
name = "dtaas-runner-1"
url = "https://foo.com/gitlab/" # Edit this
token = "xxx" # Edit this
executor = "docker"
[runners.docker]
tls_verify = false
image = "ruby:2.7"
privileged = false
disable_entrypoint_overwrite = false
oom_kill_disable = false
volumes = ["/cache"]
network_mode = "host" # Disable this in secure contexts
```

1. Set the `url` variable to the URL of your GitLab instance.
1. Set the `token` variable to the runner registration token you obtained earlier.
1. If you are following the server installation scenario, remove the line
`network_mode = "host"`.

## Start the GitLab Runner

You may use the following commands to start and stop the `gitlab-runner`
container respectively, depending on your installation scenario:

1. Localhost Installation

```bash
docker compose -f deploy/services/runner/compose.runner.local.yml --env-file deploy/docker/.env.local up -d
docker compose -f deploy/services/runner/compose.runner.local.yml --env-file deploy/docker/.env.local down
```

2. Server Installation

```bash
docker compose -f deploy/services/runner/compose.runner.server.yml --env-file deploy/docker/.env.server up -d
docker compose -f deploy/services/runner/compose.runner.server.yml --env-file deploy/docker/.env.server down
```

Once the container starts, the runner within it will run automatically. You can
tell if the runner is correctly configured by navigating to
`CI/CD > Runners` on your Admin dashboard and seeing something like this:

![Status indicator under Admin Area > Runners](./runner-activation.png)

You will now have a GitLab runner ready to accept jobs for the GitLab instance.

## Resource Allocation

By default, the runner executor will pick up as many jobs as it can (limited
by the number of threads on the machine). To limit the number of jobs that may
be run concurrently, you can set the `limit` variable in `config.toml`.

A list of advanced configuration options is provided on the
[GitLab documentation page](https://docs.gitlab.com/runner/configuration/advanced-configuration.html).
15 changes: 15 additions & 0 deletions deploy/services/runner/compose.runner.local.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Environment variables taken from deploy/docker/.env.local

services:
gitlab-runner:
container_name: gitlab-runner
# Runner image version is independent of the gitlab-ce image version
image: gitlab/gitlab-runner:alpine-v17.5.3
volumes:
- "./runner-config.toml:/etc/gitlab-runner/config.toml:ro"
- "/var/run/docker.sock:/var/run/docker.sock:ro"
# Maps the self-signed certificate for localhost to the container
- "${DTAAS_DIR}/deploy/docker/certs/localhost/fullchain.pem:/etc/gitlab-runner/certs/localhost.crt:ro"

# To make https://localhost accessible from the container
network_mode: host
13 changes: 13 additions & 0 deletions deploy/services/runner/compose.runner.server.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Environment variables taken from deploy/docker/.env.server

services:
gitlab-runner:
container_name: gitlab-runner
# Runner image version is independent of the gitlab-ce image version
image: gitlab/gitlab-runner:alpine-v17.5.3
volumes:
- "./runner-config.toml:/etc/gitlab-runner/config.toml:ro"
- "/var/run/docker.sock:/var/run/docker.sock:ro"
# Maps the self-signed certificate for your server to the container
# Remove this if you are not using a self-signed certificate
- "${DTAAS_DIR}/deploy/docker/certs/${SERVER_DNS}/fullchain.pem:/etc/gitlab-runner/certs/${SERVER_DNS}.crt:ro"
Binary file added deploy/services/runner/runner-activation.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions deploy/services/runner/runner-config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[[runners]]
name = "dtaas-runner-1"
url = "https://foo.com/gitlab/" # Edit this
token = "xxx" # Edit this
executor = "docker"
[runners.docker]
tls_verify = false
image = "ruby:2.7"
privileged = false
disable_entrypoint_overwrite = false
oom_kill_disable = false
volumes = ["/cache"]
network_mode = "host" # Disable this in secure contexts
Binary file added deploy/services/runner/runner-registration.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.