Giter Club home page Giter Club logo

kubecm's Introduction

Kubecm

GitHub go.mod Go version Go Go Report Card GitHub License GitHub release codecov CII Best Practices All Contributors

demo

🚀 Install

homebrew downloads GitHub Downloads (all assets, all releases)

Using Krew:

kubectl krew install kc

Using Homebrew:

brew install kubecm

Source binary:

Download the binary

💫 Highlights

  • Context Management: Switch between Kubernetes clusters and namespaces in a single command.
  • Merge-Kubeconfig: Merge multiple kubeconfig files into one.
  • Interactive Mode: Interactively select the context you want to switch to.
  • Multi-Platform: Support Linux, macOS, and Windows.
  • Auto-Completion: Support auto-completion for Bash, Zsh, and Fish.

📝 Documentation

For full documentation, please visit the KubeCM website: https://kubecm.cloud

🎬 Demo

asciicast

🤝 Contribute

We love your input! We want to make contributing to this project as easy and transparent as possible, whether it's:

  • Reporting a bug
  • Discussing the current state of the code
  • Submitting a fix
  • Proposing new features
  • Becoming a maintainer

Feel free to open issue and pull requests. Any feedback is highly appreciated!

Be sure to follow our Community Guidelines when submitting your PR and interacting with other folks in this repository.

📈 Star History

Star History Chart

✨ Contributors

Thanks goes to these wonderful people (emoji key):

Xudong Guo
Xudong Guo

💻 📖 🚧
Cheng Wang
Cheng Wang

💻
Neko Ayaka
Neko Ayaka

💻
l1b0k
l1b0k

💻
Zhizhen He
Zhizhen He

💻
Hang Yu
Hang Yu

💻
dennislapchenko
dennislapchenko

💻
cnfatal
cnfatal

💻
Se7en
Se7en

💻 📖
Yarden Shoham
Yarden Shoham

💻 ⚠️ 📖
Vimsucks
Vimsucks

💻
Shunsuke Suzuki
Shunsuke Suzuki

💻
YS Liu
YS Liu

💻
Sarun Nuntaviriyakul
Sarun Nuntaviriyakul

💻
Max Anderson
Max Anderson

💻
Mario Fritschen
Mario Fritschen

💻
Jia Sui
Jia Sui

💻
AdamRussak
AdamRussak

💻
Rui Chen
Rui Chen

🚇
Michael Burman
Michael Burman

🐛 💻
Jan-Otto Kröpke
Jan-Otto Kröpke

💻
yxxhero
yxxhero

💻
Add your contributions

This project follows the all-contributors specification. Contributions of any kind welcome!

🍻 Acknowledgement

JetBrains logo

kubecm's People

Contributors

adamrussak avatar allcontributors[bot] avatar astraw99 avatar burmanm avatar chenrui333 avatar cnfatal avatar cr7258 avatar dennislapchenko avatar dependabot[bot] avatar futuretea avatar guyzsarun avatar hezhizhen avatar jkroepke avatar jsfaint avatar l1b0k avatar mario-f avatar maxanderson95 avatar nekomeowww avatar seanly avatar sunny0826 avatar suzuki-shunsuke avatar vimsucks avatar yardenshoham avatar yxxhero avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

kubecm's Issues

kubecm uses wrong user and cluster name

kube cm adds the cluster with wrong cluster name and wrong user name:

image

kubecm uses the wrong names cluster-95ct8cddbt and user-95ct8cddbt instead of the correct names k3d-testkube and admin@k3d-testkube

Here is original kubeconfig:

---
apiVersion: v1
clusters:
  - cluster:
      certificate-authority-data: DATA+OMITTED
      server: REDACTED
    name: k3d-testkube
contexts:
  - context:
      cluster: k3d-testkube
      user: admin@k3d-testkube
    name: k3d-testkube
current-context: k3d-testkube
kind: Config
preferences: {}
users:
  - name: admin@k3d-testkube
    user:
      client-certificate-data: REDACTED
      client-key-data: REDACTED

Here is after kubecm add -f:

apiVersion: v1
clusters:
- cluster:
    certificate-authority-data: DATA+OMITTED
    server: REDACTED
  name: cluster-95ct8cddbt # wrong
contexts:
- context:
    cluster: cluster-95ct8cddbt # wrong
    user: user-95ct8cddbt # wrong
  name: k3d-testkube
current-context: ""
kind: Config
preferences: {}
users:
- name: user-95ct8cddbt # wrong
  user:
    client-certificate-data: REDACTED
    client-key-data: REDACTED

[bug] fish shell completion throw error

@sunny0826 Tested and still having the issue.

Builded using a clean Linux env and a fresh fish installation:

`vscode@a71fb1df192a /w/kubecm (dependabot/go_modules/github.com/spf13/cobra-1.4.0)> ./kubecm math: Error: Unexpected tokenish/completions/kubecm.fish
'ompletion ended with directive: ShellCompDirectiveNoFileComp / 1'
^
math: Error: Unexpected token
'% 2'
^
test: Missing argument at index 2

~/.config/fish/completions/kubecm.fish (line 93):
if test $compErr -eq 1
^
in function '__kubecm_prepare_completions'
in command substitution

(Type 'help test' for related documentation)
math: Error: Unexpected token
'ompletion ended with directive: ShellCompDirectiveNoFileComp / 8'
^
math: Error: Unexpected token
'% 2'
^
math: Error: Unexpected token
'ompletion ended with directive: ShellCompDirectiveNoFileComp / 16'
^
math: Error: Unexpected token
'% 2'
^
test: Missing argument at index 2

~/.config/fish/completions/kubecm.fish (line 101):
if test $filefilter -eq 1; or test $dirfilter -eq 1
^
in function '__kubecm_prepare_completions'
in command substitution

(Type 'help test' for related documentation)
test: Missing argument at index 2

~/.config/fish/completions/kubecm.fish (line 101):
if test $filefilter -eq 1; or test $dirfilter -eq 1
^
in function '__kubecm_prepare_completions'
in command substitution

(Type 'help test' for related documentation)
math: Error: Unexpected token
'ompletion ended with directive: ShellCompDirectiveNoFileComp / 2'
^
math: Error: Unexpected token
'% 2'
^
math: Error: Unexpected token
'ompletion ended with directive: ShellCompDirectiveNoFileComp / 4'
^
math: Error: Unexpected token
'% 2'
^
test: Missing argument at index 2

~/.config/fish/completions/kubecm.fish (line 117):
if test $nospace -ne 0; or test $nofiles -eq 0
^
in function '__kubecm_prepare_completions'
in command substitution

(Type 'help test' for related documentation)
test: Missing argument at index 2

~/.config/fish/completions/kubecm.fish (line 117):
if test $nospace -ne 0; or test $nofiles -eq 0
^
in function '__kubecm_prepare_completions'
in command substitution

(Type 'help test' for related documentation)`

The same results using MacOs

Originally posted by @interpeix in #76 (comment)

Support stdin kubeconfig for add command

Is your feature request related to a problem? Please describe.
Potentially, but likely not. Immutable workstations may have issue downloading files, something like this could also be used to generate a dynamic kubeconfig to be consumed by another tool

Describe the solution you'd like
Using MacOS terminal as an example, I'd like to use pbpaste or similar utility (echo) to feed a kubeconfig to kubecm add from stdin.

Describe alternatives you've considered
pbpaste can be used to output to a file that can then be read into kubecm add using the previous example. However, this doesn't flow as well and other K8S utilities make use of piping natively which would enable this utility to become part of that flow. See Carvel's toolsuite for an example (heavily used in VMware's TKG products as a replacement for helm with many extra features).

Additional context
For Rancher products, this would make for a very useful utility in copy-pasting kubeconfigs from the Rancher Server UI without needing to download the file itself

list 问题

invalid configuration: no configuration has been provided, try setting KUBERNETES_MASTER environment variable

Need to change the tar name format to make it consistent with the `.krew.yaml`

Describe the bug
In the .krew.yaml, the release download url is:

https://github.com/sunny0826/kubecm/releases/download/{{ .TagName }}/kubecm_{{ .TagName }}_Linux_x86_64.tar.gz

But currently, our release url is:

https://github.com/sunny0826/kubecm/releases/download/v0.19.3/kubecm_0.19.3_Linux_x86_64.tar.gz

So we need to change the kubecm_0.19.3 to kubecm_v0.19.3 to make it consistent.

Support for multiple shells.

Feature Request
if you work with multiple clusters, you often want to associate one terminal window to a cluster. With kubectx and many other tools including kubecm this is not possible. A few tools where this is possible, they use subshells, which has its set of issues.

Describe the solution you'd like
it should be possible to have multiple shells that use different Kubernetes contexts

Describe alternatives you've considered
I am currently using a combination of different tools to accomplish this.
kubens and https://github.com/danielfoehrKn/kubeswitch

Additional context
Add any other context or screenshots about the feature request here.

[Help Wanted] Test completions command

The shell completions for fish and PowerShell have been added in v0.16.2, but I don't have the appropriate environment to test if they work. If you are using kubcm and are using fish or PowerShell, please help to test if this feature is available. Please provide feedback in this issue, thank!

The shell completions feature is a function that allows the user to use the <TAB> key to automatically complete commands when using kubecm, and will not affect the normal use of kubecm if this feature is not available.

[bug] zsh shell completion throw error

Hi, i noticed this issue is only for fish and powershell but I have some problems with completion also on zsh.
For example on tab after kubecm I get that last option:

11:32  76% ❯ kubecm
add                                                            -- Add KubeConfig to $HOME/.kube/config
alias                                                          -- Generate alias for all contexts
clear                                                          -- Clear lapsed context, cluster and user
completion                                                     -- Generate completion script
create                                                         -- Create new KubeConfig(experiment)
delete                                                         -- Delete the specified context from the kubeconfig
help                                                           -- Help about any command
list                                                           -- List KubeConfig
merge                                                          -- Merge the KubeConfig files in the specified directory
namespace                                                      -- Switch or change namespace interactively
rename                                                         -- Rename the contexts of kubeconfig
switch                                                         -- Switch Kube Context interactively
version                                                        -- Print version info
:4                                                             Completion ended with directive: ShellCompDirectiveNoFileComp

It also happen with any other commands but the error is sometime different:

11:32  76% ❯ kubecm list
:0                                                          Completion ended with directive: ShellCompDirectiveDefault

I enabled the completion with kubecm completion zsh > "${fpath[1]}/_kubecm" and zsh version is zsh 5.8 (x86_64-ubuntu-linux-gnu), don't know if it matters but I also use oh-my-zsh.

Originally posted by @gpstuff in #76 (comment)

Problem with add and merge

Describe the bug
When merging 2 configs or adding a config, the name is not preserved

To Reproduce
I have a cluster
+------------+---------+------------+ .....
|..CURRENT...|....NAME...|...CLUSTER..| .....
+=========+=======+=========+ .....
| ....................|..test-vm..|...test-vm.....| .....

When adding a second config via kubecm add -f /tmp/config or kubecm merge "~/.kube/config" /tmp/config -y the name (context) of the first cluster is changed to config

+------------+---------+------------+ .....
|..CURRENT...|....NAME...|...CLUSTER..| .....
+=========+=======+=========+ .....
| ....................|...config...|...test-vm.....| .....
+------------+---------+------------+ .....
| ....................|..cluster2.|....cluster2....| .....

Expected behavior
It should not rename the cluster config name

Desktop (please complete the following information):

  • OS: MacOS
  • Version Ventura 13.0.1

Thanks!

Feature Request: Manage kubeconfig with public cloud

As i'm using many cluster in AlibabaCloud , it would be easier to manage kubeconfig directly from API, other than manually config all kubeconfig.

kubecm 可以直接管理公有云上集群的 kubeconfig,
下面一点想法

kubecm list --provider=alibabacloud
kubecm switch --provider=alibabacloud {cluster_id}

阿里云可以通过下面两个API 达成

  • acs/api/v1/clusters.json 集群列表
  • acs/k8s/{cluster_id}/user_config kubeconfig

panic: runtime error: invalid memory address or nil pointer dereference

初次使用,添加一个config成功后,再次添加开始报错,kubecm ls也报,如下:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x10 pc=0x1ea0aa5]

goroutine 1 [running]:
github.com/sunny0826/kubecm/cmd.Formatable(0xc0002d2c50, 0xc000127d58)
/github/workspace/cmd/utils.go:97 +0x285
github.com/sunny0826/kubecm/cmd.(*ListCommand).runList(0xc0002bf570, 0xc000263b80, 0x2b28a18, 0x0, 0x0, 0x0, 0x0)
/github/workspace/cmd/list.go:30 +0x26
github.com/sunny0826/kubecm/cmd.(*ListCommand).Init.func1(0xc000263b80, 0x2b28a18, 0x0, 0x0, 0x0, 0x0)
/github/workspace/cmd/list.go:22 +0x52
github.com/spf13/cobra.(*Command).execute(0xc000263b80, 0x2b28a18, 0x0, 0x0, 0xc000263b80, 0x2b28a18)
/go/pkg/mod/github.com/spf13/[email protected]/command.go:842 +0x47c
github.com/spf13/cobra.(*Command).ExecuteC(0xc0002622c0, 0x10449b7, 0x2a847a0, 0xc000058778)
/go/pkg/mod/github.com/spf13/[email protected]/command.go:950 +0x375
github.com/spf13/cobra.(*Command).Execute(...)
/go/pkg/mod/github.com/spf13/[email protected]/command.go:887
main.main()
/github/workspace/main.go:27 +0x36

kubecm merge faild !

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. kubecm merge -f directory
  2. see error
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x10 pc=0x1535162]

goroutine 1 [running]:
k8s.io/client-go/tools/clientcmd/api/v1.autoConvert_api_AuthInfo_To_v1_AuthInfo(0x1f130c0, 0x0, {0x2283cb8, 0xc000610240})
	/go/pkg/mod/k8s.io/[email protected]/tools/clientcmd/api/v1/zz_generated.conversion.go:196 +0x22
k8s.io/client-go/tools/clientcmd/api/v1.Convert_api_AuthInfo_To_v1_AuthInfo(...)
	/go/pkg/mod/k8s.io/[email protected]/tools/clientcmd/api/v1/zz_generated.conversion.go:225
k8s.io/client-go/tools/clientcmd/api/v1.Convert_Map_string_To_Pointer_api_AuthInfo_To_Slice_v1_NamedAuthInfo(0xc000612158, 0xc0001ca318, {0x2283cb8, 0xc000610240})
	/go/pkg/mod/k8s.io/[email protected]/tools/clientcmd/api/v1/conversion.go:93 +0x270
k8s.io/client-go/tools/clientcmd/api/v1.autoConvert_api_Config_To_v1_Config(0xc000612120, 0xc0001ca2c0, {0x2283cb8, 0xc000610240})
	/go/pkg/mod/k8s.io/[email protected]/tools/clientcmd/api/v1/zz_generated.conversion.go:323 +0x99
k8s.io/client-go/tools/clientcmd/api/v1.Convert_api_Config_To_v1_Config(...)
	/go/pkg/mod/k8s.io/[email protected]/tools/clientcmd/api/v1/zz_generated.conversion.go:338
k8s.io/client-go/tools/clientcmd/api/v1.RegisterConversions.func8({0x1f8a8a0, 0xc000612120}, {0x1f8a960, 0xc0001ca2c0}, {0x2283cb8, 0xc000610240})
	/go/pkg/mod/k8s.io/[email protected]/tools/clientcmd/api/v1/zz_generated.conversion.go:74 +0x65
k8s.io/apimachinery/pkg/conversion.(*Converter).Convert(0xc000265290, {0x1f8a8a0, 0xc000612120}, {0x1f8a960, 0xc0001ca2c0}, 0xc000610230)
	/go/pkg/mod/k8s.io/[email protected]/pkg/conversion/converter.go:221 +0x3a3
k8s.io/apimachinery/pkg/runtime.(*Scheme).convertToVersion(0xc0002689a0, 0x0, {0x2284000, 0xc000612120}, {0x2284ca8, 0xc0001b9a80})
	/go/pkg/mod/k8s.io/[email protected]/pkg/runtime/scheme.go:540 +0xe1b
k8s.io/apimachinery/pkg/runtime.(*Scheme).UnsafeConvertToVersion(...)
	/go/pkg/mod/k8s.io/[email protected]/pkg/runtime/scheme.go:467
k8s.io/apimachinery/pkg/runtime.unsafeObjectConvertor.ConvertToVersion({0xc0002689a0}, {0x2284000, 0xc000612120}, {0x2284ca8, 0xc0001b9a80})
	/go/pkg/mod/k8s.io/[email protected]/pkg/runtime/helper.go:39 +0x3b
k8s.io/apimachinery/pkg/runtime/serializer/versioning.(*codec).doEncode(0xc000251180, {0x2284000, 0xc000612120}, {0x226dec0, 0xc0004ec1e0})
	/go/pkg/mod/k8s.io/[email protected]/pkg/runtime/serializer/versioning/versioning.go:232 +0x7fc
k8s.io/apimachinery/pkg/runtime/serializer/versioning.(*codec).Encode(0xc000251180, {0x2284000, 0xc000612120}, {0x226dec0, 0xc0004ec1e0})
	/go/pkg/mod/k8s.io/[email protected]/pkg/runtime/serializer/versioning/versioning.go:184 +0x106
k8s.io/apimachinery/pkg/runtime.Encode({0xb315008, 0xc000251180}, {0x2284000, 0xc000612120})
	/go/pkg/mod/k8s.io/[email protected]/pkg/runtime/codec.go:50 +0x64
k8s.io/client-go/tools/clientcmd.Write(...)
	/go/pkg/mod/k8s.io/[email protected]/tools/clientcmd/loader.go:466
k8s.io/client-go/tools/clientcmd.WriteToFile({{0x0, 0x0}, {0x0, 0x0}, {0x0, 0xc0004ec2d0}, 0xc0004ec300, 0xc0004ec330, 0xc0004ec360, {0x0, ...}, ...}, ...)
	/go/pkg/mod/k8s.io/[email protected]/tools/clientcmd/loader.go:419 +0x9e
github.com/sunny0826/kubecm/cmd.WriteConfig(0xb0, {0x7ff7bfeff8a2, 0x1f}, 0xc0004d5980)
	/github/workspace/cmd/utils.go:265 +0xa5
github.com/sunny0826/kubecm/cmd.MergeCommand.runMerge({{0x11848a0}}, 0xc000207d88, {0xc000207d60, 0x0, 0x0})
	/github/workspace/cmd/merge.go:64 +0x386
github.com/sunny0826/kubecm/cmd.(*MergeCommand).Init.func1(0xc00043d400, {0xc0003dd8c0, 0x2, 0x2})
	/github/workspace/cmd/merge.go:28 +0x34
github.com/spf13/cobra.(*Command).execute(0xc00043d400, {0xc0003dd880, 0x2, 0x2})
	/go/pkg/mod/github.com/spf13/[email protected]/command.go:856 +0x60e
github.com/spf13/cobra.(*Command).ExecuteC(0xc00043c500)
	/go/pkg/mod/github.com/spf13/[email protected]/command.go:974 +0x3bc
github.com/spf13/cobra.(*Command).Execute(...)
	/go/pkg/mod/github.com/spf13/[email protected]/command.go:902
main.main()
	/github/workspace/main.go:29 +0x25

System Version:
Mac OS Monterey 12.0.1 (21A559)

Kubecm Version:
Version: 0.16.2
GoOs: darwin
GoArch: amd64

kubecm ls filter

不知道能不能支持,根据自定义的 filter ,过滤某些集群?

Feature request

Hi,

Me again :)

Please consider expanding kubecm with additional functionality specially useful when using aliases:

  kubecm {context,c} <NAME>  (to easily switch to context <NAME>)
  kubecm {context,c} -       (to quickly switch to the previous context)
  kubecm {context,c}         (to quickly find out the current context name. Optionally maybe a flag like --current could be useful)

% kubecm version
Version: 0.13.0
GoOs: darwin
GoArch: amd64

Thanks! 🙏

[Proposal]add cmd: alias

add alias cmd, generate alias for all contexts.And then, you can operate the cluster by alias cmd without switching context.

$ kubecm alias
# dev 
alias k-dev='kubectl --context dev'
# test
alias k-test='kubectl --context test'
# prod
alias k-prod='kubectl --context prod'
$ kubecm alias -o zsh
# add context to ~/.zshrc
$ kubecm alias -o bash
# add context to ~/.bash_profile

example:

$ k-dev get pod
# print pod of dev cluster 

更新到最新版本后merge错误

image
更新到最新版本后,不支持merge的-c参数了。去除-c参数,合并后kubeconfig是错的,server全是一个。查了下合并后的kubeconfig,确实不对。

文件解压缩时报错

gzip: stdin: not in gzip format
tar: Child returned status 1
tar: Error is not recoverable: exiting now

MAC 安装报错

brew install sunny0826/tap/kubecm
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 2 taps (homebrew/core and homebrew/cask).
==> Updated Formulae
arduino-cli jenkins nim open-babel phpunit watchexec
==> minikube has been moved to Homebrew.
To uninstall the cask run:
brew cask uninstall --force minikube
==> Installing minikube...
==> Downloading https://homebrew.bintray.com/bottles/minikube-1.5.0.mojave.bottle.tar.gz
==> Downloading from https://akamai.bintray.com/15/157d59038a69e69178185216cf9bc0f06f7d029ed31ee8598da72f98f367b86c?__gda__=exp=1572328857~hmac=03e5fe9aa36d09059156d2b88ec1cb224143d5f0
######################################################################## 100.0%
==> Pouring minikube-1.5.0.mojave.bottle.tar.gz
==> minikube cask is installed, skipping link.
==> Caveats
Bash completion has been installed to:
/usr/local/etc/bash_completion.d

zsh completions have been installed to:
/usr/local/share/zsh/site-functions
==> Summary
🍺 /usr/local/Cellar/minikube/1.5.0: 8 files, 61.1MB
Linking /usr/local/Cellar/minikube/1.5.0... 3 symlinks created

==> Tapping sunny0826/tap
Cloning into '/usr/local/Homebrew/Library/Taps/sunny0826/homebrew-tap'...
remote: Enumerating objects: 8, done.
remote: Counting objects: 100% (8/8), done.
remote: Compressing objects: 100% (8/8), done.
remote: Total 8 (delta 0), reused 4 (delta 0), pack-reused 0
Unpacking objects: 100% (8/8), done.
Error: Invalid formula: /usr/local/Homebrew/Library/Taps/sunny0826/homebrew-tap/kubecm.rb
kubecm: undefined method updatetime' for #<Class:0x00007fc9ce29a500> Error: Invalid formula: /usr/local/Homebrew/Library/Taps/sunny0826/homebrew-tap/hamal.rb hamal: undefined method updatetime' for #Class:0x00007fc9ce298638
Error: Cannot tap sunny0826/tap: invalid syntax in tap!

kubecm delete interactively exit.

Thank you for the great tool!
But, when I run kubecm delete, if I don't want delete a context, the tools can't exit as normal. I've to press 'ctrl+c'. Just some inconvenience.

Disable notifications on macOS

With version 0.20.0 a new feature was added to present a macOS notification if a command was successful. It would be nice, if there would be a setting to disable this feature.

The PR was: #518

Error: no Auth Provider found for name "gcp"

Hi,

I got this error message when trying to list the namespaces of my GKE cluster; please find below a sanitised version of ~/.kube/config:

% cat ~/.kube/config
apiVersion: v1
clusters:
- cluster:
    certificate-authority-data: blah
    server: https://localhost:6443
  name: default
- cluster:
    certificate-authority-data: blah
    server: https://1.2.3.4
  name: gke_cluster
contexts:
- context:
    cluster: gke_cluster
    namespace: default
    user: gke_cluster
  name: gke_cluster
- context:
    cluster: default
    user: default
  name: minikube
current-context: gke_cluster
kind: Config
preferences: {}
users:
- name: default
  user:
    password: blah
    username: blah
- name: gke_cluster
  user:
    auth-provider:
      config:
        access-token: token_blah
        cmd-args: config config-helper --format=json
        cmd-path: /Users/cig0/Applications/google-cloud-sdk/bin/gcloud
        expiry: "blah"
        expiry-key: '{.credential.token_expiry}'
        token-key: '{.credential.access_token}'
      name: gcp

It is worth noting that I'm able to work with this context/cluster using kubectl or other CLI tools.

% kubecm version
Version: 0.13.0
GoOs: darwin
GoArch: amd64

Thanks! 🙏

[feature] merge command support for multiple file input

Overview

The merge command currently only supports merging kubeconfig within a folder. support is needed for merging multiple files as specified, e.g.

kubecm merge 1st-kind.yaml 2nd-kind.yaml 3rd-kind.yaml

TBD

  • multiple file input support
  • add merge command e2e test

binary naming convention

Description

Noticed that the binary naming is changed since the last release, from kubecm_0.19.2_Darwin_arm64.tar.gz to kubecm_v0.19.3_Darwin_arm64.tar.gz, the difference is the char v in the version.

Was the change intentional or is it a bug?

It broke our end-to-end test suite in arkade which features your project.

If the change was intentional please let me know and I'll submit a PR in arkade, elsewise I'm more then happy to fix this behaviour in your project!

feature request: switch default namespace.

I usually use kucectx and kubens to switch default context and default namespace.
Now kubecm support switch context, I hope it can support switch default namespace.
BTW, swictch command can;t support more sub-command to quickly switch with context name.
just like kubecm switch my-context.

list按名称排序

工作用的集群比较多,一般以名称区分不同账户不同地域,所以能否在switch时按照名字排序?

kubecm completion bash adds unrelated strings to output

When you execute: kubecm completion bash
it adds "A new release..." unrelated strings to the end of bash completion output:

...
if [[ $(type -t compopt) = "builtin" ]]; then
    complete -o default -F __start_kubecm kubecm
else
    complete -o default -o nospace -F __start_kubecm kubecm
fi

# ex: ts=4 sw=4 et filetype=sh


A new release of kubecm is available: dev → 0.19.1
To upgrade, run: brew update && brew upgrade kubecm
https://github.com/sunny0826/kubecm/releases/tag/v0.19.1

if you use brew install kubecm, then brew uses output of kubecm completion bash to generate bash completion script.

So you got:

A new release of kubecm is available: dev → 0.19.1
To upgrade, run: brew update && brew upgrade kubecm
https://github.com/sunny0826/kubecm/releases/tag/v0.19.1

into end of your bash completion script for kubecm.

So when you start your terminal you see something like:

-bash: $'\E[0': command not foundug 2022 at 11:29
-bash: 33mA: command not found
-bash: $'36mdev\E[0m': command not found
-bash: $'32m0.19.1\E[0m': command not found
-bash: $'\E[0': command not found
-bash: 33mhttps://github.com/sunny0826/kubecm/releases/tag/v0.19.1: No such file or directory

because bash completion tries to execute:

�[0;33mA new release of kubecm is available:�[0m �[0;36mdev�[0m ‚Üí �[0;32m0.19.1�[0m
�[0;33mhttps://github.com/sunny0826/kubecm/releases/tag/v0.19.1�[0m

in the end of kubecm bash completion script.

desired behavior - no extra lines unrelated to bash completion script added to the output of kubecm completion bash output.

delete lead to panic

「xx」 write successful!
+------------+-----------+-----------------------+--------------------+------------------------------+--------------+
|   CURRENT  |    NAME   |        CLUSTER        |        USER        |            SERVER            |   Namespace  |
+============+===========+=======================+====================+==============================+==============+
|            |   2123d   |   cluster-46gc56tgt8  |   user-46gc56tgt8  |   https://xxx  |    default   |
+------------+-----------+-----------------------+--------------------+------------------------------+--------------+
|            |    1234   |   cluster-46gc56tgt8  |   user-46gc56tgt8  |   https://xxx  |    default   |
+------------+-----------+-----------------------+--------------------+------------------------------+--------------+
|            |   xassss  |   cluster-46gc56tgt8  |   user-46gc56tgt8  |   https://xxx  |    default   |
+------------+-----------+-----------------------+--------------------+------------------------------+--------------+

❯ ./main delete
😸 Select:2123d
👻 True
Context Delete:「2123d」
「/Users/root/.kube/config」 write successful!
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x10 pc=0x1eab718]

goroutine 1 [running]:
github.com/sunny0826/kubecm/cmd.PrintTable(0xc0004105a0, 0xc0001a8008, 0x212e220)
        /Users/root/projects/kubecm/cmd/utils.go:93 +0x178
github.com/sunny0826/kubecm/cmd.WriteConfig(0xc000219d01, 0xc000324c20, 0x17, 0xc0004105a0, 0x0, 0x0)
        /Users/root/projects/kubecm/cmd/utils.go:230 +0x16f
github.com/sunny0826/kubecm/cmd.(*DeleteCommand).runDelete(0xc0003bf558, 0xc000360dc0, 0x2b43b60, 0x0, 0x0, 0x0, 0x0)
        /Users/root/projects/kubecm/cmd/delete.go:56 +0x165
github.com/sunny0826/kubecm/cmd.(*DeleteCommand).Init.func1(0xc000360dc0, 0x2b43b60, 0x0, 0x0, 0x0, 0x0)
        /Users/root/projects/kubecm/cmd/delete.go:25 +0x52
github.com/spf13/cobra.(*Command).execute(0xc000360dc0, 0x2b43b60, 0x0, 0x0, 0xc000360dc0, 0x2b43b60)
        /Users/root/go/pkg/mod/github.com/spf13/[email protected]/command.go:842 +0x47c
github.com/spf13/cobra.(*Command).ExecuteC(0xc0003602c0, 0x1046d17, 0x2aa00c0, 0xc000000180)
        /Users/root/go/pkg/mod/github.com/spf13/[email protected]/command.go:950 +0x375
github.com/spf13/cobra.(*Command).Execute(...)
        /Users/root/go/pkg/mod/github.com/spf13/[email protected]/command.go:887
main.main()
        /Users/root/projects/kubecm/main.go:27 +0x36

Repeated printing of error messages

If kubeconfig does not have permission to query the componentstatuses API, it will return Error: Cluster check failure!, but will throw the error message twice.

$ kc ls
...
Error: Cluster check failure!
componentstatuses is forbidden: User "guoxudong" cannot list resource "componentstatuses" in API group "" at the cluster scope
Usage:
  kubecm ls

Aliases:
  ls, l

Examples:

# List all the contexts in your kubeconfig file
kubecm ls
# Aliases
kubecm l
# Filter out keywords(Multi-keyword support)
kubecm ls kind k3s


Flags:
  -h, --help   help for ls

Global Flags:
      --config string   path of kubeconfig (default "/Users/xxx/.kube/config")

Cluster check failure!
componentstatuses is forbidden: User "guoxudong" cannot list resource "componentstatuses" in API group "" at the cluster scope

404 got on the bottom link of the introduction page

Describe the bug

On the introduction page, the bottom link [CLI References](https://kubecm.cloud/en-us/cli/kubecm_add) just redirect to 404.
But it works ok to click from the menu tab add. May be it is a frontend redirect issue.

Both the en and zh pages need to fix.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.