Skip to content
This repository has been archived by the owner on Dec 21, 2019. It is now read-only.

Add --include-file / --exclude-file for specific files in resource sets #69

Closed
alajmo opened this issue Jul 3, 2017 · 8 comments
Closed

Comments

@alajmo
Copy link

alajmo commented Jul 3, 2017

This is allowed with regular kubectl:

$ kubectl apply -f path/to/file-deploy.yaml

These don't seem to work:

$ kontemplate template beta-cluster.yaml -i path/to/file-deploy.yaml
 │Loading resources for path/to/file-deploy.yaml 

$ kontemplate template beta-cluster.yaml -i path/to/file-deploy
 │Loading resources for path/to/file-deploy

Meaning, they don't output the rendered file.

I attempted with the following beta-cluster.yaml:

---
context: lala
include:
  - name: path/to
    values:
      lala: land

  - name: path/to/file-deploy
    values:
      configStuff: stuff

  - name: path/to/file-deploy.yaml
    values:
      configStuff: stuff
@tazjin
Copy link
Owner

tazjin commented Jul 3, 2017

Currently include/exclude works on resource sets (i.e. the whole folder containing resources and potentially default values).

I could theoretically extend that to allow targeting specific files but there are a few considerations (do default vars still get loaded from the files basedir?) that I need to think about.

@alajmo
Copy link
Author

alajmo commented Jul 4, 2017

Well I would assume no since that's what globals are for?

  - name: some-api/hello
    values:
      version: 1.0-0e6884d
      importantFeature: true
      apiPort: 4567

some-api/lala would not inherit variables from some-api/hello. I do think this feature is needed since kubectl allows it. I also think kubectl replace is idempotent when you write over with the same config unless you do add the --force label, then it deletes and adds the new resource.

@tazjin
Copy link
Owner

tazjin commented Jul 11, 2017

Hmm, so you want to specify individual files inside a resource set in the context file? Why not just split them in separate resource sets then?

To elaborate, kontemplate does not call kubectl on a file - it renders the templates inside the resource set and passes them to the stdin of kubectl.

I also think kubectl replace is idempotent when you write over with the same config

Not entirely sure about this, I almost always apply with apply because that will normally do the correct thing :-)

@alajmo
Copy link
Author

alajmo commented Jul 13, 2017

Hmm, so you want to specify individual files inside a resource set in the context file? Why not just split them in separate resource sets then?

Well it makes sense to place them under the same folder but occasionally you'll make a change to stuff-deployment.yaml but not stuff-service.yaml, and thus you only want to apply stuff-deployment.

@tazjin
Copy link
Owner

tazjin commented Jul 13, 2017

Okay, but in that case I assume you'd want to use the --include | --exclude flags on the CLI as a one-off, rather than specifying that specific file in the cluster context?

@tazjin tazjin changed the title Targetting specific files does not seem to be possible Add --include-file / --exclude-file for specific files in resource sets Jul 26, 2017
@rolftimmermans
Copy link

rolftimmermans commented Aug 22, 2017

It is definitely useful to have support for individual files. My project is oriented per app (microservice) and I want the resource definition inside each directory. But the microservice directories also (potentially) contain lots of other JSON/YML files such as package.json. This is now presumed to be a resource definition but there appears to be absolutely no way around this. I cannot exclude any files, and I cannot selectively include specific files.

The project claims "no file naming conventions enforced at all", but there are definitely big assumptions on how the directories are structured (i.e. they must only contain resource definitions, or at least no other YML/JSON files since they cannot be excluded). This is not obvious from the documentation.

@rakshazi
Copy link

Hello!
Any update on this?

@tazjin
Copy link
Owner

tazjin commented Dec 20, 2019

The source of kontemplate is moving to git.tazj.in and I've moved this issue to the depot@tazj.in mailing list over here.

@tazjin tazjin closed this as completed Dec 20, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants