Guida - 5 min

Archestack su Kubernetes, la via breve

La via più breve per arrivare su un cluster che gestisci già: Archestack sotto un percorso di un hostname che il suo ingress serve già, per esempio https://apps.example.com/archestack/. Cinque file manifest e una pipeline, niente Helm, e anche PostgreSQL gira nel cluster.

Vuoi hostname tutti suoi, un database gestito e più repliche dell'API? Hosting su AKS è la versione completa.

Cosa gira

https://apps.example.com
  /archestack/api, /archestack/hubs  ->  archestack-api       1 pod, with disks for files and backups
  /archestack/...                    ->  archestack-web       2 pods: the builder and the published app
  /archestack-grafana/               ->  archestack-grafana   optional, with Prometheus, Tempo and Loki

archestack-api  ->  archestack-postgres   PostgreSQL 16 on a disk of its own

Il builder è su /archestack/, l'app pubblicata su /archestack/app/, e l'API allo stesso indirizzo, quindi non c'è un secondo hostname da configurare.

Cosa ti serve

  • Un cluster con ingress-nginx e un hostname che serve già in HTTPS.
  • Un namespace archestack e una storage class che fornisce dischi, come fa quella predefinita di AKS.
  • Azure DevOps, GitHub o GitLab. Un cluster privato ha bisogno di un runner all'interno della sua rete, perché i runner ospitati lo raggiungono da internet.

Configurarlo

  1. Estrai il kit nel tuo repository come archestack/.
  2. Crea nel tuo sistema CI un ambiente archestack-dev che contenga queste cinque, le ultime tre come segreti:
    HOST                apps.example.com
    ADMIN_EMAIL         you@example.com
    POSTGRES_PASSWORD   secret, set once and never changed
    ADMIN_PASSWORD      secret, the first admin's password
    GRAFANA_PASSWORD    secret, Grafana's user admin
  3. Collega la pipeline, come dice la sezione del tuo sistema CI qui sotto.
  4. Eseguila. Il primo avvio richiede qualche minuto, mentre l'API crea i suoi database. Poi accedi su https://<HOST>/archestack/ con l'email e la password dell'admin.
Il tuo sistema CI

Azure DevOps

  • Aggiungi archestack/azure-pipelines.yml come pipeline.
  • In Pipelines, Environments, crea archestack-dev con il namespace archestack del cluster come risorsa Kubernetes.
  • In Pipelines, Library, crea un gruppo di variabili con lo stesso nome che contenga le cinque.

GitHub Actions

  • Sposta archestack/github-actions.yml in .github/workflows/archestack.yml.
  • In Settings, Environments, crea archestack-dev: HOST e ADMIN_EMAIL come variabili, le password come segreti, più il segreto KUBECONFIG (vedi qui sotto).

GitLab CI

  • Includi il file del kit dal tuo .gitlab-ci.yml:
    include:
      - local: archestack/gitlab-ci.yml
  • In Settings, CI/CD, Variables, aggiungi le cinque limitate a archestack-dev, con le password mascherate e tutte protette, più KUBECONFIG di tipo File (vedi qui sotto).

Accedere al cluster

Esegui bash archestack/kubeconfig.sh una volta, come qualcuno che può creare ruoli nel namespace, e salva ciò che stampa come KUBECONFIG. È un service account che può entrare nel namespace archestack e in nient'altro. Non usare mai il tuo kubeconfig: porta con sé i tuoi diritti sull'intero cluster.

I file

archestack/
  azure-pipelines.yml     Azure DevOps: fills in the manifests, makes the secret, deploys
  github-actions.yml      GitHub Actions: move it to .github/workflows/archestack.yml
  gitlab-ci.yml           GitLab CI: include it from the repository's .gitlab-ci.yml
  deploy.sh               what GitHub Actions and GitLab CI run: the same three steps
  images.sh               pins both images to the digest of the tag you deploy
  kubeconfig.sh           their sign-in, allowed into the archestack namespace only
  manifests/
    postgres.yml          PostgreSQL 16 with a 32 GB disk
    api.yml               the API, with disks for files (20 GB) and backups (50 GB)
    web.yml               the builder and the published app
    ingress.yml           /archestack on the hostname the cluster already serves
    observability.yml     optional: Grafana with Prometheus, Tempo and Loki

ingress.yml è l'unico file che potrebbe dover cambiare per il tuo cluster. Lascialo senza riscrittura (Archestack si aspetta il prefisso /archestack) e senza un proxy di accesso davanti: Archestack fa accedere le persone da solo.

Aggiornare

Esegui di nuovo la pipeline. latest prende la release più recente, una versione come 1.4.37 dice esattamente cosa gira, ed è il modo per portare una versione dal test alla produzione. In entrambi i casi la pipeline fissa le due immagini al loro digest, così ogni pod esegue esattamente l'immagine che è stata rilasciata. L'API non è disponibile per il minuto che impiega a riavviarsi; i tuoi dati restano sui suoi dischi. Ogni versione e i suoi digest sono in Release.

Da sapere

  • La password del database si imposta una volta sola. PostgreSQL tiene quella con cui si è avviato la prima volta, quindi cambiarla dopo nel sistema CI lascia l'API fuori.
  • La password dell'admin crea solo il primo admin. Dopo cambiala in Archestack.
  • I backup restano nel cluster. Copiali anche da un'altra parte.
  • Tornare a una versione più vecchia può fallire una volta che una più nuova ha migrato il database. Prova prima un aggiornamento su un ambiente di test.

Dove andare dopo

Il deploy dal repository porta le tue applicazioni da git a questi ambienti.