Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
cdk8s init typescript-app
(first: npm install -g cdk8s)
"cdk8s import k8s" generate from inside of CI, or committed in the repo?
opted to run it client-side.
tests are not comprehensive (add kubeval in a future iteration)
add package-lock.json - there is an error from CI about npm version
Our upstream base image is using NodeJS 14, which is the LTS release
Generally do not commit synths/*.js
(except for synths/jest.config.js, which is full of test configuration)
do not include compilation targets (*.js)
Generated by npm run compile and they should not be committed in CI
do not save snapshots/*.test.ts.snap
I am not sure how to use snapshots as an effective test strategy that
scales, so I will not use them.
(It is better to add health checks, run kubeval before generating a
commit, this way the tool can help you avoid a production incident.)
https://openconstructfoundation.org/testing-cdk8s/
If there are tests or validation in your chosen framework (jsonnet,
cdk8s, etc.) then of course you should also run them, and be sure that
if they fail, a commit is not generated.
We run "npm run compile" and "npm run test" with set -e so the build
will fail, and script will exit without generating a commit if compile
fails, or if a test does not pass. This will prevent downstream failure
based on partial apply or inconsistent state.
So we can see a problem in our generated output thanks to test failures,
the namespace has not been mentioned in the re-hydrated yaml from cdk8s.
Let's add a test that asserts we include the namespace, and include it.
...
run the tests in CI
this should stop synths commit from being generated in event that it
failed the test (this is imperfect, but it's a useful mitigation)
do not use snapshots for now
show how to update a deploy through cdk8s synth