MinKube + Docker
【容器架構】Minikube vs.kind vs.k3s-我應該用哪一個?
下面您可以找到一個表,列出了每個工具的一些關鍵事實。
minikube | kind | k3s | |
---|---|---|---|
runtime | VM | container | native |
supported architectures | AMD64 | AMD64 | AMD64, ARMv7, ARM64 |
supported container runtimes | Docker,CRI-O,containerd,gvisor | Docker | Docker, containerd |
startup time initial/following | 5:19 / 3:15 | 2:48 / 1:06 | 0:15 / 0:15 |
memory requirements | 2GB | 8GB (Windows, MacOS) | 512 MB |
requires root? | no | no | yes (rootless is experimental) |
multi-cluster support | yes | yes | no (can be achieved using containers) |
multi-node support | no | yes | yes |
project page | minikube | kind | k3s |
原文:https://brennerm.github.io/posts/minikube-vs-kind-vs-k3s.html
Goto: Multi-Node K3s Cluster on NVIDIA Jetson Nano in 5 Minutes
是否應該選擇 K3S
Ref: https://wener.me/story/k3s-one-week/
如果你猶豫使用 K3S 還是使用 K8S 請思考以下問題
-
- 公司在平台投入多少 ?
- 有多少專人維護 ?
- K8S 建議至少 3-5 人
- 節點資源性能如何 ?
- K8S 建議至少 8 核 32G - 否則基礎服務占用資源不能被平攤
- 是否選擇托管的 K8S ?
- 不存在使用 K3S
- 混合雲、私有雲、公有雲 ?
或者用最簡單的方式判斷
-
- 節點數 <=50 選擇 K3S
- 一人工作量
- 50 < 節點數 <= 150 選擇 K3S 或 K8S
- 節點數量 > 150 選擇 K8S
- 有這樣的規模,運維必然是一個團隊,因此不存在 K8S 復雜的問題
- 節點數 <=50 選擇 K3S
B站:從0到1基礎入門
開始
-
下載並安裝k3s
$ curl -sfL https://get.k3s.io | sh -
# 安裝指定版本
$ curl -sfL https://get.k3s.io | INSTALL_K3S_VERSION=v1.0.1 sh -
-
查看啟動
$ tail -f /var/log/syslog $ kubectl get all -n kube-system
-
卸載
$ k3s-uninstall.sh
manifest 機制
containerd ---> host arch(arm64) ---> pull arch image(amd64)
添加集群
雲邊協同模式
MicroKube
Ref: microk8s 搭建
Ref: 使用 Microk8s 快速部署 kubernetes
安裝
sudo snap install microk8s --classic
常用命令
ubuntu@ip-172-30-5-71:~/argo-workflows/argo-workflows-demo$ sudo microk8s.start Started. ubuntu@ip-172-30-5-71:~/argo-workflows/argo-workflows-demo$ sudo microk8s.kubectl cluster-info Kubernetes control plane is running at https://127.0.0.1:16443 CoreDNS is running at https://127.0.0.1:16443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'. ubuntu@ip-172-30-5-71:~/argo-workflows/argo-workflows-demo$ sudo microk8s.kubectl get nodes NAME STATUS ROLES AGE VERSION ip-172-30-5-71 Ready <none> 2d1h v1.24.3-2+63243a96d1c393 ubuntu@ip-172-30-5-71:~/argo-workflows/argo-workflows-demo$ sudo microk8s.kubectl get pods No resources found in default namespace.
啟動 addons
ubuntu@ip-172-30-5-71:~/argo-workflows/argo-workflows-demo$ sudo microk8s.status microk8s is running high-availability: no datastore master nodes: 127.0.0.1:19001 datastore standby nodes: none addons: enabled: dns # (core) CoreDNS ha-cluster # (core) Configure high availability on the current node disabled: community # (core) The community addons repository dashboard # (core) The Kubernetes dashboard gpu # (core) Automatic enablement of Nvidia CUDA helm # (core) Helm 2 - the package manager for Kubernetes helm3 # (core) Helm 3 - Kubernetes package manager host-access # (core) Allow Pods connecting to Host services smoothly hostpath-storage # (core) Storage class; allocates storage from host directory ingress # (core) Ingress controller for external access mayastor # (core) OpenEBS MayaStor metallb # (core) Loadbalancer for your Kubernetes cluster metrics-server # (core) K8s Metrics Server for API access to service metrics prometheus # (core) Prometheus operator for monitoring and logging rbac # (core) Role-Based Access Control for authorisation registry # (core) Private image registry exposed on localhost:32000 storage # (core) Alias to hostpath-storage add-on, deprecated $ sudo microk8s.enable dashboard
查看
Pods都READY嘛?
ubuntu@ip-172-30-5-71:~/argo-workflows/argo-workflows-demo$ sudo microk8s.kubectl get nodes NAME STATUS ROLES AGE VERSION ip-172-30-5-71 Ready <none> 2d2h v1.24.3-2+63243a96d1c393 ubuntu@ip-172-30-5-71:~/argo-workflows/argo-workflows-demo$ sudo microk8s.kubectl get pods -n kube-system NAME READY STATUS RESTARTS AGE calico-node-7l29w 1/1 Running 1 (137m ago) 2d2h coredns-66bcf65bb8-gbb8c 1/1 Running 0 26m calico-kube-controllers-5d96b44665-zdtlz 1/1 Running 1 (137m ago) 2d2h metrics-server-5f8f64cb86-tbwgm 1/1 Running 0 17m kubernetes-dashboard-765646474b-jghcv 1/1 Running 0 16m dashboard-metrics-scraper-6b6f796c8d-7lwk5 1/1 Running 0 16m
登錄 Dashboard?
獲取 dashboard 的 ClusterIP
ubuntu@ip-172-30-5-71:~/argo-workflows/argo-workflows-demo$ sudo microk8s.kubectl get svc -n kube-system
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE kube-dns ClusterIP 10.152.183.10 <none> 53/UDP,53/TCP,9153/TCP 49m metrics-server ClusterIP 10.152.183.126 <none> 443/TCP 37m kubernetes-dashboard ClusterIP 10.152.183.238 <none> 443/TCP 37m dashboard-metrics-scraper ClusterIP 10.152.183.128 <none> 8000/TCP 37m
Deployment of Nginx
ubuntu@ip-172-30-5-71:~/argo-workflows/argo-workflows-demo$ sudo microk8s.kubectl create deployment nginx --image=nginx deployment.apps/nginx created
ubuntu@ip-172-30-5-71:~/argo-workflows/argo-workflows-demo$ sudo microk8s.kubectl get deployments NAME READY UP-TO-DATE AVAILABLE AGE nginx 1/1 1 1 13s ubuntu@ip-172-30-5-71:~/argo-workflows/argo-workflows-demo$ sudo microk8s.kubectl get pods -o wide NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES nginx-8f458dc5b-r9rtr 1/1 Running 0 27s 10.1.219.72 ip-172-30-5-71 <none> <none> ubuntu@ip-172-30-5-71:~/argo-workflows/argo-workflows-demo$ wget 10.1.219.72:80 --2022-09-11 08:34:25-- http://10.1.219.72/ Connecting to 10.1.219.72:80... connected. HTTP request sent, awaiting response... 200 OK Length: 615 [text/html] Saving to: ‘index.html’ index.html 100%[========================================================================>] 615 --.-KB/s in 0s 2022-09-11 08:34:25 (103 MB/s) - ‘index.html’ saved [615/615] ubuntu@ip-172-30-5-71:~/argo-workflows/argo-workflows-demo$ vim index.html
continue ...