iT邦幫忙

2021 iThome 鐵人賽

DAY 6
0


圖片來源github

Kind

Kind = Kubernetes in Docker,簡單說就是把k8s run在docker上面,少了安裝在本機上面的動作,
Kind也是個Kubernetes SIGs project,跟常用的minikube對比,把原本安裝在vm上面改到container上面

比較表格

項目 minikube kind
runtime VM container
supported AMD64 AMD64, ARMv7, ARM64
supported container runtimes Docker,CRI-O,containerd,gvisor Docker
memory requirements 2GB 8GB
multi-cluster support yes yes
multi-node support no yes
資料來源

架構圖


資料來源

手把手安裝

安裝前請先安裝好godocker

1.安裝kind

GO111MODULE="on" go get sigs.k8s.io/kind@v0.11.1

執行結果

go: downloading sigs.k8s.io/kind v0.11.1
go: downloading github.com/spf13/cobra v1.1.1
go: downloading github.com/alessio/shellescape v1.4.1
go: downloading k8s.io/apimachinery v0.20.2
go: downloading golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c
go: downloading sigs.k8s.io/yaml v1.2.0
go: downloading github.com/evanphx/json-patch v4.9.0+incompatible
go: downloading github.com/pelletier/go-toml v1.8.1
go: downloading github.com/inconshreveable/mousetrap v1.0.0
go: downloading github.com/evanphx/json-patch/v5 v5.2.0

2.新增cluster

kind create cluster

執行結果

Creating cluster "kind" ...
 ✓ Ensuring node image (kindest/node:v1.21.1) ?
 ✓ Preparing nodes ?
 ✓ Writing configuration ?
 ✓ Starting control-plane ?️
 ✓ Installing CNI ?
 ✓ Installing StorageClass ?
Set kubectl context to "kind-kind"
You can now use your cluster with:

kubectl cluster-info --context kind-kind

Thanks for using kind! ?

也是可以使用參數指定cluster的名稱

kind create cluster --name test-kind-cluster

需要指定node image版本,可以加上tag

kind create cluster --name tag-version-kind --image kindest/node:v1.21.1

安裝儀表版

kind不像minikube有自帶儀表版,所以需要自行安裝
1.安裝dashboard

kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.0.0-beta8/aio/deploy/recommended.yaml

確認一下有沒有正常運作

kubectl get pod -n kubernetes-dashboard

執行結果

NAME                                         READY   STATUS    RESTARTS   AGE
dashboard-metrics-scraper-778b77d469-v85pw   1/1     Running   0          3m5s
kubernetes-dashboard-5cd89984f5-9vtsm        1/1     Running   0          3m5s

2.安裝ClusterRoleBinding,提供剛剛建的cluster管理權限存取

kubectl create clusterrolebinding default-admin --clusterrole cluster-admin --serviceaccount=default:default

3.因為儀表板是使用token登入,所以把token匯出

token=$(kubectl get secrets -o jsonpath="{.items[?(@.metadata.annotations['kubernetes\.io/service-account\.name']=='default')].data.token}"|base64 -d)
echo $token

4.使用kubectl proxy進入儀板表

kubectl proxy

5.登入

http://localhost:8001/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy/#/login

6.填入token就可以看到k8s資訊啦
https://ithelp.ithome.com.tw/upload/images/20210908/20129515cXxfUdOwhw.png
https://ithelp.ithome.com.tw/upload/images/20210908/2012951539mv7elKzn.png

kind的基礎安裝就到這邊了


上一篇
[DAY5]認識kubectl指令
下一篇
[DAY7]從0開始裝k8s(2)-k0s
系列文
k8s新手船長船難記30
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

1 則留言

0
namaste520
iT邦新手 5 級 ‧ 2022-03-02 23:28:22

版主您好, 謝謝您撰寫精采好文!

我要留言

立即登入留言