Comments (4)
Hi Alex, which bit do you want to use with Node? Do you want to, e.g., use @jkcfg/std
from a Node.JS script? Or something else.
from jk.
Maybe I should explain why I'm asking all these questions. I work on Argo CD and Argo Workflows. I'm trying to see if I can use JK to template apps because Helm, Kustomize, and Jsonnet don't do what I need.
I have around 160 apps to template, one for each Kubernetes cluster. These apps are largely homogenic - BUT not quite.
All the clusters are listed in a single YAML file which is generated by combining three other JSON files and a CSV, which is done using a Golang script. The output is
- arn: arn:aws:acm:us-west-2:469802291...
bu: sbg ;# this business uint
hostName: ;# the host name of the ingress
ingress: true
name: my-cluster.cluster.k8s.local
server: https://REDACTED.west-2.elb.amazonaws.com
splunk: https://REDACTED
type: preprod ;# or prod
wave: 3 ;# which release wave they go in and therefore which manifests and images they are based
So I have one control-plane app in Argo CD that create one app for each cluster (this is know as "app-of-apps").
So those apps should use one script to generate the YAML.
For Argo CD to support JK in this use case we need to:
- (a) Install JK as a custom plugin.
- (b) Parameterize the build based on the cluster name (which will be the app's name).
Argo CD requires you print the YAML to stdout, not to a file, e.g.:
print(manifests, {
format: Format.YAMLStream
});
An you must invoke jk run main.js
not jk generate main.js
(aside - I tried path: '/dev/stdout'
- it did not seem to work).
The way you parametrize a build in Argo CD is using environment variables. ARGOCD_APP_NAME;
is the app name, which is also the cluster name.
So I have a script to generate the control plane:
read("data/cluster-configs.yaml").then(cs => {
const apps = cs.map(c => {
...
return m;
});
print(apps, {format: Format.YAMLStream});
});
An one to generate each cluster app:
read("data/cluster-configs.yaml").then(cs => {
const c = cs.find(c => c.name = cluster);
read("base/wave" + c.wave + "/image-tag.json", {
format: Format.Raw
}).then(imageTag => {
read(
"src/argo-workflows/base/wave" + c.wave + "/resources/upstream.yaml",
{format: Format.YAMLStream}
).then(upstream => {
I thought I could do this using:
const cluster = process.ENV.ARGOCD_APP_NAME;
But that does not seem to work?
from jk.
If you have time, it'd be great to Zoom about this.
from jk.
Argo CD requires you print the YAML to stdout, not to a file, e.g.:
You can get jk generate
to print to stdout with jk generate --stdout
. The draft documentation in jkcfg/website#39 (files on that branch) go a little way towards explaining run
vs generate
and the rest.
The way you parametrize a build in Argo CD is using environment variables.
ARGOCD_APP_NAME;
is the app name, which is also the cluster name.
There's no access to environment variables from within a script, at present. You will need to wrap jk in a shell script that translates environment variables to parameters passed to jk
at invocation, or the equivalent.
"src/argo-workflows/base/wave" + c.wave + "/resources/upstream.yaml"
A slightly neater way to construct strings is
`src/argo-workflows/base/wave${c.wave}/resources/upstream.yaml`
(backticks deliberate)
from jk.
Related Issues (20)
- Force format of output HOT 1
- Transform doesn't write streams back again
- Validate doesn't read multi-valued files HOT 1
- Support CSV files HOT 3
- Support for YAML streams HOT 3
- Sandboxing JK HOT 4
- `write` can write outside the output directory HOT 1
- Migrate from gometalinter golangci-lint
- Can the jkcfg/build image use jkcfg/prebuilt? HOT 5
- JK vs Helm vs Kustomize vs TK vs Jsonnet
- Kubernetes Resource Typescript Generation HOT 1
- fatal panic during exection due to import cycle HOT 1
- Can't run jk generate with absolute path
- jk generate will fail silently to overwrite files HOT 2
- Possible to generate a YAML comment? HOT 2
- Using params with std.Format.Raw HOT 2
- TOML support HOT 1
- comparison to l9t and usage of denojs HOT 1
- Status of Project? HOT 11
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jk.