本地電腦安裝minikube

什么是MiniKube

Minikube 是一個(gè)可以在本地輕松運(yùn)行 Kubernetes 的工具。Minikube 會(huì)在您的筆記本電腦中的虛擬機(jī)上運(yùn)行一個(gè)單節(jié)點(diǎn)的 Kubernetes 集群,以便用戶對(duì) Kubernetes 進(jìn)行試用或者在之上進(jìn)行 Kubernetes 的日常開(kāi)發(fā)(---來(lái)自于官網(wǎng)的描述

安裝MiniKube

一、準(zhǔn)備

  1. BIOS 中啟用 VT-x 或者 AMD-v 虛擬化(Linux系統(tǒng)可以執(zhí)行命令:egrep --color 'vmx|svm' /proc/cpuinfo;結(jié)果不為空則表示已經(jīng)開(kāi)啟)

二、安裝

  1. 安裝VirtualBox


    image.png
  2. 安裝kubectl(我使用的是Ubuntu,其它安裝方式請(qǐng)參考官網(wǎng)
    kubectl是Kubernetes命令行工具,通過(guò)它可以部署和管理應(yīng)用,查看各種資源、創(chuàng)建、刪除和更新
sudo apt-get update && sudo apt-get install -y apt-transport-https
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
echo "deb https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee -a /etc/apt/sources.list.d/kubernetes.list
sudo apt-get update
sudo apt-get install -y kubectl
  1. 安裝Minikube
  • 下載安裝包
curl -Lo minikube https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 \
  && chmod +x minikube
  • copy到/usr/local/bin路徑下
sudo cp minikube /usr/local/bin

三、啟動(dòng)

  1. 指定 VM driver類型
minkube start --vm-driver=virtualbox

VM Driver支持多種類型,詳見(jiàn)官網(wǎng)

啟動(dòng)日志

$ minikube start --vm-driver=virtualbox
Starting local Kubernetes v1.13.2 cluster...
Starting VM...
Getting VM IP address...
Moving files into cluster...
Setting up certs...
Connecting to cluster...
Setting up kubeconfig...
Stopping extra container runtimes...
Starting cluster components...
Verifying kubelet health ...
Verifying apiserver health ...
Kubectl is now configured to use the cluster.
Loading cached images from config file.

Everything looks great. Please enjoy minikube!
  1. 體驗(yàn)MiniKube
  • 部署應(yīng)用
$ kubectl run hello-minikube --image=k8s.gcr.io/echoserver:1.10 --port=8080
deployment.apps/hello-minikube created

執(zhí)行上述命令時(shí),會(huì)出現(xiàn)下面命令廢棄的提示信息:
kubectl run --generator=deployment/apps.v1 is DEPRECATED and will be removed in a future version. Use kubectl run --generator=run-pod/v1 or kubectl create instead.

  • 訪問(wèn)應(yīng)用
$ kubectl expose deployment hello-minikube --type=NodePort
service/hello-minikube exposed
#第一次執(zhí)行時(shí),創(chuàng)建Pod中
$ kubectl get pod
NAME                              READY   STATUS              RESTARTS   AGE
hello-minikube-6fd785d459-4n5s8   0/1     ContainerCreating   0          27s

#第二次執(zhí)行時(shí),Pod創(chuàng)建完畢
$ kubectl get pods
NAME                              READY   STATUS    RESTARTS   AGE
hello-minikube-6fd785d459-4n5s8   1/1     Running   0          13m
#獲取服務(wù)地址
$ minikube service hello-minikube --url
http://192.168.99.105:30555
$ curl http://192.168.99.105:30555

Hostname: hello-minikube-6fd785d459-4n5s8

Pod Information:
    -no pod information available-

Server values:
    server_version=nginx: 1.13.3 - lua: 10008

Request Information:
    client_address=172.17.0.1
    method=GET
    real path=/
    query=
    request_version=1.1
    request_scheme=http
    request_uri=http://192.168.99.105:8080/

Request Headers:
    accept=*/*
    host=192.168.99.105:30555
    user-agent=curl/7.58.0

Request Body:
    -no body in request-
  • 啟動(dòng) dashboard
$ minikube dashboard
Enabling dashboard ...
Verifying dashboard health ...
Launching proxy ...
Verifying proxy health ...
Opening http://127.0.0.1:46595/api/v1/namespaces/kube-system/services/http:kubernetes-dashboard:/proxy/ in your default browser...
[17270:17270:0131/140138.494733:ERROR:sandbox_linux.cc(364)] InitializeSandbox() called with multiple threads in process gpu-process.

瀏覽器中顯示Dashboard


image.png

參考
https://kubernetes.io/docs/tasks/tools/install-minikube/

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

友情鏈接更多精彩內(nèi)容