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
Run the kubecm merge
command with the --select-context
parameter.
./kubecm merge --config output kubeconfig1 kubeconfig2 --select-context
If there is no context to add or merge, the program ends directly instead of asking Does it overwrite File xxx ?
.
Changelog
What's Changed
- ci: 🎡 add monthly issue metrics report action by @sunny0826 in #873
- chore(deps): bump k8s.io/api from 0.29.0 to 0.29.1 by @dependabot in #871
- chore(deps): bump github.com/pterm/pterm from 0.12.74 to 0.12.75 by @dependabot in #869
- Fix routing on website by @yardenshoham in #875
- add yardenshoham as a contributor for doc by @allcontributors in #876
- chore(deps): bump peter-evans/create-issue-from-file from 4 to 5 by @dependabot in #881
- chore(deps): bump k8s.io/client-go from 0.29.0 to 0.29.1 by @dependabot in #880
- chore(deps): bump codecov/codecov-action from 3.1.4 to 3.1.5 by @dependabot in #882
- chore(deps): bump github.com/pterm/pterm from 0.12.75 to 0.12.76 by @dependabot in #878
- chore(deps): bump github.com/aws/aws-sdk-go from 1.49.21 to 1.50.5 by @dependabot in #879
- chore(deps): bump codecov/codecov-action from 3.1.5 to 4.0.1 by @dependabot in #884
- chore(deps): bump github.com/pterm/pterm from 0.12.76 to 0.12.78 by @dependabot in #886
- feat: Refactor Azure support by @jkroepke in #800
- add jkroepke as a contributor for code by @allcontributors in #894
- chore(deps): bump golangci/golangci-lint-action from 3 to 4 by @dependabot in #889
- chore(deps): bump github.com/pterm/pterm from 0.12.78 to 0.12.79 by @dependabot in #893
- chore(deps): bump k8s.io/api from 0.29.1 to 0.29.2 by @dependabot in #896
- chore(deps): bump codecov/codecov-action from 4.0.1 to 4.0.2 by @dependabot in #901
- chore(deps): bump github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tke from 1.0.841 to 1.0.861 by @dependabot in #900
- chore(deps): bump codecov/codecov-action from 4.0.2 to 4.1.0 by @dependabot in #904
- chore(deps): bump github.com/aws/aws-sdk-go from 1.50.5 to 1.50.35 by @dependabot in #908
- chore(deps): bump github.com/alibabacloud-go/tea from 1.2.1 to 1.2.2 by @dependabot in #890
- chore(deps): bump google.golang.org/protobuf from 1.31.0 to 1.33.0 by @dependabot in #910
- chore(deps): bump github/issue-metrics from 2 to 3 by @dependabot in #916
- chore(deps): bump codecov/codecov-action from 4.1.0 to 4.1.1 by @dependabot in #915
- chore(deps): bump github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tke from 1.0.861 to 1.0.890 by @dependabot in #917
- chore(deps): bump github.com/Azure/azure-sdk-for-go/sdk/azcore from 1.9.2 to 1.10.0 by @dependabot in #907
- chore(deps): bump codecov/codecov-action from 4.1.1 to 4.2.0 by @dependabot in #920
- chore(deps): bump codecov/codecov-action from 4.2.0 to 4.3.0 by @dependabot in #925
- update go.mod by @sunny0826 in #928
- chore(deps): bump golang.org/x/net from 0.21.0 to 0.23.0 by @dependabot in #929
- README add new badges by @sunny0826 in #934
- chore(deps): bump github.com/stretchr/testify from 1.8.4 to 1.9.0 by @dependabot in #922
- chore(deps): bump k8s.io/api from 0.29.2 to 0.30.0 by @dependabot in #930
- chore(deps): bump golangci/golangci-lint-action from 4 to 5 by @dependabot in #937
- chore(deps): bump k8s.io/client-go from 0.29.1 to 0.30.0 by @dependabot in #939
- chore(deps): bump golangci/golangci-lint-action from 5 to 6 by @dependabot in #951
- chore(deps): bump codecov/codecov-action from 4.3.0 to 4.3.1 by @dependabot in #947
- feat: allow select context for kubecm add and merge command by @cr7258 in #952
- add cr7258 as a contributor for doc by @allcontributors in #953
- chore(deps): bump codecov/codecov-action from 4.3.1 to 4.4.0 by @dependabot in #954
- feat: generate context name by specific attributes by @cr7258 in #956
New Contributors
Full Changelog: v0.28.0...v0.29.0