Skip to content
This repository has been archived by the owner on Feb 6, 2024. It is now read-only.

Expand more data in the template #70

Closed
ensonic opened this issue Nov 14, 2017 · 9 comments
Closed

Expand more data in the template #70

ensonic opened this issue Nov 14, 2017 · 9 comments

Comments

@ensonic
Copy link
Contributor

ensonic commented Nov 14, 2017

Since k8s_object is already running substitution to apply project settings, it would be nice if one culd substitute other variables too.

1.) One option could be to specify an extra dict of key:value pairs that it would add to the substitutions it sets up for the images:

k8s_object(
  name = "x-deployment",
  template = ":deployment.yaml",
  images = { ... },
  substitutions = {
    "${KEY}": "value",
  },
)

Issues:
- one might want to setup some global substitution in k8s_defaults() and add more in the aliased rule

2.) Just add ctx.vars to the list of substitutions. All keys are changed to `${key}`or something simillar.
@ensonic
Copy link
Contributor Author

ensonic commented Nov 14, 2017

@mattmoor
Copy link
Contributor

I had this in my initial prototype and specifically avoided it because templating is a hot topic of debate in the K8s space right now.

I would much rather see this solved by templating rules that compose with (or even wrap) these rules. rules_jsonnet is an option, but without this may be of limited use.

@mattmoor
Copy link
Contributor

I'm going to close this for now, but happy to continue the discussion. If specific items fall out of further discussion, let's open more bugs. WDYT?

@ensonic
Copy link
Contributor Author

ensonic commented Nov 17, 2017

It is mostly a question of what the purpose of the k8s rules is. if it is to configure the k8s templates for the given build, then we should look for a templating solution as part of it. I have an idea that I will try today and keep you posted.

@mattmoor
Copy link
Contributor

At this point I would say: mostly development.

I want folks to be able to build/push/deploy in a tight cycle, and for that Bazel needs to be able to model the dependencies of the K8s resources.

There is possibility for involving this in a release process to "freeze" templates via something like:

bazel run :everything > release.yaml

(I use that here)

I agree that templating is often the next thing folks will want, but the DSL wars for K8s are just getting started, so my goal is for rules_k8s to compose with things like rules_jsonnet vs. embed very limited templating (as my original prototype did).

You can see some of the original discussion on this here.

@mattmoor
Copy link
Contributor

@ensonic ... and yes, keep me posted (but I'm OOTO starting tonight).

@ensonic
Copy link
Contributor Author

ensonic commented Nov 17, 2017

The problem with bazel run :everything > release.yaml is that this assumes all those things are safe to run. We have a build with all kind of things, tools, services, .... For some targets 'run' would actually run a binary. So conceptually we want to build everything and for the k8s rules that would mean to resolve the yaml files.

@mattmoor
Copy link
Contributor

For some targets 'run' would actually run a binary

bazel run on k8s_object[s] just publishes the images and prints the resolved template to stdout. It should not run any binaries. We do this on bazel run because publishing is non-hermetic, and neither is accessing your credential keyring.

@skyl
Copy link
Contributor

skyl commented Nov 3, 2022

is there a way to use a list or object in the template?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants