您好,登錄后才能下訂單哦!
節點名稱 | 服務名稱 | 用途 |
---|---|---|
管理節點 | 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
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。