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

feat: replace helm with go service templates #289

Merged
merged 107 commits into from
Jul 21, 2024
Merged

Conversation

shreddedbacon
Copy link
Member

@shreddedbacon shreddedbacon commented Jan 14, 2024

This is a fairly substantial pullrequest that moves away from using helm template generation to service templates defined in go.

Most of the old helm chart logic was identical, as such the work in the PR was to try and extract all the individual changes from each of the original templates into their core components. This meant that the template logic could be consolidated down from all the individual helmcharts. The result is that there are now service types defined in code, which can be extended or modified as required, and the template generator should be able to adjust accordingly with minimal changes overall.

The benefits of this are that we now have far better coverage of changes, and which values influence the resulting templates than before with helm. If modifying one value, you can now see how this change flows through to any templates or any other service generation steps.

A big part of this change is to also remove a substantial amount of legacy bash for handling the image build process. All of the old logic for determining build contexts, targets, dockerfiles, pull through images (both from external and private registries) has been moved into go. The result is simpler bash functionality so it focuses on the important parts only (building or pushing images)

Mutliple ports

This brings additional functionality that allows multiple ports to be opened for services,
Example docker-compose with the lagoon.service.usecomposeports: true label. Adding this results in the default port for the service being disabled, and only those ports defined in the ports section of that specific service will be created.

version: '2'
services:
  custom:
    build:
      context: internal/testdata/basic/docker
      dockerfile: Dockerfile
    user: '10000'
    labels:
      lagoon.type: basic-persistent
      lagoon.persistent: /app/storage
      lagoon.service.usecomposeports: true
    volumes:
      - ./storage:/app/storage:delegated
    ports:
      - "8080"
      - "10009"

it is then possible to expose one of these services to a route in lagoon.yml file like so. The first port in the list will always be the "default" port for a service defined route, but it is possible to direct a route to a different port by extending the service name.

environments:
  main:
    routes:
      - custom:
        - example.com
      - custom-10009:
        - otherport.example.com

Note: while UDP ports can be defined, attempting to create a route to a UDP service will fail.


Note: There is additional work to consolidate the template generation that will need to be done after this pullrequest. That would be consolidating all the template generation steps down, but this would be another substantial change to the overall lagoon build structure that needs to be addressed (ie, we template ingress and services at different points of a build, with consolidation efforts, these could all be applied at the same time in one step)

There are still some other helm templates that remain that would be addressed by #115 and #287

Closes

closes #208
closes #243
closes #268

…emove unused code that the templating command replaces
Copy link
Member

@tobybellwood tobybellwood left a comment

Choose a reason for hiding this comment

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

I've been through this A LOT - and it looks like it's pretty spot-on to the current configuration. Ok for this to merge and head out the door 🥳

@shreddedbacon shreddedbacon marked this pull request as ready for review July 17, 2024 22:14
@tobybellwood tobybellwood merged commit 5859bae into main Jul 21, 2024
2 checks passed
@tobybellwood tobybellwood deleted the service-templates branch July 21, 2024 22:53
@tobybellwood tobybellwood restored the service-templates branch July 22, 2024 08:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants