跳至主要內容

kubectl 常用命令

Change Lee...小于 1 分钟容器k8s

给k8s集群中的node节点加标签

file
file

1.增加节点标签 备注 =:代表增加标签

kubectl label nodes node3 node-role.kubernetes.io/node3=

2.减少节点标签 备注 -:代表减少标签

kubectl label nodes node3 node-role.kubernetes.io/node3-

让Master 成为一个Node ,单机 ALL-IN-ONE 的 Kubernetes 环境。

#--all 代表所有node ,也可以指定单个node 的名称
kubectl taint nodes --all node-role.kubernetes.io/master-

bash 补全

yum install -y bash-completion
source /usr/share/bash-completion/bash_completion
source <(kubectl completion bash)
echo "source <(kubectl completion bash)" >> ~/.bashrc

未整理

#将pod 暴露为一个service ,使用node 的端口
kubectl expose pod nginx-7db9fccd9b-7n6dq --name nginx --port=8080 --target-port=80 --type=NodePort
#k8s 查看部署信息
kubeadm config view
#
kubectl get cm -o yaml -n kube-system kubeadm-config

kubectl get pod -o custom-columns=NAME:.metadata.name,CN:spec.containers[0].name

参考连接

kubectl技巧之通过jsonpath截取属性open in new window

上次编辑于:
贡献者: change,lichangyangccm@163.com
评论
  • 按正序
  • 按倒序
  • 按热度
Powered by Waline v3.1.3