Skip to content
For the complete documentation index, see llms.txt. This page is also available as Markdown.

Best practices

Design secure, reusable, and maintainable projections for DataOS workloads.

Use these practices to keep projections secure, readable, and predictable across environments.

Keep secrets out of resource files

  • Store credentials and tokens in Secrets.

  • Reference secret values in projections.

  • Avoid plain text values in templates.

projection:
  secrets:
    - id: "postgres-credentials"
      contextAlias: "db"
  projections:
    envVars:
      - key: "DATABASE_URL"
        template: "postgresql://{{ secrets['db'].username | base64_decode }}:{{ secrets['db'].password | base64_decode }}@{{ secrets['db'].host | base64_decode }}:{{ secrets['db'].port | base64_decode }}/{{ secrets['db'].database | base64_decode }}"

Use clear aliases

Use short, meaningful contextAlias values.

Good aliases make templates easier to read and debug.

projection:
  secrets:
    - id: "api-credentials"
      contextAlias: "api"
  depots:
    - name: "sales-warehouse"
      contextAlias: "warehouse"

Pick the right template engine

  • Use liquid (the default) for anything that reads secrets, depots, or runtime context.

  • Use none for static values.

  • Always put the content in template. There is no value field.

Match the syntax to the selected engine.

Put the projection at the right level

  • Use a stack-level projection for values every job, Service, or Worker on that stack needs.

  • Use spec.use.projection for values one workload needs. If both levels set the same environment variable, the workload value wins.

  • In a Workflow, put use.projection under each step (spec.dag[].spec.use.projection). A projection under the Workflow's top-level spec is silently dropped, and steps do not inherit projections from each other.

Keep generated output focused

Project only the values your workload needs.

Too many inputs make templates harder to test and maintain.

  • Limit referenced Secrets and Depots.

  • Generate only required files and variables.

  • Split unrelated concerns into separate templates.

Use reserved paths carefully

Avoid writing files into reserved DataOS paths unless the runtime expects them.

Reserved paths include:

  • /etc/dataos/config

  • /etc/dataos/secret

  • /etc/dataos/work

Use explicit custom directories for app-specific files.

Add defaults for optional values

Use defaults when values may be missing across environments.

This keeps templates portable.

Test before deployment

Validate projection logic locally before attaching it to a workload.

  1. Test the template with dataos develop use.

  2. Validate the full resource with dataos develop resource.

  3. Review generated output before deployment.

Avoid leaking sensitive output

  • Do not print rendered secrets in logs.

  • Do not expose generated config files in debug output.

  • Restrict depot secret access with specific secretPurposes.

Keep templates reusable

Design templates so the same resource works across tenants and environments.

  • Use runtime context instead of hardcoded tenant values.

  • Prefer aliases over repeated object paths.

  • Keep static strings outside templated expressions when possible.

Review generated arguments and files together

Arguments, files, and environment variables should agree on paths and values.

Misaligned output causes runtime errors that are hard to trace.

Last updated

Was this helpful?