jkcfg / jk

Configuration as Code with ECMAScript
https://jkcfg.github.io
Apache License 2.0
404 stars 30 forks source link

skaffold support #165

Open bryanlarsen opened 5 years ago

bryanlarsen commented 5 years ago

I opened a super hacky PR on skaffold to start discussion about including support for jk: https://github.com/GoogleContainerTools/skaffold/pull/1983

dlespiau commented 5 years ago

Thanks for that!

Note that we realise there's probably a better way to declare the files you want to generate instead of having to use std.write everytime (https://github.com/jkcfg/jk/issues/125). For instance this could look like:

const myservice = 'foo';
const ns = 'namespace';

const deployment = new k8s.apps.v1.Deployment(myservice, ...);
const service = ...

export default {
  `${ns}/{myservice}-deploy.yaml`: deployment,
  `${ns}/{myservice}-svc.yaml`: service,
};

To execute this we would introduce a new generate command that know what to do which this exported object:

jk generate --stdout myservice.js
bryanlarsen commented 5 years ago

Using export doesn't allow us to pass parameters to units. We have our code structured so that every unit exports a function that returns an array of manifests. Then the top level calls all the units and std.write's everything to stdout using a YAMLStream.

A more important issue vis-a-vis skaffold integration is that we're going to need a way to generate the list of input filenames so that skaffold can inotify wait on them. Can we get that out of jk somehow?