Skip to content

kuberenetes-learning-group/kubectl-plugin-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

Kubectl Plugin Demo

使用方式

curl -O https://raw.githubusercontent.com/kuberenetes-learning/kubectl-plugin-demo/master/kubectl-foo
sudo chmod +x ./kubectl-foo

sudo mv ./kubectl-foo /usr/local/bin

kubectl foo

Kubectl Plugin

Kebernetes源码解析

参考 source_code.md

要求

  1. 可执行文件
  2. 名称以kubectl-开头,命令以-来分割,比如kubectl gpu version的可执行文件名称是kubectl-gpu-version。命令名称中如果包含-,用_表示,比如kubectl gpu-version的可执行文件名称是kubectl-gpu_version
  3. 可执行文件位于PATH路径下
  4. 不能和kubectl命令或者子命令重复,比如kubectl version

注意

  1. Kubectl查找时按照最长匹配原则,比如存在kubectl-gpukubectl-gpu-version,那么输入kubectl gpu verson时执行的是kubectl-gpu-version

  2. 运行命令名称重复,但是只有一个会执行,具体哪个可以通过kubectl plugin list查看

kubectl plugin list
The following kubectl-compatible plugins are available:

/usr/local/bin/plugins/kubectl-foo
/usr/local/bin/moreplugins/kubectl-foo
  - warning: /usr/local/bin/moreplugins/kubectl-foo is overshadowed by a similarly named plugin: /usr/local/bin/plugins/kubectl-foo

error: one plugin warning was found

About

demo for kubectl command plugin

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages