Environment_Infrastructure/setup/05-test-runner-ve-deploy-onkosullari.md
Murat ÖZDEMİR 5fe57ee108 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.
2026-05-12 19:49:24 +03:00

101 lines
3.2 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 05 - Test Runner ve Deploy Ön Koşulları
Bu aşamanın amacı test ortamında Gitea Actions runner'ı (`act_runner`) systemd servisi olarak kurmak ve CI/CD pipeline'larının çalışabileceği ortamı hazırlamaktır.
## Runner Yerleşimi
Test ortamında maliyet ve basitlik için tek runner kullanılır:
| Host | Servis Adı | Etiketler |
| --- | --- | --- |
| `iklim-app-01` | `gitea-act-runner` | `ubuntu-latest`, `ubuntu-22.04`, `ubuntu-20.04`, `test-runner` |
## 1. Runner Kullanıcısı ve Yetkiler
Runner, host üzerinde Docker komutlarını çalıştırabilmelidir.
```bash
# Kullanıcıyı oluştur
sudo useradd -m -s /bin/bash gitea-runner
# Docker grubuna ekle
sudo usermod -aG docker gitea-runner
```
## 2. act_runner Kurulumu
### Kurulum
Kurulum ve kayıt Ansible ile otomatik yapılır (`test-app-post-stack.yml`). Manuel kurulum gerekirse:
```bash
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 chmod +x /usr/local/bin/act_runner
```
### Kayıt (Registration)
Gitea arayüzünden (Organization → Settings → Actions → Runners) **Registration Token** alın, vault'a ekleyin:
```yaml
# group_vars/all/vault.yml
vault_gitea_runner_token: "<TOKEN>"
```
```bash
cd Environment_Infrastructure/ansible/test
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ı
Pipeline'ın `iklim-app-01` üzerinde başarılı deploy yapabilmesi için şu araçların kurulu olması şarttır:
- `docker-ce` ve `docker-compose-plugin`
- `gettext` (`envsubst` komutu için)
- `jq`
- `git`
## 5. Gitea Organization Secrets
Pipeline'ların çalışması için Gitea Organization seviyesinde şu secret'lar tanımlanmalıdır:
| Secret | Açıklama |
| --- | --- |
| `STORAGEBOX_SSH_PRIV` | StorageBox SSH private key |
| `STORAGEBOX_SSH_PUB` | StorageBox SSH public key |
| `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
1. Gitea Runners sayfasında `iklim-test-app` runner'ı **Idle** (yeşil) görünür.
2. `runs-on: test-runner` kullanan bir workflow başarıyla tetiklenir.
3. Job container'ı Docker daemon'a ve `iklimco-net` overlay network'üne erişebilir.
4. `8200/tcp` (Vault) portu public internete kapalıdır.