标签:net 应用 不可 处理 方式 clu pods Kubernete system
相关服务及用途节点名称 | 服务名称 | 用途 |
---|---|---|
管理节点 | kubctl-apiserver | 提供HTTP Rest统一接口服务,处理和验证REST请求和更新etcd中API对象的状态 |
管理节点 | kubectl-controller-manager | 资源控制管理同步 |
管理节点 | kube-scheduler | 负责资源调度(调度Pod) |
工作节点 | kubelet | 管理Pod的生命周期,创建、启停等任务 |
工作节点 | kube-proxy | 负责网络通信及负载均衡 |
### 1.重启服务
kubectl patch deployment app名称 -p {\"spec\":{\"template\":{\"metadata\":{\"labels\":{\"date\":\"date +‘%s‘
\"}}}}} -n kube-system
### 2.重新分配pod数量
kubectl scale deployment kubernetes-dashboard --replicas=1 -n kube-system
### 3.查看部署应用
kubectl get deploy -n kube-system
### 4.获得容器前一次运行的日志内容
kubectl logs --previous <Pod名称> <Pod中的容器名称>
kubectl logs --previous l7-lb-controller-74c67fb85d-5b5cg -n kube-system
### 5.查看描述
kubectl describe svc kubernetes-dashboard -n kube-system
kubectl describe pod kubernetes-dashboard -n kube-system
### 6.查看pod部署节点及IP
kubectl get pods -n kube-system -o wide
### 7.查看集群中服务
kubectl get services --all-namespaces
kubectl get svc kubernetes-dashboard -n kube-system
### 8.查看暴露端口
kubectl get endpoints -n kube-system kubernetes-dashboard
kubectl get ep -n kube-system kubernetes-dashboard
## 9.标签管理
kubectl label node 192.168.61.66 nodetype=node --overwrite
lsmod | grep ip_vs
kubectl get node --show-labels -n kube-system
kubectl get pods --show-labels kube-sytem
kubectl get pod --show-labels kubernetes-dashboard-6845889d64-25f9x -n kube-system
### 10.查看svc/pod描述
kubectl describe 类型 资源名称 命名空间
kubectl describe svc kubernetes-dashboard -n kube-system
kubectl describe pod kubernetes-dashboard -n kube-system
### 11.查询日志
kubectl logs -f pod名称 -n kube-system
kubectl exec -ti pod名称 /bin/bash -n kube-system
### 12.以yaml/json方式显示pod信息
kubectl get deployment -o yaml kubernetes-dashboard -n kube-system
kubectl get daemonset -o yaml -n kube-system calico-node
kubectl get svc -o json pod名称 -n kube-system
### 13.显示所有的服务
kubectl get deployments -n kube-system
kubectl get daemonsets -n kube-system
### 14.创建命名空间
kubectl create namespace new-namespace
cat > my-namespace.yaml << EOF
apiVersion: v1
kind: Namespace
metadata:
name: new-namespace
EOF
kubectl create -f ./my-namespace.yaml
kubectl delete namespaces new-namespace
### 15.创建/查看 Deployment 记录版本号
kubectl create -f nginx-deployment.yaml --record
### 16.实现水平扩展或收缩
kubectl scale deployment kubernetes-dashboard --replicas=2 -n kube-system
kubectl scale deployment kubernetes-dashboard --replicas=1 -n kube-system
### 17.版本回退
kubectl rollout status deployment/kubernetes-dashboard -n kube-system
kubectl rollout history deployment/kubernetes-dashboard -n kube-system
kubectl rollout history deployment/kubernetes-dashboard --revision=1 -n kube-system
kubectl rollout undo deployment/kubernetes-dashboard -n kube-system
kubectl rollout undo deployment/kubernetes-dashboard --to-revision=1 -n kube-system
### 18.自动扩展
kubectl autoscale deployment kubernetes-dashboard --min=1 --max=5 --cpu-percent=80 -n kube-system
kubectl get hpa kubernetes-dashboard -n kube-system
kubectl describe hpa kubernetes-dashboard -n kube-system
kubectl delete hpa kubernetes-dashboard -n kube-system
### 19.更新Deployment镜像
kubectl set image deployment kubernetes-dashboard nginx=nginx:1.9.1
### 20.编辑 Deployment pod配置
kubectl edit deployment kubernetes-dashboard -n kube-system
### 21.升级资源
kubectl rollout pause deployment kubernetes-dashboard -n kube-system
kubectl set image deploy kubernetes-dashboard nginx=nginx:1.9.1
kubectl set resources deployment kubernetes-dashboard -c=kubernetes-dashboard --limits=cpu=200m,memory=512Mi -n kube-system
kubectl rollout resume deploy kubernetes-dashboard -n kube-system
### 22.查看CIDR划分
kubectl get nodes -o json | jq ‘.items[] | .spec‘
## 23.授权管理
kubectl get certificatesigningrequests
kubectl get csr
kubectl get csr|grep ‘Pending‘ | awk ‘NR>0{print $1}‘| xargs kubectl certificate approve
for i in kubectl get csr|grep -v NAME|awk ‘{print $1}‘
;do kubectl certificate approve $i;done
kubectl get nodes
kubectl certificate deny node-csr-AzAMd7KYm57dUkiD-aM3POpS_N37bXCyHeI_B-llyQM
for i in kubectl get csr|grep -v NAME|awk ‘{print $1}‘
;do kubectl certificate deny $i;done
kubectl delete csr node-csr-AzAMd7KYm57dUkiD-aM3POpS_N37bXCyHeI_B-llyQM
for i in kubectl get csr|grep -v NAME|awk ‘{print $1}‘
;do kubectl delete csr $i;done
### 24.集群信息查看
curl -sSL https://dl.k8s.io/release/v1.11.2/bin/linux/amd64/kubeadm > /usr/bin/kubeadm
kubectl cluster-info
kubectl describe clusterrole cluster-admin -n kube-system
kubectl version
kubectl api-version
kubectl config view
kubectl get componentstatuses
kubectl get rs
kubectl get nodes
kubectl get namespaces
每个Node都包括以下状态信息
地址:包括hostname、外网IP和内网IP
条件(Condition):包括OutOfDisk、Ready、MemoryPressure和DiskPressure
容量(Capacity):Node上的可用资源,包括CPU、内存和Pod总数
基本信息(Info):包括内核版本、容器引擎版本、OS类型等
kubectl cordon NodeName
kubectl uncordon NodeName
标签:net 应用 不可 处理 方式 clu pods Kubernete system
原文地址:https://blog.51cto.com/ko178/2453203