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

deployment path as local dir #545

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

epcim
Copy link
Contributor

@epcim epcim commented Jun 5, 2023

Description

Allow this on deployment.yml so the folder with code can be referenced either as include while allowing additional processing). I use this for shared artefacts.

In one folder to have:

deployment.yml

deployments:
- path: .
  vars:
   - file: context-{{ global.clusterName }}.yml
     ignoreMissing: true
     noOverride: true
   - file: context.yml
     ignoreMissing: true                        
     noOverride: true

kustomization.yml

resource:
- someInterpolatedManifestsWithDefaultValues.yml

The future improvements could be to translate "." to actual folder (include path name). I wanted to have this MR simple as possible, so avoided for now.

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update
  • This change requires a new example

I count to post some examples with the deployment later to example repo. Does not need dedicated documentation change. IMO.

@codablock
Copy link
Collaborator

I'm trying to understand your initial requirement here. What do you mean with "additional" processing?

@epcim
Copy link
Contributor Author

epcim commented Jun 12, 2023

I'm trying to understand your initial requirement here. What do you mean with "additional" processing?

In the example (additional processing) means I do load some vars files.

Regarding patch: Understand today, the deployment.yml must be one folder above the kustomization.yml code (they can't co-exist in the same folder).

I will post some example this week. Assume I have some "shared" folder ("to/some") with generic service deployment that I will refer from some deployment.yml. As it's shared and might have multiple variants it's used, I dont want to be limited to only "path: to/some" (with kustomize.yml) but I either want to be flexible to do "include: so/some" (and have some more control with another layer of deployment.yml).

For a good reason I dont want to structure my folders "to/some/kustomization" just because deplyment.yml must be one folder above, so it can by path: ./xxx refer the place where kustomization.yml is.

@epcim
Copy link
Contributor Author

epcim commented Jun 12, 2023

minor fix force-pushed in..

@codablock
Copy link
Collaborator

The way I understand you is that you want to have a shared kustimization with a set of shared variables attached to it, all while NOT having the kustomization below a sub-deployment (with just a deployment.yaml and the vars). Is this correct?

I'm not sure that his is worth the additional effort and risks being introduced. For example, the templating engine currently expects to work on deployment-item (a kustomization) level, meaning that it renders the whole directly in one go. At the same time, the deployment.yaml from a sub-deployment is rendered as a single file.

When we start to mix sub-deployments with deployment-items, we'd start to render files multiple times. This can easily lead to unexpected behaviour.

@codablock
Copy link
Collaborator

Based on what I wrote before: Right now, it is not explicitly forbidden to mix deployment-items and sub-deployments, it simply fails at some point. This should also be re-considered.

@epcim
Copy link
Contributor Author

epcim commented Jun 12, 2023

Well you made good point. Certainly I little experiment with structuring the repo/model input for kluctl.

First aimed to two approaches:

  • have directory with reusable config/examples/deployment files that I could share independently
  • define on vars (all interpolated params + possibly helm values & kustomization overrides)

That's why is required for simplicity. I anyway have workaround for the below as path: ../<folder name> but that is not that nice as:

deployments:

  • path: .

To answer you problem with mixing sub-deployments. Yes I have hit that (they just render once, or render each time depends how configured). And you are right this is not good pattern. Today I dont mix subdeployments and if then it;s for different target/cluster.

The reason for "experiment with structuring the repo/model input" is that I tend to have configuration parameters (vars) somewhere at top level, rather then partially in each deployment.yml across several folders for these reasons:

  • having full config (vars) down the last included deployment.yml is sort of "helm-values" like approach. Almost as hardcoded, still require some control params, interpolation and if/else in templates.
  • having full config (vars) down the last included deployment.yml does not play well if I want to share some params across multiple apps.
  • ^^ in both examples, one can move params up in the repo hiearchy and introduce new params for interpolation. That is pretty much ok in many example. I only have that experience it tend to "creative params/variables" model like structures that are uniq per deployment - thus not reusable. Thus rather pushing myself to structure all paramas "top level" and in the structure the application use it (helm-values, helm-lib values, my own interpolation, my own kustomization patches).

Top-down approach requires me to introduce some "patch" that will to "all" apps introduce some certain config (like ingress config or storageClass/persistence setup). While application deployment code remains simple, prone to extra templating, having space for others to reuse my "app deployment example" on their deployments with (their overrides) without having to deal with resources they dont need or interpolation/params they are not interested with.

(as mentioned, will share some deployment repo with you this week, possibly we could have some short zoom call to discuss)

@epcim
Copy link
Contributor Author

epcim commented Jun 15, 2023

will share some deployment repo with you this week

@codablock pls check "non-working" export from "working" setup":
https://github.com/epcim/gitops-infra-public/tree/main/cluster/apealive

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.

None yet

3 participants