Demo / hello (push) Successful in 16s
The runner's built-in cache server now backs actions/cache. - In the cluster, cache blobs go on a new PVC (gitea-actions-cache, 20Gi, default storage class) mounted at /cache in the runner container, so the cache survives runner restarts. The role creates the PVC before the Helm release. NFS doesn't enforce the size; the runner's own expiry (unused 7 days, or older than 30 days) keeps it bounded. - Fixed port 8088. Job containers reach it at the pod IP, which DinD's per-job networks route to because DinD shares the pod's network. - The dedicated-host runner gets the same config, with the cache on a bind mount under gitea_actions_host_dir. - gitea_actions_cache_enabled: false turns it all off again. Refs DevOps/software-infrastructure#56 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
172 lines
6.5 KiB
YAML
172 lines
6.5 KiB
YAML
---
|
|
# Deploys an instance-wide Gitea Actions runner (act_runner + DinD).
|
|
- name: check for existing runner registration token secret
|
|
kubernetes.core.k8s_info:
|
|
kind: Secret
|
|
namespace: gitea
|
|
name: "{{ gitea_actions_runner_token_secret }}"
|
|
register: runner_token_secret
|
|
|
|
- name: generate and store a runner registration token
|
|
when: runner_token_secret.resources | length == 0
|
|
block:
|
|
# Poll instead of `kubectl rollout status`, which exits immediately once
|
|
# a slow rollout has passed the deployment's progressDeadlineSeconds.
|
|
- name: wait for the gitea deployment to finish rolling out
|
|
command: >-
|
|
kubectl -n gitea get deployment gitea
|
|
-o jsonpath={.spec.replicas},{.status.replicas},{.status.updatedReplicas},{.status.availableReplicas}
|
|
register: gitea_rollout
|
|
until: gitea_rollout.stdout.split(',') | unique | length == 1
|
|
retries: 90
|
|
delay: 10
|
|
changed_when: false
|
|
|
|
- name: generate instance-level runner registration token
|
|
command: kubectl -n gitea exec deployment/gitea -c gitea -- gitea actions generate-runner-token
|
|
register: runner_token
|
|
retries: 10
|
|
delay: 15
|
|
until: runner_token.rc == 0 and (runner_token.stdout | trim | length) > 0
|
|
changed_when: false
|
|
no_log: true
|
|
|
|
- name: store runner registration token
|
|
kubernetes.core.k8s:
|
|
state: present
|
|
definition:
|
|
apiVersion: v1
|
|
kind: Secret
|
|
metadata:
|
|
name: "{{ gitea_actions_runner_token_secret }}"
|
|
namespace: gitea
|
|
type: Opaque
|
|
stringData:
|
|
token: "{{ runner_token.stdout | trim }}"
|
|
no_log: true
|
|
|
|
- name: find the node labeled for the runner
|
|
kubernetes.core.k8s_info:
|
|
kind: Node
|
|
label_selectors: "{{ gitea_actions_runner_node_selector.items() | map('join', '=') | list }}"
|
|
register: runner_nodes
|
|
|
|
- name: require a node labeled for the runner
|
|
ansible.builtin.assert:
|
|
that: runner_nodes.resources | length > 0
|
|
fail_msg: >-
|
|
No node matches {{ gitea_actions_runner_node_selector }}. Label a node
|
|
with enough local disk for Docker-in-Docker, for example
|
|
`kubectl label node <node> eom.dev/ci-runner=true`, then rerun with
|
|
--tags actions.
|
|
quiet: true
|
|
|
|
- name: create the actions cache volume
|
|
when: gitea_actions_cache_enabled | bool
|
|
kubernetes.core.k8s:
|
|
state: present
|
|
definition:
|
|
apiVersion: v1
|
|
kind: PersistentVolumeClaim
|
|
metadata:
|
|
name: "{{ gitea_actions_cache_pvc }}"
|
|
namespace: gitea
|
|
spec:
|
|
accessModes: ["ReadWriteOnce"]
|
|
resources:
|
|
requests:
|
|
storage: "{{ gitea_actions_cache_size }}"
|
|
|
|
- name: deploy gitea actions runner
|
|
kubernetes.core.helm:
|
|
name: gitea-actions
|
|
chart_ref: gitea/actions
|
|
chart_version: "{{ gitea_actions_chart_version }}"
|
|
release_namespace: gitea
|
|
create_namespace: true
|
|
values:
|
|
enabled: true
|
|
giteaRootURL: https://gitea.eom.dev
|
|
existingSecret: "{{ gitea_actions_runner_token_secret }}"
|
|
existingSecretKey: token
|
|
# Native sidecar after DinD: starts once Docker's socket is up and stops
|
|
# before it. See gitea_actions_prune_* in defaults for what it removes.
|
|
postExtraInitContainers:
|
|
- name: docker-prune
|
|
image: "{{ gitea_actions_prune_image }}"
|
|
restartPolicy: Always
|
|
command: ["/bin/sh", "-c", "{{ lookup('ansible.builtin.file', 'docker-prune.sh') }}"]
|
|
env:
|
|
- name: DOCKER_HOST
|
|
value: unix:///run/dind/docker.sock
|
|
- name: PRUNE_INTERVAL_SECONDS
|
|
value: "{{ gitea_actions_prune_interval_seconds | string }}"
|
|
- name: PRUNE_MAX_AGE_MINUTES
|
|
value: "{{ gitea_actions_prune_max_age_minutes | string }}"
|
|
- name: PRUNE_IMAGES_ABOVE_GB
|
|
value: "{{ gitea_actions_prune_images_above_gb | string }}"
|
|
- name: PRUNE_KEEP_IMAGES
|
|
value: "{{ gitea_actions_prune_keep_images | join(' ') }}"
|
|
resources:
|
|
requests:
|
|
cpu: 10m
|
|
memory: 32Mi
|
|
limits:
|
|
cpu: 200m
|
|
memory: 128Mi
|
|
volumeMounts:
|
|
- name: docker-socket
|
|
mountPath: /run/dind
|
|
statefulset:
|
|
replicas: "{{ gitea_actions_runner_replicas }}"
|
|
persistence:
|
|
size: 1Gi
|
|
# Chart 0.1.2 renders nodeSelector correctly for one key only.
|
|
nodeSelector: "{{ gitea_actions_runner_node_selector }}"
|
|
extraVolumes: >-
|
|
{{ [{'name': 'docker-data',
|
|
'emptyDir': {'sizeLimit': gitea_actions_docker_data_size}}]
|
|
+ ([{'name': 'actions-cache',
|
|
'persistentVolumeClaim': {'claimName': gitea_actions_cache_pvc}}]
|
|
if gitea_actions_cache_enabled | bool else []) }}
|
|
dind:
|
|
extraVolumeMounts:
|
|
- name: docker-data
|
|
mountPath: /var/lib/docker
|
|
resources:
|
|
requests:
|
|
cpu: "{{ gitea_actions_dind_cpu_request }}"
|
|
memory: "{{ gitea_actions_dind_memory_request }}"
|
|
ephemeral-storage: "{{ gitea_actions_dind_ephemeral_request }}"
|
|
limits:
|
|
cpu: "{{ gitea_actions_dind_cpu_limit }}"
|
|
memory: "{{ gitea_actions_dind_memory_limit }}"
|
|
ephemeral-storage: "{{ gitea_actions_dind_ephemeral_limit }}"
|
|
runner:
|
|
resources: "{{ gitea_actions_runner_resources }}"
|
|
extraVolumeMounts: >-
|
|
{{ [{'name': 'actions-cache', 'mountPath': gitea_actions_cache_dir}]
|
|
if gitea_actions_cache_enabled | bool else [] }}
|
|
config: |
|
|
log:
|
|
level: info
|
|
cache:
|
|
enabled: {{ gitea_actions_cache_enabled | bool | lower }}
|
|
dir: {{ gitea_actions_cache_dir }}
|
|
port: {{ gitea_actions_cache_port }}
|
|
container:
|
|
require_docker: true
|
|
docker_timeout: 300s
|
|
# Use the cached job image; the labels below pin its version.
|
|
force_pull: false
|
|
runner:
|
|
capacity: {{ gitea_actions_runner_capacity }}
|
|
timeout: {{ gitea_actions_runner_job_timeout }}
|
|
shutdown_timeout: {{ gitea_actions_runner_shutdown_timeout }}
|
|
report_close_timeout: {{ gitea_actions_runner_report_close_timeout }}
|
|
fetch_timeout: {{ gitea_actions_runner_fetch_timeout }}
|
|
labels:
|
|
{% for label in gitea_actions_runner_labels %}
|
|
- "{{ label }}"
|
|
{% endfor %}
|