Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(k8s): add support for patching manifests #5187

Merged
merged 3 commits into from
Oct 6, 2023
Merged

Conversation

eysi09
Copy link
Collaborator

@eysi09 eysi09 commented Oct 4, 2023

What this PR does / why we need it:

From the commit message:

This change introduces a \`patchResources\` field to the \`kubernetes\`
Deploy action that allows users to overwrite the values of manifests in
Garden config without modifying the manifest itself.

This enables users to drop Garden into existing K8s projects without
making any other changes to code or config.

Under the hood, Garden uses the `kubectl patch` command. The behaviour
is documented here:

https://kubernetes.io/docs/tasks/manage-kubernetes-objects/update-api-object-kubectl-patch/

I also added an example project that demonstrates this functionality and updated the k8s-deploy-config-templates example to use the same pattern.

To do:

  • Update docs on Kubernetes action types (we can do that in a follow up PR if needed)

I started writing the docs on a different branch to keep things simple.

Which issue(s) this PR fixes:

Fixes #5082

Special notes for your reviewer:

The large number of line changes is due to the example projects. The main feature is pretty simple.

@eysi09 eysi09 force-pushed the k8s-patch-resources branch 7 times, most recently from 888cfdc to c90e4f3 Compare October 5, 2023 20:15
export interface KubernetesPatchResource {
name: string
// TODO @eysi: Can we get a better type here?
kind: string
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just went for a string type here instead of listing all K8s object types.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that makes sense because a user could also patch a custom resource.

@eysi09 eysi09 marked this pull request as ready for review October 5, 2023 20:26
@eysi09 eysi09 changed the title feat(k8s): add support for patching manifests (WIP) feat(k8s): add support for patching manifests Oct 5, 2023
@eysi09 eysi09 force-pushed the k8s-patch-resources branch 4 times, most recently from e6eac87 to 1938ed8 Compare October 6, 2023 08:45
This change introduces a \`patchResources\` field to the \`kubernetes\`
Deploy action that allows users to overwrite the values of manifests in
Garden config without modifying the manifest itself.

This enables users to drop Garden into existing K8s projects without
making any other changes to code or config.

Under the hood, Garden uses the `kubectl patch` command. The behaviour
is documented here:

https://kubernetes.io/docs/tasks/manage-kubernetes-objects/update-api-object-kubectl-patch/
twelvemo
twelvemo previously approved these changes Oct 6, 2023
Copy link
Collaborator

@twelvemo twelvemo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job! The examples are also super sound, nothing to improve imho. One nit-pick about a missing dot at the end of the sentence but that's it. Leaving it up to you to if you want to add it, otherwise approving.

export interface KubernetesPatchResource {
name: string
// TODO @eysi: Can we get a better type here?
kind: string
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that makes sense because a user could also patch a custom resource.

core/src/plugins/kubernetes/kubernetes-type/config.ts Outdated Show resolved Hide resolved
twelvemo
twelvemo previously approved these changes Oct 6, 2023
@eysi09 eysi09 enabled auto-merge October 6, 2023 14:42
Co-authored-by: Anna Mager <78752267+twelvemo@users.noreply.github.com>
@eysi09 eysi09 added this pull request to the merge queue Oct 6, 2023
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Oct 6, 2023
@eysi09 eysi09 enabled auto-merge October 6, 2023 16:50
@eysi09 eysi09 added this pull request to the merge queue Oct 6, 2023
Merged via the queue into main with commit 5f7f533 Oct 6, 2023
43 checks passed
@eysi09 eysi09 deleted the k8s-patch-resources branch October 6, 2023 20:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEATURE]: Re-use existing Kubernetes manifests without modifying them
2 participants