Skip to Content

Volumes, backups and cron jobs

Persistent volumes, sharing them between apps, backups and scheduled jobs.

The examples on this page share one project, shop, which also manages a bucket for its backups.

projects/shop/project.yaml
# yaml-language-server: $schema=https://a-line.cloud/schemas/iac/v1.json
version: 1
name: shop
cluster: hetzner-fsn1
buckets:
  - name: shop-backups
    quota_gb: 100
clusters/hetzner-fsn1.yaml
# yaml-language-server: $schema=https://a-line.cloud/schemas/iac/v1.json
version: 1
provider: hetzner
region: fsn1
pools:
  - name: control-plane
    role: control_plane
  - name: general

Volumes

projects/shop/apps/media.yaml
# yaml-language-server: $schema=https://a-line.cloud/schemas/iac/v1.json
version: 1
source:
  image: ghcr.io/example/media:1.0.0
port: 8080
volumes:
  - name: uploads
    mount_path: /data/uploads
    size: 20Gi
    access_mode: ReadWriteMany
    auto_expand:
      threshold_percent: 80
      increment_gb: 10
      max_size_gb: 200
backup_policies:
  - name: nightly-uploads
    source:
      volume: uploads
    schedule: "0 3 * * *"
    retention_count: 14
    targets:
      - bucket: shop-backups
        primary: true
Volume keyMeaning
name, mount_pathThe volume's name and where it is mounted.
sizeThe size, such as 10Gi.
access_modeReadWriteOnce (the default) for a volume used by one node, or ReadWriteMany to share it.
auto_expandGrow the volume when its usage reaches threshold_percent (default 80), by increment_gb (default 5), up to max_size_gb.
read_onlyMount the volume read-only.
storage_classlonghorn or lvm-localpath; left out, the cluster default. A ReadWriteMany volume can't use lvm-localpath.
replicasHow many copies Longhorn keeps, 1 to 3. Only with storage_class: longhorn, at most the node count of the cluster's largest Longhorn pool, and fixed once the volume exists (volume_immutable_field).

See VolumeSpec for every key.

Sharing a volume

volume_mounts mounts another app's volume, read-only. from is <app>/<volume>, and the volume must be ReadWriteMany.

projects/shop/apps/thumbnails.yaml
# yaml-language-server: $schema=https://a-line.cloud/schemas/iac/v1.json
version: 1
source:
  image: ghcr.io/example/thumbnails:1.0.0
volume_mounts:
  - from: media/uploads
    mount_path: /data/uploads

Backups

backup_policies backs up a volume (source: {volume: <name>}) or a database app's data (source: database) to one or more buckets.

Policy keyDefault
schedule0 2 * * * (a cron expression)
retention_count, retention_days7 and 7
backup_typefull
compressiongzip
enabledtrue

A target bucket must be managed by the same link, or be granted to it. strategy names a backup strategy of your organization, also by grant.

A database template app also takes a simpler backup block, with enabled, schedule, retention_days and compression:

projects/shop/apps/db.yaml
# yaml-language-server: $schema=https://a-line.cloud/schemas/iac/v1.json
version: 1
source:
  template: postgres
  version: "16"
backup:
  enabled: true
  schedule: "0 2 * * *"
  retention_days: 14

Backups are never deleted with their app. See BackupPolicySpec.

Cron jobs

projects/shop/apps/reports.yaml
# yaml-language-server: $schema=https://a-line.cloud/schemas/iac/v1.json
version: 1
source:
  image: ghcr.io/example/reports:1.0.0
cron_jobs:
  - name: daily-report
    schedule: "30 6 * * *"
    timezone: Europe/Amsterdam
    command: ["/app/report", "--daily"]
    memory_limit: 1Gi

A cron job runs the app's image (or image_override) on a cron schedule.

KeyDefault
timezoneUTC
concurrency_policyForbid
cpu_limit, memory_limit500m and 512Mi
successful_jobs_history, failed_jobs_history3
suspendedfalse

See CronJobSpec.

Bucket access

storage_bindings gives the app credentials for a bucket as environment variables. The bucket must be managed by the same link, or be granted to it.

projects/shop/apps/exporter.yaml
# yaml-language-server: $schema=https://a-line.cloud/schemas/iac/v1.json
version: 1
source:
  image: ghcr.io/example/exporter:1.0.0
storage_bindings:
  - bucket: shop-backups
    permission: write_only
    key_prefix: media/
    env_prefix: BACKUP
    credential_mode: per_pod
KeyMeaning
bucketThe bucket's name.
permissionread_write (the default), read_only or write_only.
key_prefixLimit access to object keys under this prefix.
env_prefixPrefix of the variable names, default S3. Upper-case letters, digits and _, starting with a letter, at most 32 characters.
credential_modestatic (the default) or per_pod, see below.
credential_modeCredentials
staticOne key shared by every pod of the app.
per_podEach pod gets its own key through a dynamic secret lease. The key is revoked when the lease ends, when the binding is removed and when the app is deleted.

write_only, key_prefix and per_pod need the A-Line S3 gateway. A platform that serves S3 in direct mode refuses them, and an external storage needs Route through A-Line gateway turned on for per_pod.

See StorageBindingSpec.

On this page