Repository navigation
feat(resource): add crossplane resource simulate with provider diff servers (alpha)
#429
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
Draft
haarchri
wants to merge
2
commits into
crossplane:main
Choose a base branch
from
haarchri:feature/resource-simulate
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+3,000
−90
Draft
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| This command previews what applying one or more managed resources would do, | ||
| without applying anything: which resources it would create, which fields it | ||
| would change, and, most importantly, which changes the provider could only | ||
| apply by destroying and recreating the external resource. | ||
|
|
||
| For each input resource the CLI fetches the live managed resource from the | ||
| cluster, if one exists, and asks the provider itself for the verdict: it runs | ||
| the provider's package image locally as a diff server (a stateless, | ||
| credential-free gRPC service upjet-based providers serve) and sends it the | ||
| desired and live state. The provider computes its own diff, so the preview | ||
| includes replacement detection, values known only after apply, and redacted | ||
| sensitive values. A resource with no live counterpart plans as a create. | ||
|
|
||
| Which providers run as diff servers comes from the current kubeconfig context | ||
| by default: the CLI lists the providers installed on the cluster and uses | ||
| their package images, so the preview matches the provider versions the | ||
| cluster actually runs. --provider-images overrides that discovery, for | ||
| example to preview how a provider version that is not installed yet would | ||
| treat existing resources. | ||
|
|
||
| Not every provider serves diffs. A provider package declares the capability | ||
| in its metadata, and a resource whose provider serves no diff server (or | ||
| whose diff server cannot compute a diff for it) still appears in the preview | ||
| with an approximate client-side comparison, marked [?], rather than failing | ||
| the run or silently dropping out. | ||
|
|
||
| Nothing simulate does writes to the cluster or the cloud: it reads the | ||
| cluster with your kubeconfig and RBAC, and the diff servers run locally with | ||
| no credentials and no cluster access. | ||
|
|
||
| Diff server startup takes a few seconds per provider image. In an | ||
| edit-simulate-edit loop, --keep-diff-servers leaves the containers running so | ||
| the next run reuses them; they are named `crossplane-diff-server-DIGEST` and | ||
| are cleaned up by any later run without the flag, or manually with docker rm. | ||
|
|
||
| Examples: | ||
|
|
||
| # Preview what applying resources.yaml would do. | ||
| crossplane resource simulate -f resources.yaml | ||
|
|
||
| # Preview against a specific provider version instead of the installed one. | ||
| crossplane resource simulate -f resources.yaml --provider-images xpkg.upbound.io/upbound/provider-aws-ec2:v2.9.0 | ||
|
|
||
| # Keep diff servers running for faster subsequent runs. | ||
| crossplane resource simulate -f resources.yaml --keep-diff-servers | ||
|
|
||
| # Emit machine-readable results for CI gating. | ||
| crossplane resource simulate -f resources.yaml -o json | ||
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: we should format these to match what we have in other commands: