cdk8s-core icon indicating copy to clipboard operation
cdk8s-core copied to clipboard

FOLDER_PER_CHART_FILE_PER_RESOURCE does not respect dependency order

Open ameyp opened this issue 1 year ago • 0 comments

Description of the bug:

If I specify the YamlOutputType as FOLDER_PER_CHART_FILE_PER_RESOURCE for synth, I expect the resources in the folder created to be named in such a way as to honor their dependency order. However, the resources are created without an index prefix, and so will be applied in alphabetical order by kubectl/fluxcd/whatever.

I see two options:

  • Prefix the filenames with their index, I think this will work
  • (Better option IMO) Create a kustomize.yaml with a resources block that lists each file in order

Reproduction Steps:

class MyChart extends Chart {
    constructor(scope: Construct, id: string) {
        super(scope, id, {
            namespace: constants.databases.namespace
        });

        const resource1 = // ...create resource here
        const resource2 = // ...create resource here
        resource1.addDependency(resource2)
}

const app = new App({
    yamlOutputType: YamlOutputType.FOLDER_PER_CHART_FILE_PER_RESOURCE
});

const chart = new MyChart(app, 'mychart');
app.synth();

This will generate two files:

  • resource1.yaml
  • resource2.yaml

Which will be applied in that order, despite resource1 needing resource2 to be applied first.


This is :bug: Bug Report

ameyp avatar Jun 09 '23 15:06 ameyp