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

kubecm 0.29.0 #172590

Merged
merged 2 commits into from
May 23, 2024
Merged

kubecm 0.29.0 #172590

merged 2 commits into from
May 23, 2024

Conversation

BrewTestBot
Copy link
Member

Created by brew bump


Created with brew bump-formula-pr.

release notes
## Highlight

Thanks to @cr7258 for his outstanding contribution to solving a long-standing issue #768 .

Generate context name by specific attributes

Use two kubeconfig files for testing.

./kubecm list --config kubeconfig1
+------------+-------------+-------------+----------+-------------------------+--------------+
|   CURRENT  |     NAME    |   CLUSTER   |   USER   |          SERVER         |   Namespace  |
+============+=============+=============+==========+=========================+==============+
|      *     |   context1  |   cluster1  |   user1  |   https://example1.com  |    default   |
+------------+-------------+-------------+----------+-------------------------+--------------+
./kubecm list --config kubeconfig2
+------------+-------------+-------------+----------+-------------------------+----------------+
|   CURRENT  |     NAME    |   CLUSTER   |   USER   |          SERVER         |    Namespace   |
+============+=============+=============+==========+=========================+================+
|      *     |   context2  |   cluster2  |   user2  |   https://example2.com  |   kube-system  |
+------------+-------------+-------------+----------+-------------------------+----------------+
|            |   context3  |   cluster3  |   user3  |   https://example3.com  |     default    |
+------------+-------------+-------------+----------+-------------------------+----------------+
|            |   context4  |   cluster4  |   user4  |   https://example4.com  |     default    |
+------------+-------------+-------------+----------+-------------------------+----------------+

Case 1: Use the default context-template value ("context")
The context name is the same as the original kubeconfig.

./kubecm add --config kubeconfig1 -f kubeconfig2

# result
+------------+-------------+-------------+----------+-------------------------+----------------+
|   CURRENT  |     NAME    |   CLUSTER   |   USER   |          SERVER         |    Namespace   |
+============+=============+=============+==========+=========================+================+
|      *     |   context1  |   cluster1  |   user1  |   https://example1.com  |     default    |
+------------+-------------+-------------+----------+-------------------------+----------------+
|            |   context2  |   cluster2  |   user2  |   https://example2.com  |   kube-system  |
+------------+-------------+-------------+----------+-------------------------+----------------+
|            |   context3  |   cluster3  |   user3  |   https://example3.com  |     default    |
+------------+-------------+-------------+----------+-------------------------+----------------+
|            |   context4  |   cluster4  |   user4  |   https://example4.com  |     default    |
+------------+-------------+-------------+----------+-------------------------+----------------+

Case 2: Define context template

./kubecm add --config kubeconfig1 -f kubeconfig2 --context-template filename,cluster,user

# result
+------------+-------------------------------+-------------+----------+-------------------------+----------------+
|   CURRENT  |              NAME             |   CLUSTER   |   USER   |          SERVER         |    Namespace   |
+============+===============================+=============+==========+=========================+================+
|      *     |            context1           |   cluster1  |   user1  |   https://example1.com  |     default    |
+------------+-------------------------------+-------------+----------+-------------------------+----------------+
|            |   kubeconfig2-cluster2-user2  |   cluster2  |   user2  |   https://example2.com  |   kube-system  |
+------------+-------------------------------+-------------+----------+-------------------------+----------------+
|            |   kubeconfig2-cluster3-user3  |   cluster3  |   user3  |   https://example3.com  |     default    |
+------------+-------------------------------+-------------+----------+-------------------------+----------------+
|            |   kubeconfig2-cluster4-user4  |   cluster4  |   user4  |   https://example4.com  |     default    |
+------------+-------------------------------+-------------+----------+-------------------------+----------------+

Case 3: Define context template and context prefix

./kubecm add --config kubeconfig1 -f kubeconfig2 --context-template cluster,user --context-prefix demo

# result
+------------+------------------------+-------------+----------+-------------------------+----------------+
|   CURRENT  |          NAME          |   CLUSTER   |   USER   |          SERVER         |    Namespace   |
+============+========================+=============+==========+=========================+================+
|      *     |        context1        |   cluster1  |   user1  |   https://example1.com  |     default    |
+------------+------------------------+-------------+----------+-------------------------+----------------+
|            |   demo-cluster2-user2  |   cluster2  |   user2  |   https://example2.com  |   kube-system  |
+------------+------------------------+-------------+----------+-------------------------+----------------+
|            |   demo-cluster3-user3  |   cluster3  |   user3  |   https://example3.com  |     default    |
+------------+------------------------+-------------+----------+-------------------------+----------------+
|            |   demo-cluster4-user4  |   cluster4  |   user4  |   https://example4.com  |     default    |
+------------+------------------------+-------------+----------+-------------------------+----------------+

Case 4: kubecm merge with context template

./kubecm merge kubeconfig1 kubeconfig2 --context-template cluster,user

# result
+------------+-------------------+-------------+----------+-------------------------+----------------+
|   CURRENT  |        NAME       |   CLUSTER   |   USER   |          SERVER         |    Namespace   |
+============+===================+=============+==========+=========================+================+
|            |   cluster1-user1  |   cluster1  |   user1  |   https://example1.com  |     default    |
+------------+-------------------+-------------+----------+-------------------------+----------------+
|            |   cluster2-user2  |   cluster2  |   user2  |   https://example2.com  |   kube-system  |
+------------+-------------------+-------------+----------+-------------------------+----------------+
|            |   cluster3-user3  |   cluster3  |   user3  |   https://example3.com  |     default    |
+------------+-------------------+-------------+----------+-------------------------+----------------+
|            |   cluster4-user4  |   cluster4  |   user4  |   https://example4.com  |     default    |
+------------+-------------------+-------------+----------+-------------------------+----------------+

Case 5: Define context name
it's useful if there is only one context in the kubeconfig file.

./kubecm add --config kubeconfig2 -f kubeconfig1 --context-name seven

# result
+------------+-------------+-------------+----------+-------------------------+----------------+
|   CURRENT  |     NAME    |   CLUSTER   |   USER   |          SERVER         |    Namespace   |
+============+=============+=============+==========+=========================+================+
|      *     |   context2  |   cluster2  |   user2  |   https://example2.com  |   kube-system  |
+------------+-------------+-------------+----------+-------------------------+----------------+
|            |   context3  |   cluster3  |   user3  |   https://example3.com  |     default    |
+------------+-------------+-------------+----------+-------------------------+----------------+
|            |   context4  |   cluster4  |   user4  |   https://example4.com  |     default    |
+------------+-------------+-------------+----------+-------------------------+----------------+
|            |    seven    |   cluster1  |   user1  |   https://example1.com  |     default    |
+------------+-------------+-------------+----------+-------------------------+----------------+

If the kubeconfig file contains more than 1 context, an incremental number will be added as a suffix.

./kubecm add --config kubeconfig1 -f kubeconfig2 --context-name seven
Add Context: seven
Add Context: seven-2
Add Context: seven-3

Allow select context for kubecm add and merge command

Add the --select-context parameter allowing the user to choose which context should be added when running the kubecm add and kubecm merge commands.

Prepare two kubeconfig.

./kubecm list --config kubeconfig1
+------------+-------------+-------------+----------+-------------------------+--------------+
|   CURRENT  |     NAME    |   CLUSTER   |   USER   |          SERVER         |   Namespace  |
+============+=============+=============+==========+=========================+==============+
|      *     |   context1  |   cluster1  |   user1  |   https://example1.com  |    default   |
+------------+-------------+-------------+----------+-------------------------+--------------+

./kubecm list --config kubeconfig2
+------------+-------------+-------------+----------+-------------------------+--------------+
|   CURRENT  |     NAME    |   CLUSTER   |   USER   |          SERVER         |   Namespace  |
+============+=============+=============+==========+=========================+==============+
|      *     |   context2  |   cluster2  |   user2  |   https://example2.com  |    default   |
+------------+-------------+-------------+----------+-------------------------+--------------+
|            |   context3  |   cluster3  |   user3  |   https://example3.com  |    default   |
+------------+-------------+-------------+----------+-------------------------+--------------+
|            |   context4  |   cluster4  |   user4  |   https://example4.com  |    default   |
+------------+-------------+-------------+----------+-------------------------+--------------+

Run the kubecm add command with the --select-context parameter. The user needs to confirm each context to be imported. If the --select-context parameter is omitted, confirmation is not required.

./kubecm add --config kubeconfig1 -f kubeconfig2 --select-context

asciicast

Run the kubecm merge command with the --select-context parameter.

./kubecm merge --config output  kubeconfig1 kubeconfig2 --select-context

asciicast

If there is no context to add or merge, the program ends directly instead of asking Does it overwrite File xxx ?.
asciicast

Changelog

What's Changed

New Contributors

Full Changelog: sunny0826/kubecm@v0.28.0...v0.29.0

@github-actions github-actions bot added go Go use is a significant feature of the PR or issue bump-formula-pr PR was created using `brew bump-formula-pr` labels May 23, 2024
Copy link
Contributor

🤖 An automated task has requested bottles to be published to this PR.

@github-actions github-actions bot added the CI-published-bottle-commits The commits for the built bottles have been pushed to the PR branch. label May 23, 2024
@BrewTestBot BrewTestBot enabled auto-merge May 23, 2024 12:35
@BrewTestBot BrewTestBot added this pull request to the merge queue May 23, 2024
Merged via the queue into master with commit 1bd6738 May 23, 2024
14 checks passed
@BrewTestBot BrewTestBot deleted the bump-kubecm-0.29.0 branch May 23, 2024 12:42
@github-actions github-actions bot added the outdated PR was locked due to age label Jun 24, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 24, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bump-formula-pr PR was created using `brew bump-formula-pr` CI-published-bottle-commits The commits for the built bottles have been pushed to the PR branch. go Go use is a significant feature of the PR or issue outdated PR was locked due to age
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants