当前位置:网站首页>Expand your kubecl function
Expand your kubecl function
2022-07-04 23:28:00 【InfoQ】
kubectl
kubectl
get
proxy
kubectl
kubectl
kubectl
kubectl
kubectl
git
krew
kubectl
- Execute at the terminal (Bash perhaps Zsh) perform
(
set -x; cd "$(mktemp -d)" &&
OS="$(uname | tr '[:upper:]' '[:lower:]')" &&
ARCH="$(uname -m | sed -e 's/x86_64/amd64/' -e 's/\(arm\)\(64\)\?.*/\1\2/' -e 's/aarch64$/arm64/')" &&
KREW="krew-${OS}_${ARCH}" &&
curl -fsSLO "https://github.com/kubernetes-sigs/krew/releases/latest/download/${KREW}.tar.gz" &&
tar zxvf "${KREW}.tar.gz" &&
./"${KREW}" install krew
)
- take$HOME/.krew/binAdd toPATHenvironment variable , Update your.bashrcperhaps.zshrcfile , Add the following line
export PATH="${KREW_ROOT:-$HOME/.brew}/bin:$PATH"
- testkrewInstalled successfully
* k krew version
OPTION VALUE
GitTag v0.4.3
GitCommit dbfefa5
IndexURI https://github.com/kubernetes-sigs/krew-index.git
BasePath /home/mengz/.krew
IndexPath /home/mengz/.krew/index/default
InstallPath /home/mengz/.krew/store
BinPath /home/mengz/.krew/bin
DetectedPlatform linux/amd64
- ( Optional ) Set up krew Alias
alias krew='kubectl-krew'
echo "alias krew='kubectl-krew'" >> ~/.alias
kubectl
krew
krew
krew
- List the currently installed plug-ins
* krew list
PLUGIN VERSION
krew v0.4.3
- Installing a plug-in ( Other plug-ins described below will be installed in this way )
* krew install [ The plugin name ]
- Update the local plug-in index ( Check whether there are plug-in updates )
* krew update
Updated the local copy of plugin index.
New plugins available:
* liqo
* switch-config
Upgrades available for installed plugins:
* open-svc v2.5.2 -> v2.5.3
* rbac-tool v1.7.1 -> v1.8.0
* rolesum v1.5.1 -> v1.5.5
- Upgrade plug-ins
* krew upgrade open-svc
Updated the local copy of plugin index.
Upgrading plugin: open-svc
- Delete plug-ins
* krew uninstall [ The plugin name ]
kubectl
example
krew install example
example
* k example deploy
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
labels:
app: nginx
spec:
replicas: 3
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.14.2
ports:
- containerPort: 80
fleet
krew install fleet
fleet
* k fleet
CLUSTER VERSION NODES NAMESPACES PROVIDER API
homek8sc1 v1.23.8 3/3 4 ? https://k8sc1.mengz.lan:6443
api-sandbox-x8i5-p1-openshiftapps-com:6443 v1.23.5+9ce5071 ? ? ? https://api.sandbox.x8i5.p1.openshiftapps.com:6443
minikube v1.22.3 1/1 4 minikube https://192.168.64.3:8443
get-all
krew install get-all
get-all
* k get-all -n kube-system
NAME NAMESPACE AGE
configmap/calico-config kube-system 13d
configmap/coredns kube-system 13d
configmap/extension-apiserver-authentication kube-system 13d
configmap/kube-proxy kube-system 13d
configmap/kube-root-ca.crt kube-system 13d
configmap/kubeadm-config kube-system 13d
configmap/kubelet-config-1.23 kube-system 13d
endpoints/kube-dns kube-system 13d
...
htpasswd
krew install htpasswd
htpasswd
* k htpasswd create aaa-basic-auth user1=user1password user2=user2password -o yaml --dry-run
apiVersion: v1
data:
auth: dXNlcjE6JDJhJDEwJDVNeEJGT3lEUEJYT0xkUldlblNWME91RGtZTzFQOElJNXJuRnh5blpUdC55L2FUUUNDYzJ1CnVzZXIyOiQyYSQxMCRVbFdHOG5NTU4zRGVpOC5GMmVRM3EuYWhxTENYZGtLYUJ1cXZzT3lEOGl0ODJRdU4zV1c1dQ==
kind: Secret
metadata:
creationTimestamp: null
name: aaa-basic-auth
namespace: default
type: Opaque
images
krew install images
images
* k images
[Summary]: 1 namespaces, 2 pods, 2 containers and 1 different images
+------------------------+---------------+-------------------+
| PodName | ContainerName | ContainerImage |
+------------------------+---------------+-------------------+
| webapp-98f7444c5-8772w | nginx | nginx:1.21-alpine |
+------------------------+ + +
| webapp-98f7444c5-vsxr9 | | |
+------------------------+---------------+-------------------+
ktop
krew install ktop
ktop
* k ktop
┌ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─
│ API server: https://k8sc1.mengz.lan:6443 Version: v1.23.8 context: [email protected] User: kubernetes-admin namespace: (all) metrics: not connected v0.3.0
└ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─
╔ Cluster Summary ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═
║ ptime: 13d Nodes: 3 Namespaces: 4 Pods: 15/15 (20 imgs) Deployments: 5/5 Sets: replicas 5, daemons 6, stateful 0 Jobs: 0 (cron: 0) PVs: 0 (0Gi) PVCs: 0 (0Gi)
║ PU: [||||||||||| ] 1600m/6000m (26.7% requested) Memory: [|| ] 1Gi/11Gi (2.5% requested)
╚ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═
┌ Nodes (3) ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─
│ NAME STATUS AGE VERSION INT/EXT IPs OS/ARC PODS/IMGs DISK CPU MEM
│ homek8sc1-control Ready 13d v1.23.8 192.168.0.140/<none> Ubuntu 20.04.4 LTS/amd64 9/10 16Gi [|||||| ] 1100m/2000m (55%) [|| ] 1Gi/2Gi (13%)
│ homek8sc1-worker1 Ready 13d v1.23.8 192.168.0.141/<none> Ubuntu 20.04.4 LTS/amd64 3/5 16Gi [|| ] 250m/2000m (12%) [ ] 0Gi/5Gi (0%)
│ homek8sc1-worker2 Ready 13d v1.23.8 192.168.0.142/<none> Ubuntu 20.04.4 LTS/amd64 3/5 16Gi [|| ] 250m/2000m (12%) [ ] 0Gi/5Gi (0%)
│
└ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─
┌ Pods (15) ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
│ AMESPACE POD READY STATUS RESTARTS AGE VOLS IP NODE CPU MEMORY
│ ube-system kube-controller-manager-homek8sc1-control 1/1 Running 1 13d 8/8 192.168.0.140 homek8sc1-control [| ] 200m 10.0% [ ] 0Gi 0.0%
│ ube-system kube-proxy-4c9nq 1/1 Running 2 13d 4/4 192.168.0.141 homek8sc1-worker1 [ ] 0m 0.0% [ ] 0Gi 0.0%
│ ube-system kube-proxy-4whcn 1/1 Running 1 13d 4/4 192.168.0.140 homek8sc1-control [ ] 0m 0.0% [ ] 0Gi 0.0%
│ ube-system kube-proxy-bz8lt 1/1 Running 3 13d 4/4 192.168.0.142 homek8sc1-worker2 [ ] 0m 0.0% [ ] 0Gi 0.0%
│ ube-system kube-scheduler-homek8sc1-control 1/1 Running 1 13d 1/1 192.168.0.140 homek8sc1-control [| ] 100m 5.0% [ ] 0Gi 0.0%
└ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─
summary
krew
- https://kubernetes.io/docs/tasks/extend-kubectl/kubectl-plugins/
- https://krew.sigs.k8s.io/docs/user-guide/quickstart/
边栏推荐
- ETCD数据库源码分析——处理Entry记录简要流程
- MariaDB的Galera集群-双主双活安装设置
- CTF競賽題解之stm32逆向入門
- Hong Kong Jewelry tycoon, 2.2 billion "bargain hunting" Giordano
- 金融市场,资产管理与投资基金
- PMP证书续证流程
- S32 Design Studio for ARM 2.2 快速入门
- Network namespace
- Examples of time (calculation) total tools: start time and end time of this year, etc
- Is the account opening link of Huatai Securities with low commission safe?
猜你喜欢
初试为锐捷交换机跨设备型号升级版本(以RG-S2952G-E为例)
Redis getting started complete tutorial: hash description
壁仞科技研究院前沿技术文章精选
可观测|时序数据降采样在Prometheus实践复盘
ECCV 2022 | Tencent Youtu proposed disco: the effect of saving small models in self supervised learning
Redis: redis transactions
CTF競賽題解之stm32逆向入門
Excel 快捷键-随时补充
Editplus-- usage -- shortcut key / configuration / background color / font size
Why does infographic help your SEO
随机推荐
C语言快速解决反转链表
[binary tree] the maximum difference between a node and its ancestor
cout/cerr/clog的区别
Servlet+jdbc+mysql simple web exercise
推荐收藏:跨云数据仓库(data warehouse)环境搭建,这货特别干!
快解析内网穿透帮助企业快速实现协同办公
Recommended collection: build a cross cloud data warehouse environment, which is particularly dry!
Stm32 Reverse Introduction to CTF Competition Interpretation
MariaDB的Galera集群-双主双活安装设置
【ODX Studio编辑PDX】-0.3-如何删除/修改Variant变体中继承的(Inherited)元素
Font design symbol combination multifunctional wechat applet source code
[ODX studio edit PDX] -0.3- how to delete / modify inherited elements in variant variants
[graph theory] topological sorting
【taichi】用最少的修改将太极的pbf2d(基于位置的流体模拟)改为pbf3d
取得PMP證書需要多長時間?
Intelligence test to see idioms guess ancient poems wechat applet source code
S32 design studio for arm 2.2 quick start
Mysql database backup and recovery -- mysqldump command
Mit-6.824-lab4b-2022 (10000 word idea explanation - code construction)
SPH中的粒子初始排列问题(两张图解决)