Code Monkey home page Code Monkey logo

kubectl-plugin-develop's Introduction

kubectl-插件开发

本项目为主要开发poddeployment项目。

子项目在目录:kubectl-plugin-develop/test_plugin/ 子项目是对常见资源的list操作开发。

基本方法

1. 写个可执行程序(先执行chmod +x xxxx),并放到PATH目录下。  
2. 文件名必须是kubectl-xxxx
3. 放入/local/bin下
3、kubectl plugin list    ---验证一下

对kubectl进行简易插件化开发

1. 本地编译

本地编译
go build -o kubectl-pods .
chmod 777 kubectl-pods
mv kubectl-pods ~/go/bin/

2. pod

命令示范
1. kubectl list pods
2. kubectl list pods --show-labels
3. kubectl list pods --show-labels --feilds "spec.nodeName=aa"
4. kubectl list pods --show-labels --labels "app=aa"
5. kubectl pods prompt 交互式
(base) xxxxxMacBook-Pro:kubectl_plugin_develop zhenyu.jiang$ kubectl pods prompt
>>> list
从缓存取
POD名称                         NAMESPACE       POD IP          状态    
hello-world-68fdbf5747-679dk    default         172.17.0.7      Running 
hello-world-68fdbf5747-w789w    default         172.17.0.4      Running 
hello-world-1-745964bf47-8wst8  default         172.17.0.2      Running 
hello-world-1-745964bf47-m7m4w  default         172.17.0.3      Running 
>>> get h (只要打出h就会显示如下)
          hello-world-68fdbf5747-w789w    节点:minikube 状态:Running IP:172.17.0.4  
          hello-world-1-745964bf47-8wst8  节点:minikube 状态:Running IP:172.17.0.2  
          hello-world-1-745964bf47-m7m4w  节点:minikube 状态:Running IP:172.17.0.3  
          hello-world-68fdbf5747-679dk    节点:minikube 状态:Running IP:172.17.0.7

补充

fields 字段的限制

metadata.name
metadata.namespace
spec.nodeName
spec.restartPolicy
spec.serviceAccountName
status.phase
status.podIP
status.podIPs
status.nominatedNodeName

kubectl-plugin-develop's People

Contributors

googs1025 avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Forkers

okeas

kubectl-plugin-develop's Issues

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.