Implement: Declarative act_runner configuration and Docker integration
Migrates `act_runner` configuration from shell-generated to an Ansible-templated `config.yaml`. This enables: - Dynamic label provisioning, including `test-runner:docker://ubuntu:22.04`. - Explicit configuration for joining the `iklimco-net` overlay network. - Docker socket mounting for CI/CD jobs to interact with the Docker daemon. Updates `setup/05-test-runner-ve-deploy-onkosullari.md` and other related documentation to reflect the new automated and integrated runner setup.
This commit is contained in:
parent
2198f932cd
commit
5fe57ee108
@ -3,6 +3,6 @@ act_runner_version: "0.2.12"
|
|||||||
act_runner_arch: "linux-amd64"
|
act_runner_arch: "linux-amd64"
|
||||||
act_runner_gitea_url: "https://git.tarla.io"
|
act_runner_gitea_url: "https://git.tarla.io"
|
||||||
act_runner_name: "iklim-test-app"
|
act_runner_name: "iklim-test-app"
|
||||||
act_runner_labels: "ubuntu-latest,ubuntu-22.04,ubuntu-20.04"
|
act_runner_labels: "ubuntu-latest,ubuntu-22.04,ubuntu-20.04,test-runner:docker://ubuntu:22.04"
|
||||||
# Gitea'dan alınan tek seferlik registration token; kayıt olmadıysa boş bırakılır.
|
# Gitea'dan alınan tek seferlik registration token; kayıt olmadıysa boş bırakılır.
|
||||||
act_runner_registration_token: "{{ vault_gitea_runner_token | default('') }}"
|
act_runner_registration_token: "{{ vault_gitea_runner_token | default('') }}"
|
||||||
|
|||||||
@ -33,19 +33,14 @@
|
|||||||
group: gitea-runner
|
group: gitea-runner
|
||||||
mode: "0750"
|
mode: "0750"
|
||||||
|
|
||||||
# Kayıt öncesinde varsayılan config.yaml üretilir; dosya varsa tekrar yazılmaz.
|
- name: Deploy act_runner config
|
||||||
- name: Generate default config.yaml
|
ansible.builtin.template:
|
||||||
ansible.builtin.shell:
|
src: config.yaml.j2
|
||||||
cmd: /usr/local/bin/act_runner generate-config > /etc/gitea-act-runner/config.yaml
|
dest: /etc/gitea-act-runner/config.yaml
|
||||||
creates: /etc/gitea-act-runner/config.yaml
|
|
||||||
become_user: gitea-runner
|
|
||||||
|
|
||||||
- name: Fix config.yaml ownership
|
|
||||||
ansible.builtin.file:
|
|
||||||
path: /etc/gitea-act-runner/config.yaml
|
|
||||||
owner: gitea-runner
|
owner: gitea-runner
|
||||||
group: gitea-runner
|
group: gitea-runner
|
||||||
mode: "0640"
|
mode: "0640"
|
||||||
|
notify: restart act_runner
|
||||||
|
|
||||||
# .runner dosyası varsa runner zaten kayıtlıdır; creates ile idempotent hale gelir.
|
# .runner dosyası varsa runner zaten kayıtlıdır; creates ile idempotent hale gelir.
|
||||||
- name: Register runner with Gitea
|
- name: Register runner with Gitea
|
||||||
|
|||||||
39
ansible/roles/act_runner/templates/config.yaml.j2
Normal file
39
ansible/roles/act_runner/templates/config.yaml.j2
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
log:
|
||||||
|
level: info
|
||||||
|
|
||||||
|
runner:
|
||||||
|
file: .runner
|
||||||
|
capacity: 1
|
||||||
|
timeout: 3h
|
||||||
|
insecure: false
|
||||||
|
fetch_timeout: 5s
|
||||||
|
fetch_interval: 2s
|
||||||
|
labels:
|
||||||
|
{% for label in act_runner_labels.split(',') %}
|
||||||
|
- "{{ label }}"
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
|
cache:
|
||||||
|
enabled: true
|
||||||
|
dir: ""
|
||||||
|
host: ""
|
||||||
|
port: 0
|
||||||
|
external_server: ""
|
||||||
|
|
||||||
|
container:
|
||||||
|
# Job container'ları iklimco-net overlay network'üne katılır;
|
||||||
|
# böylece iklim-db_postgresql ve iklim-db_mongodb servislerine direkt erişebilir.
|
||||||
|
network: "iklimco-net"
|
||||||
|
enable_ipv6: false
|
||||||
|
privileged: false
|
||||||
|
# Docker socket mount: docker build/push/stack komutlarının çalışması için gerekli.
|
||||||
|
options: "-v /var/run/docker.sock:/var/run/docker.sock"
|
||||||
|
workdir_parent: ""
|
||||||
|
valid_volumes:
|
||||||
|
- "/var/run/docker.sock"
|
||||||
|
docker_host: ""
|
||||||
|
force_pull: false
|
||||||
|
force_rebuild: false
|
||||||
|
|
||||||
|
host:
|
||||||
|
workdir_parent: ""
|
||||||
@ -134,7 +134,8 @@ Final step order in the pipeline:
|
|||||||
14. **Prepare SWAG Directories** ← NEW
|
14. **Prepare SWAG Directories** ← NEW
|
||||||
15. Deploy Swarm Stack
|
15. Deploy Swarm Stack
|
||||||
16. **Bootstrap SWAG Certificate** ← NEW
|
16. **Bootstrap SWAG Certificate** ← NEW
|
||||||
17. Review Environment
|
17. **Run Database Init Scripts** ← NEW (önceki oturumda eklendi)
|
||||||
|
18. Review Environment
|
||||||
|
|
||||||
> Steps 8 (Provision Vault) runs before SWAG because it creates Docker secrets and
|
> Steps 8 (Provision Vault) runs before SWAG because it creates Docker secrets and
|
||||||
> AppRole IDs — Vault must be reachable for this. On re-deploys, Vault is already
|
> AppRole IDs — Vault must be reachable for this. On re-deploys, Vault is already
|
||||||
|
|||||||
@ -18,8 +18,14 @@ Terraform/Ansible setup aşamalarından hangisinde ele alındığını gösterir
|
|||||||
| `/opt/iklimco/...` dizinleri | **Ansible `03-test-ansible-bootstrap.md`** — `node_dirs` role |
|
| `/opt/iklimco/...` dizinleri | **Ansible `03-test-ansible-bootstrap.md`** — `node_dirs` role |
|
||||||
| StorageBox DAVFS mount (`u469968-sub4`) | **Ansible `03-test-ansible-bootstrap.md`** — `storagebox` role |
|
| StorageBox DAVFS mount (`u469968-sub4`) | **Ansible `03-test-ansible-bootstrap.md`** — `storagebox` role |
|
||||||
| DB stack deploy (PostgreSQL + MongoDB on `iklim-db-01`) | **Manuel `04-test-db-docker-kurulum.md`** |
|
| DB stack deploy (PostgreSQL + MongoDB on `iklim-db-01`) | **Manuel `04-test-db-docker-kurulum.md`** |
|
||||||
| `act_runner` systemd kurulumu | **Ansible `05-test-runner-ve-deploy-onkosullari.md`** — `gitea_runner` role |
|
| `act_runner` systemd kurulumu | **Ansible `05-test-runner-ve-deploy-onkosullari.md`** — `act_runner` role (`test-app-post-stack.yml`) |
|
||||||
| GoDaddy credentials storagebox'a yükleme | **Manuel kalır** — secret yönetimi, Terraform/Ansible dışı |
|
| GoDaddy credentials storagebox'a yükleme | **Manuel kalır** — secret yönetimi, Terraform/Ansible dışı |
|
||||||
|
| `docker-stack-infra.yml` port kaldırma + SWAG/cert-reloader ekleme | **Pipeline `deploy-test.yml`** + **repo değişikliği** — `roadmap/test-env/03` |
|
||||||
|
| SWAG nginx proxy conf'ları (`swag/proxy-confs/*.conf.tpl`) | **Repo içinde teslim edildi** — `roadmap/test-env/04` |
|
||||||
|
| APISIX SSL cert yükleme bloğu kaldırma (`init/apisix-core/init.sh`) | **Repo değişikliği** — `roadmap/test-env/05` |
|
||||||
|
| cert-reloader sidecar servisi | **`docker-stack-infra.yml`'e eklendi** — `roadmap/test-env/06` |
|
||||||
|
| Pipeline güncelleme: Prepare SWAG Dirs + Bootstrap SWAG Cert + Run DB Init | **`deploy-test.yml`** — `roadmap/test-env/07` |
|
||||||
|
| Deployment sonrası doğrulama kontrol listesi | **Manuel `roadmap/test-env/08-verify.md`** |
|
||||||
|
|
||||||
## PROD ortamı
|
## PROD ortamı
|
||||||
|
|
||||||
@ -40,7 +46,7 @@ Terraform/Ansible setup aşamalarından hangisinde ele alındığını gösterir
|
|||||||
| etcd cluster deploy (Patroni için) | **Manuel `08-prod-db-cluster-kurulum.md`** — Bölüm 5.2 |
|
| etcd cluster deploy (Patroni için) | **Manuel `08-prod-db-cluster-kurulum.md`** — Bölüm 5.2 |
|
||||||
| MongoDB replica set deploy | **Manuel `08-prod-db-cluster-kurulum.md`** — Bölüm 4 |
|
| MongoDB replica set deploy | **Manuel `08-prod-db-cluster-kurulum.md`** — Bölüm 4 |
|
||||||
| Patroni + PostgreSQL HA deploy | **Manuel `08-prod-db-cluster-kurulum.md`** — Bölüm 5.4 |
|
| Patroni + PostgreSQL HA deploy | **Manuel `08-prod-db-cluster-kurulum.md`** — Bölüm 5.4 |
|
||||||
| 3× `act_runner` systemd (HA runner) | **Ansible `09-prod-runner-ha-ve-swarm.md`** — `gitea_runner` role |
|
| 3× `act_runner` systemd (HA runner) | **Ansible `09-prod-runner-ha-ve-swarm.md`** — `act_runner` role |
|
||||||
| GoDaddy credentials storagebox'a yükleme | **Manuel kalır** — secret yönetimi, Terraform/Ansible dışı |
|
| GoDaddy credentials storagebox'a yükleme | **Manuel kalır** — secret yönetimi, Terraform/Ansible dışı |
|
||||||
|
|
||||||
## Klasör yapısı
|
## Klasör yapısı
|
||||||
|
|||||||
@ -68,7 +68,7 @@ Public internete acik portlar sadece:
|
|||||||
|
|
||||||
`8200/tcp` Vault public internete acilmayacak. Vault sadece private network veya Docker overlay icinden erisilebilir olmalidir.
|
`8200/tcp` Vault public internete acilmayacak. Vault sadece private network veya Docker overlay icinden erisilebilir olmalidir.
|
||||||
|
|
||||||
Mevcut uygulama stack dosyalarinda bazi servisler host port publish ediyor olabilir. Hetzner Cloud firewall public ingress'i engelleyecegi icin bu portlar public'ten erisilemez olmalidir. Ancak uzun vadede stack manifestleri de bu politikaya uyacak sekilde sadeleştirilmelidir.
|
`docker-stack-infra.yml` bu politikaya uygun hale getirilmiştir: yalnızca SWAG servisi 80/443 portlarını yayınlar; Vault, APISIX, RabbitMQ, Prometheus, Grafana gibi tüm diğer servisler yalnızca `iklimco-net` overlay üzerinden erişilebilir.
|
||||||
|
|
||||||
## Private Network Politikasi
|
## Private Network Politikasi
|
||||||
|
|
||||||
|
|||||||
@ -79,7 +79,7 @@ Bu portlar public acilmayacak. Sadece private network veya Docker overlay icinde
|
|||||||
| `9090` | TCP | Prometheus UI/API | Admin CIDR veya private ops | Prometheus service/node | Public kapali |
|
| `9090` | TCP | Prometheus UI/API | Admin CIDR veya private ops | Prometheus service/node | Public kapali |
|
||||||
| `3000` | TCP | Grafana UI | Admin CIDR veya private ops | Grafana service/node | Public kapali |
|
| `3000` | TCP | Grafana UI | Admin CIDR veya private ops | Grafana service/node | Public kapali |
|
||||||
|
|
||||||
Mevcut `docker-stack-infra.yml` bazi servisleri host mode ile publish ediyor olabilir. Hetzner firewall public ingress'i kapatsa bile private ingress kararini bu tablo belirler.
|
`docker-stack-infra.yml` güncellenmiş olup yalnızca SWAG servisi 80/443 portlarını host mode ile yayınlar. Diğer tüm servisler published port içermez; erişim yalnızca `iklimco-net` overlay üzerinden sağlanır. Private ingress kararları için bu tablo kaynak olmaya devam eder.
|
||||||
|
|
||||||
## DB Node Portlari
|
## DB Node Portlari
|
||||||
|
|
||||||
|
|||||||
@ -6,9 +6,9 @@ Bu aşamanın amacı test ortamında Gitea Actions runner'ı (`act_runner`) syst
|
|||||||
|
|
||||||
Test ortamında maliyet ve basitlik için tek runner kullanılır:
|
Test ortamında maliyet ve basitlik için tek runner kullanılır:
|
||||||
|
|
||||||
| Host | Servis Adı | Label |
|
| Host | Servis Adı | Etiketler |
|
||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
| `iklim-app-01` | `gitea-act-runner` | `test-runner`, `iklim-app-01`, `docker` |
|
| `iklim-app-01` | `gitea-act-runner` | `ubuntu-latest`, `ubuntu-22.04`, `ubuntu-20.04`, `test-runner` |
|
||||||
|
|
||||||
## 1. Runner Kullanıcısı ve Yetkiler
|
## 1. Runner Kullanıcısı ve Yetkiler
|
||||||
|
|
||||||
@ -23,50 +23,53 @@ sudo usermod -aG docker gitea-runner
|
|||||||
|
|
||||||
## 2. act_runner Kurulumu
|
## 2. act_runner Kurulumu
|
||||||
|
|
||||||
### Binary İndirme
|
### Kurulum
|
||||||
|
|
||||||
|
Kurulum ve kayıt Ansible ile otomatik yapılır (`test-app-post-stack.yml`). Manuel kurulum gerekirse:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
wget -O act_runner https://dl.gitea.com/act_runner/0.2.10/act_runner-0.2.10-linux-amd64
|
wget -O act_runner https://dl.gitea.com/act_runner/0.2.12/act_runner-0.2.12-linux-amd64
|
||||||
sudo mv act_runner /usr/local/bin/
|
sudo mv act_runner /usr/local/bin/
|
||||||
sudo chmod +x /usr/local/bin/act_runner
|
sudo chmod +x /usr/local/bin/act_runner
|
||||||
```
|
```
|
||||||
|
|
||||||
### Kayıt (Registration)
|
### Kayıt (Registration)
|
||||||
Gitea arayüzünden (Organization -> Settings -> Actions -> Runners) bir **Registration Token** alın.
|
|
||||||
|
|
||||||
```bash
|
Gitea arayüzünden (Organization → Settings → Actions → Runners) **Registration Token** alın, vault'a ekleyin:
|
||||||
# Config dosyasını oluştur
|
|
||||||
act_runner generate-config > config.yaml
|
|
||||||
|
|
||||||
# Kayıt işlemini gerçekleştir
|
```yaml
|
||||||
act_runner register --instance https://git.tarla.io --token <TOKEN> --no-interactive
|
# group_vars/all/vault.yml
|
||||||
```
|
vault_gitea_runner_token: "<TOKEN>"
|
||||||
*Not: Kayıt sırasında label olarak `test-runner,iklim-app-01,docker` girildiğinden emin olun.*
|
|
||||||
|
|
||||||
## 3. Systemd Servisi
|
|
||||||
|
|
||||||
`/etc/systemd/system/gitea-act-runner.service` dosyasını oluşturun:
|
|
||||||
|
|
||||||
```ini
|
|
||||||
[Unit]
|
|
||||||
Description=Gitea Actions runner
|
|
||||||
After=network.target docker.service
|
|
||||||
|
|
||||||
[Service]
|
|
||||||
ExecStart=/usr/local/bin/act_runner daemon --config /etc/gitea-act-runner/config.yaml
|
|
||||||
WorkingDirectory=/var/lib/gitea-runner
|
|
||||||
User=gitea-runner
|
|
||||||
Group=gitea-runner
|
|
||||||
Restart=always
|
|
||||||
RestartSec=5
|
|
||||||
|
|
||||||
[Install]
|
|
||||||
WantedBy=multi-user.target
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Servisi başlatın:
|
|
||||||
```bash
|
```bash
|
||||||
sudo systemctl daemon-reload
|
cd Environment_Infrastructure/ansible/test
|
||||||
sudo systemctl enable --now gitea-act-runner
|
ansible-playbook test-app-post-stack.yml --vault-password-file=.vault_pass
|
||||||
|
```
|
||||||
|
|
||||||
|
## 3. Systemd Servisi ve Konfigürasyon
|
||||||
|
|
||||||
|
Ansible tarafından yönetilir. Servis dosyası `/etc/systemd/system/gitea-act-runner.service`, konfigürasyon `/etc/gitea-act-runner/config.yaml` konumundadır.
|
||||||
|
|
||||||
|
Konfigürasyonun kritik bölümleri:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
runner:
|
||||||
|
labels:
|
||||||
|
- "ubuntu-latest:docker://ubuntu:latest"
|
||||||
|
- "ubuntu-22.04:docker://ubuntu:22.04"
|
||||||
|
- "ubuntu-20.04:docker://ubuntu:20.04"
|
||||||
|
- "test-runner:docker://ubuntu:22.04"
|
||||||
|
|
||||||
|
container:
|
||||||
|
network: "iklimco-net" # DB servislerine overlay üzerinden erişim
|
||||||
|
options: "-v /var/run/docker.sock:/var/run/docker.sock" # Docker komutları için
|
||||||
|
```
|
||||||
|
|
||||||
|
Durum kontrolü:
|
||||||
|
```bash
|
||||||
|
sudo systemctl status gitea-act-runner
|
||||||
|
sudo journalctl -u gitea-act-runner -f
|
||||||
```
|
```
|
||||||
|
|
||||||
## 4. Deploy Ön Koşulları
|
## 4. Deploy Ön Koşulları
|
||||||
@ -83,13 +86,15 @@ Pipeline'ların çalışması için Gitea Organization seviyesinde şu secret'la
|
|||||||
|
|
||||||
| Secret | Açıklama |
|
| Secret | Açıklama |
|
||||||
| --- | --- |
|
| --- | --- |
|
||||||
| `STORAGEBOX_SSH_PRIV` | StorageBox'a erişim için private key |
|
| `STORAGEBOX_SSH_PRIV` | StorageBox SSH private key |
|
||||||
| `HARBOR_USERNAME` | Container registry kullanıcı adı |
|
| `STORAGEBOX_SSH_PUB` | StorageBox SSH public key |
|
||||||
| `HARBOR_PASSWORD` | Container registry şifresi |
|
| `HARBOR_CI_TOKEN` | `robot-ci-push-iklimco` robot hesabı token'ı (build + push) |
|
||||||
|
| `HARBOR_PULL_TOKEN` | `robot-swarm-pull-iklimco` robot hesabı token'ı (Swarm deploy pull) |
|
||||||
|
| `REPO_ACCESS_TOKEN` | Gitea private repo erişimi (BE-Commons vb. checkout) |
|
||||||
|
|
||||||
## Kabul Kriterleri
|
## Kabul Kriterleri
|
||||||
|
|
||||||
1. Gitea Runners sayfasında `iklim-app-01` statusü **Idle** (yeşil) görünür.
|
1. Gitea Runners sayfasında `iklim-test-app` runner'ı **Idle** (yeşil) görünür.
|
||||||
2. Bir test workflow'u (`runs-on: test-runner`) başarıyla tetiklenir.
|
2. `runs-on: test-runner` kullanan bir workflow başarıyla tetiklenir.
|
||||||
3. Runner, host üzerindeki Docker daemon'a erişip konteyner oluşturabilir.
|
3. Job container'ı Docker daemon'a ve `iklimco-net` overlay network'üne erişebilir.
|
||||||
4. `8200/tcp` (Vault) portu public internete kapalıdır.
|
4. `8200/tcp` (Vault) portu public internete kapalıdır.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user