您好,登錄后才能下訂單哦!
節(jié)點(diǎn)名稱 | 服務(wù)名稱 | 用途 |
---|---|---|
管理節(jié)點(diǎn) | kubctl-apiserver | 提供HTTP Rest統(tǒng)一接口服務(wù),處理和驗(yàn)證REST請(qǐng)求和更新etcd中API對(duì)象的狀態(tài) |
管理節(jié)點(diǎn) | kubectl-controller-manager | 資源控制管理同步 |
管理節(jié)點(diǎn) | kube-scheduler | 負(fù)責(zé)資源調(diào)度(調(diào)度Pod) |
工作節(jié)點(diǎn) | kubelet | 管理Pod的生命周期,創(chuàng)建、啟停等任務(wù) |
工作節(jié)點(diǎn) | kube-proxy | 負(fù)責(zé)網(wǎng)絡(luò)通信及負(fù)載均衡 |
### 1.重啟服務(wù)
kubectl patch deployment app名稱 -p {\"spec\":{\"template\":{\"metadata\":{\"labels\":{\"date\":\"date +'%s'
\"}}}}} -n kube-system
### 2.重新分配pod數(shù)量
kubectl scale deployment kubernetes-dashboard --replicas=1 -n kube-system
### 3.查看部署應(yīng)用
kubectl get deploy -n kube-system
### 4.獲得容器前一次運(yùn)行的日志內(nèi)容
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部署節(jié)點(diǎn)及IP
kubectl get pods -n kube-system -o wide
### 7.查看集群中服務(wù)
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.標(biāo)簽管理
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.查詢?nèi)罩?/code>
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.顯示所有的服務(wù)
kubectl get deployments -n kube-system
kubectl get daemonsets -n kube-system
### 14.創(chuàng)建命名空間
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.創(chuàng)建/查看 Deployment 記錄版本號(hào)
kubectl create -f nginx-deployment.yaml --record
### 16.實(shí)現(xiàn)水平擴(kuò)展或收縮
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.自動(dòng)擴(kuò)展
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.升級(jí)資源
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.授權(quán)管理
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
每個(gè)Node都包括以下狀態(tài)信息
地址:包括hostname、外網(wǎng)IP和內(nèi)網(wǎng)IP
條件(Condition):包括OutOfDisk、Ready、MemoryPressure和DiskPressure
容量(Capacity):Node上的可用資源,包括CPU、內(nèi)存和Pod總數(shù)
基本信息(Info):包括內(nèi)核版本、容器引擎版本、OS類型等
kubectl cordon NodeName
kubectl uncordon NodeName
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。