KusionStack / kusion

Declarative Intent Driven Platform Orchestrator for Internal Developer Platform (IDP).
https://kusionstack.io
Apache License 2.0
879 stars 78 forks source link

Three-way Diff and Merge for Kubernetes resources #51

Closed SparkYuan closed 2 years ago

SparkYuan commented 2 years ago

Enhancement

Ref: https://kubernetes.io/docs/tasks/manage-kubernetes-objects/declarative-config/#how-apply-calculates-differences-and-merges-changes

howieyuen commented 2 years ago

Background

Kubernetes support 4 types of PATCH type:

And application/strategic-merge-patch+json only supports built-in types, not available to CRs.

Changes

Apply

kusion apply aims to support kinds of runtime. For kubernetes resources, we can try ServerSideApply first, or else back to JSON Merge Patch which is available to k8s and non k8s resources. Manifests for 3-way merge come from Modified(user specified this time), Original(applied last time, stored in kusion_state.json) and Current(live state in runtime).

Q&A

How to judge SSA feature is on? this is stable in v1.22+ May be need to introduce a new flag to indicate "--server-side" is on or not.

Preview

we have a preview stage in kusion apply process, which can see the changed details differ with Modified and Original, now we can perform a 3-way diff among Modified/Original/Current.

References

howieyuen commented 2 years ago

3-Way-Diff

Preview Stage

91

Apply Stage