- timeout-minutes sul job di tutti e 16 i workflow riusabili: 10 per branch-cleanup, 15-20 per release e manutenzione, 30 per i quality gates e le pubblicazioni, 45 per le immagini Docker, 60 per la build Android - timeout-minutes su 95 passi che dipendono dalla rete (checkout, setup-*, cache, install, audit, login, push, upload): con il solo timeout sul job il log non dice quale passo si è impiantato, con questi sì - valori letterali e non input: su un job che chiama un workflow riusabile timeout-minutes non è una chiave ammessa, quindi il limite può stare solo qui, e i valori scelti sono già ampi rispetto alla durata reale dei job Fixes #23 @1h30m
139 lines
5.1 KiB
YAML
139 lines
5.1 KiB
YAML
# Generazione dei manifesti Kubernetes di un microservizio, pubblicati come
|
|
# artifact della run.
|
|
#
|
|
# Nasce da sedici copie dello stesso file nei repo backend/node-*, identiche in
|
|
# ogni parametro e divergenti solo sulla versione del generatore (v0.6, v0.9,
|
|
# v0.10, v0.13 in circolazione contemporaneamente) e su `verbose`.
|
|
#
|
|
# `verbose` non e' un input, ed e' il motivo principale per cui questo workflow
|
|
# esiste: con verbose attivo il generatore scrive nel log la configurazione,
|
|
# credenziali comprese (k8s-yaml-generator#30). La correzione era stata applicata
|
|
# a un repository su sedici; gli altri quindici continuavano a pubblicare i
|
|
# segreti nei log a ogni tag. Qui la scelta sicura non e' piu' derogabile, e per
|
|
# ispezionare la configurazione si esegue il generatore in locale.
|
|
#
|
|
# Il generatore era l'ultima action esterna del portale: referenziata senza
|
|
# prefisso di host si risolveva sul DEFAULT_ACTIONS_URL del runner. Ora e'
|
|
# mirrorata in actions/k8s-yaml-generator e il riferimento e' esplicito.
|
|
|
|
name: Generate K8s YAML
|
|
|
|
on:
|
|
workflow_call:
|
|
inputs:
|
|
generator-version:
|
|
description: 'Tag del mirror actions/k8s-yaml-generator. Si aggiorna qui, una volta per tutti.'
|
|
type: string
|
|
default: 'v0.13'
|
|
instance:
|
|
type: string
|
|
default: ''
|
|
env-name:
|
|
description: 'File di environment da cui il generatore legge la configurazione.'
|
|
type: string
|
|
default: '.env.default'
|
|
namespace:
|
|
type: string
|
|
default: 'postgres-database'
|
|
service-type:
|
|
type: string
|
|
default: 'ClusterIP'
|
|
target-port:
|
|
type: string
|
|
default: '8080'
|
|
replicas:
|
|
type: string
|
|
default: '1'
|
|
min-replicas:
|
|
type: string
|
|
default: '1'
|
|
max-replicas:
|
|
type: string
|
|
default: '5'
|
|
target-cpu-utilization:
|
|
type: string
|
|
default: '75'
|
|
cpu-request:
|
|
type: string
|
|
default: '500m'
|
|
memory-request:
|
|
type: string
|
|
default: '512Mi'
|
|
cpu-limit:
|
|
type: string
|
|
default: '1000m'
|
|
memory-limit:
|
|
type: string
|
|
default: '1024Mi'
|
|
pvc-size:
|
|
type: string
|
|
default: '10Mi'
|
|
registry:
|
|
type: string
|
|
default: 'gitea.pzetatouch.it'
|
|
owner:
|
|
type: string
|
|
default: 'pzeta_touch'
|
|
image-pull-secrets-name:
|
|
type: string
|
|
default: 'regcred'
|
|
directory-path:
|
|
description: 'Cartella in cui il generatore scrive i manifesti, poi caricata come artifact.'
|
|
type: string
|
|
default: 'k8s'
|
|
path:
|
|
description: 'Radice da cui il generatore legge il progetto.'
|
|
type: string
|
|
default: './'
|
|
artifact-name:
|
|
type: string
|
|
default: 'K8s_Yaml'
|
|
|
|
jobs:
|
|
generate-yaml:
|
|
runs-on: ubuntu-latest
|
|
# Il chiamante non puo' dichiararlo: su un job che usa un workflow
|
|
# riusabile timeout-minutes non e' una chiave ammessa (devops/shared-actions#23).
|
|
timeout-minutes: 15
|
|
steps:
|
|
- name: Checkout
|
|
timeout-minutes: 10
|
|
uses: https://gitea.pzetatouch.it/actions/checkout@v7
|
|
|
|
- name: Generate K8s YAML
|
|
timeout-minutes: 10
|
|
uses: https://gitea.pzetatouch.it/actions/k8s-yaml-generator@${{ inputs.generator-version || 'v0.13' }}
|
|
with:
|
|
instance: ${{ inputs.instance }}
|
|
envName: ${{ inputs.env-name || '.env.default' }}
|
|
namespace: ${{ inputs.namespace || 'postgres-database' }}
|
|
serviceType: ${{ inputs.service-type || 'ClusterIP' }}
|
|
targetPort: ${{ inputs.target-port || '8080' }}
|
|
replicas: ${{ inputs.replicas || '1' }}
|
|
registry: ${{ inputs.registry || 'gitea.pzetatouch.it' }}
|
|
owner: ${{ inputs.owner || 'pzeta_touch' }}
|
|
minReplicas: ${{ inputs.min-replicas || '1' }}
|
|
maxReplicas: ${{ inputs.max-replicas || '5' }}
|
|
cpuRequest: ${{ inputs.cpu-request || '500m' }}
|
|
memoryRequest: ${{ inputs.memory-request || '512Mi' }}
|
|
cpuLimit: ${{ inputs.cpu-limit || '1000m' }}
|
|
memoryLimit: ${{ inputs.memory-limit || '1024Mi' }}
|
|
targetCPUUtilizationPercentage: ${{ inputs.target-cpu-utilization || '75' }}
|
|
directoryPath: ${{ inputs.directory-path || 'k8s' }}
|
|
imagePullSecretsName: ${{ inputs.image-pull-secrets-name || 'regcred' }}
|
|
# Vedi l'intestazione: con verbose il generatore stampa le credenziali.
|
|
verbose: 'false'
|
|
path: ${{ inputs.path || './' }}
|
|
pvcSize: ${{ inputs.pvc-size || '10Mi' }}
|
|
|
|
- name: Upload Artifact
|
|
timeout-minutes: 10
|
|
# v3 e non v5: la v5 che avevano i chiamanti non e' mai stata provata su
|
|
# questo runner, e questo workflow parte solo su un tag a*, cioe' al
|
|
# rilascio. Le v4+ usano l'API artifact nuova; su Gitea 1.27.3 c'e', ma
|
|
# va verificata con un tag usa e getta prima di metterla qui (#28).
|
|
uses: https://gitea.pzetatouch.it/actions/upload-artifact@v3
|
|
with:
|
|
name: ${{ inputs.artifact-name || 'K8s_Yaml' }}
|
|
path: ${{ inputs.directory-path || 'k8s' }}/
|