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

Advanced templating for helm values #195

Open
BacLuc opened this issue May 22, 2023 · 0 comments
Open

Advanced templating for helm values #195

BacLuc opened this issue May 22, 2023 · 0 comments

Comments

@BacLuc
Copy link
Owner

BacLuc commented May 22, 2023

With the current way of setting helm values via command line we have 2 issues:

  1. If the deploy script references an env variable, it may be difficult to not overwrite the value and use the default from values.yaml
  2. Passing a cron like schedule is difficult because of globbing.

Possible Solutions:

  1. Use a lot of shell if statements (does not solve Problem 1)

  2. Use a more powerful templating method:

    1. The deployment github actions just set the env variables they want to set, and then we template a second values file and deploy with that
      values template (here php, we could use any other template engine)
    <? /** @noinspection PhpShortOpenTagInspection */ ?>
    <? if (getenv('IMAGE_TAG')) {?>
    imageTag: "<?=getenv('IMAGE_TAG')?>"
    <?php } ?>
    autoscaling:
      <? if (getenv('AUTOSCALING_ENABLED')) {?>
      enabled: <?=getenv('AUTOSCALING_ENABLED')?>
      <?php } ?>
      minReplicas: 1
      maxReplicas: 5
      targetCPUUtilizationPercentage: 80
      # targetMemoryUtilizationPercentage: 80

    And then in the action:

     env:
       IMAGE_TAG: ${{ inputs.sha }}
       DOMAIN: ${{ inputs.name }}.${{ vars.DOMAIN }}
     run: |
        env > /tmp/.env
        docker run --rm --env-file /tmp/.env -v $(pwd)/.helm/deploy-values.yaml.php:/values.yaml.php php -f /values.yaml.php > deploy-values.yaml
        helm upgrade --install ecamp3-${{ inputs.name }} .  -f deploy-values.yaml
       ....
@BacLuc BacLuc changed the title test Advanced templating for helm values May 22, 2023
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

No branches or pull requests

1 participant