service-resources-v1.j2 882 B

12345678910111213141516171819202122232425262728
  1. {#
  2. Archetype: service-resources-v1
  3. Description:
  4. Resource limits (CPU/memory) for production deployments (schema 1.2+).
  5. Approach:
  6. - Standalone mode: Uses deploy.resources (Compose spec v3+)
  7. - Swarm mode: Includes reservations for resource guarantees
  8. - CPU limits specified as decimal (0.5, 1.0, 2.0)
  9. - Memory limits with units (512M, 1G, 2G)
  10. Usage:
  11. Use for production services that need resource constraints.
  12. Prevents resource exhaustion and enables better capacity planning.
  13. #}
  14. {% if resources_enabled %}
  15. deploy:
  16. resources:
  17. limits:
  18. cpus: '{{ resources_cpu_limit }}'
  19. memory: {{ resources_memory_limit }}
  20. {% if swarm_enabled %}
  21. reservations:
  22. cpus: '{{ resources_cpu_reservation }}'
  23. memory: {{ resources_memory_reservation }}
  24. {% endif %}
  25. {% endif %}