官方參考來源
下載地址
參考教程
安裝
複製在文件夾,在windows 環境變量中添加路徑
測試
kubectl version --client
kubectl cluster-info
創建一個HTTP 服務器
kubectl create deployment hello-minikube --image=k8s.gcr.io/echoserver:1.10
kubectl expose deployment hello-minikube --type=NodePort --port=8080
hello-minikube Pod 開始運行,但是必須等到 Pod 啓動 ,測試Pod是否運行
kubectl get pod
以下兩個狀態一個創建過程中,一個已經成功運行
可以通過以下命令得到暴露的服務, 把獲取的url 粘貼到瀏覽器能看到本地集羣的細節
minikube service hello-minikube --url
刪除服務
kubectl delete services hello-minikube
kubectl delete deployment hello-minikube
開啓第二個終端窗口去運行代理,代理可以通過CTRL+C的方式終止
kubectl proxy
使用 kubectl 進行故障排除
kubectl get - 列出資源
kubectl describe - 顯示有關資源的詳細信息
kubectl logs - 打印 pod 和其中容器的日誌
kubectl exec - 在 pod 中的容器上執行命令
kubectl get nodes 查看node節點信息
kubectl describe node k8s-node-01 查看某個node的詳細信息
刪除的方法
1、先刪除pod
2、再刪除對應的deployment
kubectl get pod -n hello-minikube
kubectl delete pod jello-minikube-dsf44735dhd -n hello-minikube
kubectl get pod -n hello-minikube
kubectl get deployment -n hello-minikube
kubectl delete deployment hello-minikube-n hello-minikube
kubectl get deployment -n hello-minikube
kubectl get pod -n hello-minikube
另外一種安裝方法
choco install kubernetes-cli