threefoldtech / tfgrid-sdk-go

Apache License 2.0
2 stars 4 forks source link

Grid-Compose #1022

Open xmonader opened 6 months ago

xmonader commented 6 months ago

Grid-Compose

Should allow users to define and manage their own multi-vm applications in a single compose file and deploy them on threefold farms, driven by yaml spec file where you define services, networks and disks used (similar to Docker Compose).

Main Components

Verison

To Specify the grid-compose version for backward compatibility

version: '1.0.0'

Networks

networks:
  net1:
    type: 'wg'
  net2:
    type: 'mycelium'
  net3:
    type: 'yggdrasil'
  net4:
    type: 'publicip4'
  net5:
    type: 'publicip6'

Services

Where you define each service, its flists, env variables, resources, .. etc and we can also define the dependencies using e.g depends_on: list of service names

e.g

services:
  web:
    flist: 'https://hub.grid.tf/tf-official-apps/nginx-latest.flist'
    environment:
      - ENV_VAR_NAME=value
    volumes:
      - web-data:/data

    networks:
      - net1
    resources:
      cpu: 2
      memoryGB: 50.5
  database:
    flist: 'https://hub.grid.tf/tf-official-apps/postgresql-latest.flist'
    environment:
      - POSTGRES_DB=mydb
      - POSTGRES_USER=user
      - POSTGRES_PASSWORD=secret
    volumes:
      - db-data:/var/lib/postgresql/data

    networks:
      - net1
      - net2
      - net3
    resources:
      cpu: 4
      memoryGB: 2

Storage

storage:
  web-data:
    type: 'zmount'
    driver_opts:
      size: 10GB
  db-data:
    type: 'zmount'
    driver_opts:
      size: 20GB

Extra

Healthcheck

we can start with something like this for each service

    healthcheck:
      test: ['CMD', 'curl' , 'http://{myceliumip}']
      interval: 1m30s
      timeout: 10s
      retries: 3

Scaling

TBD

Secrets

It's not always environment variables, it can be injected from somewhere else, but for now I believe env vars or even env files are more than enough

Omarabdul3ziz commented 4 months ago