-
Notifications
You must be signed in to change notification settings - Fork 337
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
docs(MADR): resource identifier format #12756
Open
lobkovilya
wants to merge
1
commit into
kumahq:master
Choose a base branch
from
lobkovilya:docs/madr-70
base: master
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.
+99
−0
Open
Changes from all commits
Commits
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 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,99 @@ | ||
# Resource Identifier | ||
|
||
* Status: accepted | ||
|
||
## Context and Problem Statement | ||
|
||
Kuma multizone mode allows synchronizing state between multiple clusters. Zone Control Planes connect to the Global Control Plane, forming a tree with the Global CP as the root. | ||
|
||
There are several resource synchronization patterns: | ||
- A resource is created on the Global CP and synced down to all Zone CPs. | ||
- A resource is created on a Zone CP and synced to the Global CP. | ||
- A resource is created on a Zone CP and synced to other Zone CPs. | ||
|
||
For example, the Zone CP in `zone-1` can possess the following MeshTimeouts: | ||
- MeshTimeouts created in `zone-1` | ||
- MeshTimeouts created on the Global CP and synced to `zone-1` | ||
- MeshTimeouts created in `zone-2` and synced to `zone-1` | ||
|
||
To uniquely identify a resource regardless of its place of origin, Kuma uses the following Go structure: | ||
|
||
```go | ||
type ResourceIdentifier struct { | ||
Name string | ||
Mesh string | ||
Namespace string | ||
Zone string | ||
} | ||
``` | ||
|
||
When mixing identifiers of different resource types, an extended version is used: | ||
|
||
```go | ||
type TypedResourceIdentifier struct { | ||
ResourceIdentifier | ||
|
||
ResourceType ResourceType | ||
SectionName string | ||
} | ||
``` | ||
|
||
Currently, the resource identifier lacks a string representation and is not exposed to the Kuma public API. The goal of this MADR is to propose a format. | ||
|
||
## Decision Drivers | ||
|
||
- Possible to use the identifier in a URL path as `:5681/_rules/<identifier>` | ||
- Human-readable: users should be able to type the identifier manually if needed | ||
|
||
## Considered Options | ||
|
||
* Option 1 - Order-based, no field names in the identifier | ||
* Option 2 - Field names in the identifier | ||
|
||
## Decision Outcome | ||
|
||
* Option 1 - Order-based, no field names in the identifier | ||
|
||
## Pros and Cons of the Options | ||
|
||
### Option 1 - Order-based, no field names in the identifier | ||
|
||
We need to pick a delimiter that's allowed in the URL path and not allowed in resource names, meshes, namespaces, or zones. Good candidates are `:` and `_`. | ||
|
||
There is an identifier format from Amazon called [ARN](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference-arns.html). We can adopt a similar approach: | ||
|
||
``` | ||
kri:<mesh>:<zone>:<namespace>:<resource-type>:<resource-name>:<section-name> | ||
``` | ||
For example: | ||
``` | ||
kri:mesh-1:us-east-2:kuma-demo:meshservice:backend | ||
kri:mesh-1:us-east-2:kuma-demo:meshservice:backend:http-port | ||
kri:mesh-1:::meshtimeout:global-timeouts | ||
``` | ||
|
||
Having a prefix like `kri` (Kuma Resource Identifier) is useful for two reasons: | ||
* It visually clarifies the format for users, who can then search for the format description in the documentation. | ||
* It acts as an implicit version. If we need to update the format, we can use a different prefix (e.g., `uri` or `ri`). | ||
|
||
**Pros:** | ||
- Shorter | ||
- Resembles existing formats from Amazon | ||
|
||
**Cons:** | ||
- Hard to read when names are poorly chosen, e.g., `kri:default:default:default:meshservice:backend` | ||
|
||
### Option 2 - Field names in the identifier | ||
|
||
We need to pick two delimiters: one to separate keys from values and another to separate key-value pairs. | ||
|
||
```yaml | ||
kri:meshservice:mesh=mesh-1:zone:zone-1:namespace=kuma-demo:name=backend:section=http-port | ||
``` | ||
|
||
**Pros:** | ||
- Better handling of gaps; no need for `::` when a value is not defined | ||
|
||
**Cons:** | ||
- Longer | ||
- The order of fields still matters if we want to compare identifiers with `==` |
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.
Would it be possible to use random order and specify only some of the fields, to select multiple resources?
If not then I think not using field name makes more sense as you still need to remember order and fields