Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow specifying resource requirements in docker-compose service labels #1

Conversation

MaxCWhitehead
Copy link
Collaborator

Goals / Usage:

  • Be able to define default resource requirements per service
  • Be able to override these per env
  • Primary usage is configuring for nginx-php services (nginx + php containers in shared pod, should support linked services)

Specified as service labels in lagoon project yml:

  php:
    labels:
      lagoon.type: nginx-php-persistent
      lagoon.name: nginx-php
      
      # Set default resources for php service
      lagoon.resources.requests.cpu: 20m
      lagoon.resources.limits.cpu: 200m
      
      # Override on main branch
      lagoon.resources.override-branch.main.requests.cpu: 400m
      lagoon.resources.override-branch.main.limits.cpu: 400m

Changes:

  • Update Resources type to contain memory/cpu resources/requests
  • Add Resources to ServiceValues (BuildValues templating input now may store resources per service)
  • Update composeToServiceValues to read service labels to set resources in ServiceValues
    • Prioritizes branch overrides, then uses label for service if specified
  • Update GenerateDeploymentTemplate To override resource requirements on container spec if present in ServicValues

Tests added

The tests are a bit rough and possibly hard to grok (copy and pasted from similar and tweaked to test this functionality. But what I tried to cover:

  • Ensuring that original default ServiceType resource values are used if not overridden
  • ServiceValue.Resources overrides BuildValues.Resources (if overrides are set)
  • Testing compose labels are plumbed into ServiceValues correctly
    • Testing that branch override service labels override default resource labels in docker-compose
  • Testing resources templated correctly in deployment manifest from BuildValues/ServiceValues

Copy link
Member

@gchaix gchaix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's build it and give it a spin!

@MaxCWhitehead MaxCWhitehead merged commit 7628242 into tag1consulting:tag1-main Oct 1, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants