Open vumdao opened 11 months ago
I think
const app = new App({
outdir: 'dist/my-helm',
});
doesn't work.
Try cdk8s synth --output dist/my-helm
CLI flag instead.
@shinebayar-g It does work without helm synthesis
➜ repro-cdk8s-helm pj build
../../Library/pnpm/store/v3/tmp/dlx-2280 | +1 +
../../Library/pnpm/store/v3/tmp/dlx-2280 | Progress: resolved 1, reused 1, downloaded 0, added 1, done
👾 build » default | ts-node --project tsconfig.dev.json .projenrc.ts
👾 build » compile | tsc --build
👾 build » post-compile » synth | cdk8s synth
Synthesizing application
- dist/my-helm/deployment.k8s.yaml
👾 build » test | jest --passWithNoTests --updateSnapshot
No tests found, exiting with code 0
----------|---------|----------|---------|---------|-------------------
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
----------|---------|----------|---------|---------|-------------------
All files | 0 | 0 | 0 | 0 |
----------|---------|----------|---------|---------|-------------------
👾 build » test » eslint | eslint --ext .ts,.tsx --fix --no-error-on-unmatched-pattern src test build-tools projenrc .projenrc.ts
@vumdao The issue @shinebayar-g linked to explains the problem.
Here is what happens:
outdir
value configured in your app. So it thinks the output is just dist
.App
to produce manifests inside dist/templates
(via env variable), to conform to helm structure.App
"ignores" this env variable because the outdir
is explicitly set.App
produces manifests inside dist/my-helm
dist/templates
, and fails to find them.The reason it works with regular synthesis is just because the outdir
you configured happens to be a sub-directory of dist
, and the CLI searches for manifests recursively inside what it thinks is the outdir
.
There is no real way around it, because the CLI must place the manifests inside {outdir}/templates
, but since it doesn't know what outdir
is, it is bound to fail.
Are you able to workaround the issue by using --output dist/my-helm
as @shinebayar-g suggested? Or is this blocking you?
@iliapolo Using option --output
works well but is it possible to separate build targets like following
What kind of separation are you looking for? Based on what? Are these separate charts or resources inside the same chart?
@iliapolo my use case is synth-ing a helm chart per environment ( qa, staging etc) from a single cdk8s app. This doesn't work as all chart instances are part of the same app and get rendered as a single helm chart.
It seems that unlike the cdk ( using the Stage concept ), a single cdk8s App can only emit a single "assembly".
IMO porting / reusing the stage concept to the cdk8s would address this and similar concerns.
Description of the bug:
Reproduction Steps:
Init project using projen
Add projen task for Synthesizing applications into Helm charts
project.addTask('sync-helm', { description: 'Synthesizing applications into Helm charts', exec: 'cdk8s synth --format helm --chart-version 1.0.0' });
project.addTask('helm', { description: 'Full release build for helm chart', steps: [ { spawn: 'default' }, { spawn: 'pre-compile' }, { spawn: 'compile', }, { spawn: "sync-helm" } ] })
project.synth();
npx projen
➜ repro-cdk8s-helm cat src/main.ts import { App, Chart, ChartProps } from 'cdk8s'; import * as kplus from 'cdk8s-plus-27'; import { Construct } from 'constructs';
export class MyChart extends Chart { constructor(scope: Construct, id: string, props: ChartProps = { }) { super(scope, id, props);
} }
const app = new App({ outdir: 'dist/my-helm', });
new MyChart(app, 'deployment'); app.synth();
➜ repro-cdk8s-helm pj helm ../../Library/pnpm/store/v3/tmp/dlx-8904 | +1 + ../../Library/pnpm/store/v3/tmp/dlx-8904 | Progress: resolved 1, reused 1, downloaded 0, added 1, done 👾 helm » default | ts-node --project tsconfig.dev.json .projenrc.ts 👾 helm » compile | tsc --build 👾 helm » sync-helm | cdk8s synth --format helm --chart-version 1.0.0 Synthesizing application ERROR: synthesis failed, app expected to create "dist/templates" 👾 Task "helm » sync-helm" failed when executing "cdk8s synth --format helm --chart-version 1.0.0" (cwd: /Users/vudao/workspace/repro-cdk8s-helm)  ERROR  Command failed with exit code 1: projen helm
pnpm: Command failed with exit code 1: projen helm at makeError (/opt/homebrew/Cellar/pnpm/8.6.7/libexec/dist/pnpm.cjs:24796:17) at handlePromise (/opt/homebrew/Cellar/pnpm/8.6.7/libexec/dist/pnpm.cjs:25367:33) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async Object.handler [as dlx] (/opt/homebrew/Cellar/pnpm/8.6.7/libexec/dist/pnpm.cjs:209900:7) at async /opt/homebrew/Cellar/pnpm/8.6.7/libexec/dist/pnpm.cjs:219307:21 at async main (/opt/homebrew/Cellar/pnpm/8.6.7/libexec/dist/pnpm.cjs:219274:34) at async runPnpm (/opt/homebrew/Cellar/pnpm/8.6.7/libexec/dist/pnpm.cjs:219529:5) at async /opt/homebrew/Cellar/pnpm/8.6.7/libexec/dist/pnpm.cjs:219521:7