generated from kubernetes/kubernetes-template-project
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
[importer] Extend mapping capabilities. #1878
Merged
k8s-ci-robot
merged 3 commits into
kubernetes-sigs:main
from
epam:importer-advanced-mapping
Mar 21, 2024
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
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 |
---|---|---|
|
@@ -20,14 +20,47 @@ go build -C cmd/importer/ -o $(pwd)/bin/importer | |
|
||
The command runs against the systems default kubectl configuration. Check the [kubectl documentation](https://kubernetes.io/docs/tasks/access-application-cluster/configure-access-multiple-clusters/) to learn more about how to Configure Access to Multiple Clusters. | ||
|
||
### Check | ||
The importer will perform following checks: | ||
|
||
- At least one `namespace` is provided. | ||
- The label key (`queuelabel`) providing the queue mapping is provided. | ||
- A mapping from one of the encountered `queuelabel` values to an existing LocalQueue exists. | ||
- For every Pod a mapping to a LocalQueue is available. | ||
- The target LocalQueue exists. | ||
- The LocalQueues involved in the import are using an existing ClusterQueue. | ||
- The ClusterQueues involved have at least one ResourceGroup using an existing ResourceFlavor. This ResourceFlavor is used when the importer creates the admission for the created workloads. | ||
|
||
The are two ways the mapping from a pod to a LocalQueue can be specified: | ||
|
||
#### Simple mapping | ||
|
||
It's done by specifying a label name and any number of <label-value>=<localQueue-name> a command line arguments eg. `--queuelabel=src.lbl --queuemapping=src-val=user-queue,src-val2=user-queue2`. | ||
|
||
#### Advanced mapping | ||
|
||
It's done providing an yaml mapping file name as `--queuemapping-file` argument, it's expected content being: | ||
|
||
```yaml | ||
- match: | ||
labels: | ||
src.lbl: src-val | ||
toLocalQueue: user-queue | ||
- match: | ||
priorityClassName: p-class | ||
labels: | ||
src.lbl: src-val2 | ||
src2.lbl: src2-val | ||
toLocalQueue: user-queue2 | ||
- match: | ||
labels: | ||
src.lbl: src-val3 | ||
skip: true | ||
``` | ||
|
||
- During the mapping, if the match rule has no `priorityClassName` the `priorityClassName` of the pod will be ignored, if more than one `label: value` pairs are provided, all of them should match. | ||
- The rules are evaluated in order. | ||
- `skip: true` can be used to ignore the pods matching a rule. | ||
|
||
### Import | ||
After which, if `--dry-run=false` was specified, for each selected Pod the importer will: | ||
|
||
- Update the Pod's Kueue related labels. | ||
|
@@ -36,7 +69,31 @@ After which, if `--dry-run=false` was specified, for each selected Pod the impor | |
|
||
### Example | ||
|
||
#### Simple mapping | ||
|
||
```bash | ||
./bin/importer import -n ns1,ns2 --queuelabel=src.lbl --queuemapping=src-val=user-queue,src-val2=user-queue2 --dry-run=false | ||
``` | ||
Will import all the pods in namespace `ns1` or `ns2` having the label `src.lbl` set in LocalQueues `user-queue` or `user-queue2` depending on `src.lbl` value. | ||
|
||
#### Advanced mapping | ||
With mapping file: | ||
```yaml | ||
- match: | ||
labels: | ||
src.lbl: src-val | ||
toLocalQueue: user-queue | ||
- match: | ||
priorityClassName: p-class | ||
labels: | ||
src.lbl: src-val2 | ||
src2.lbl: src2-val | ||
toLocalQueue: user-queue2 | ||
``` | ||
|
||
```bash | ||
./bin/importer import -n ns1,ns2 --queuemapping-file=<mapping-file-path> --dry-run=false | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could script return |
||
``` | ||
|
||
Will import all the pods in namespace `ns1` or `ns2` having the label `src.lbl` set to `src-val` in LocalQueue `user-queue` regardless of their priorityClassName and those with `src.lbl==src-val2` ,`src2.lbl==src2-val` and `priorityClassName==p-class`in `user-queue2`. | ||
|
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
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
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
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
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.
could the user leave a rule with no priorityClassName and no labels with
skip:true
?That could be a way of saying: if it doesn't match any rule above, I just don't care about this pod.
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.
yes,
at the end is doing that.
similarly
will put all the pods in one localQueue