1、参考文档
参考使用国内源文档
2、 安装 Docker
自行配置镜像加速
按照以上官网安装遇到错误
$ sudo apt-get install docker-ce docker-ce-cli containerd.io Reading package lists... Done Building dependency tree Reading state information... Done Package docker-ce is not available, but is referred to by another package. This may mean that the package is missing, has been obsoleted, or is only available from another source E: Package 'docker-ce' has no installation candidate E: Unable to locate package docker-ce-cli E: Unable to locate package containerd.io E: Couldn't find any package by glob 'containerd.io' E: Couldn't find any package by regex 'containerd.io'
干脆,改用 apt 安装
$ docker -v Command 'docker' not found, but can be installed with: sudo snap install docker # version 20.10.8, or sudo apt install docker.io See 'snap info docker' for additional versions.
说明:apt 安装的是 docker.io ,不是 docker-ce
docker-ce 是 docker 官方维护的 docker.io 是 Debian 团队维护的 docker.io 采用 apt 的方式管理依赖 docker-ce 用 go 的方式管理依赖,会自己管理所有的依赖。
配置阿里云镜像加速器
记得重启服务
sudo systemctl daemon-reload
sudo systemctl restart docker
3、配置Kubernetes软件源
以上阿里云Kubernetest镜像的方法缺少 sudo 和 kubernetes.list 不太对!
$ sudo apt-get install -y apt-transport-https
Reading package lists... Done Building dependency tree Reading state information... Done The following packages were automatically installed and are no longer required: linux-headers-4.15.0-151 linux-headers-4.15.0-151-generic linux-headers-4.15.0-158 linux-headers-4.15.0-158-generic linux-image-4.15.0-151-generic linux-image-4.15.0-158-generic linux-modules-4.15.0-151-generic linux-modules-4.15.0-158-generic linux-modules-extra-4.15.0-151-generic linux-modules-extra-4.15.0-158-generic Use 'sudo apt autoremove' to remove them. The following NEW packages will be installed: apt-transport-https 0 upgraded, 1 newly installed, 0 to remove and 85 not upgraded. Need to get 4,348 B of archives. After this operation, 154 kB of additional disk space will be used. Get:1 https://mirrors.tuna.tsinghua.edu.cn/ubuntu bionic-updates/universe amd64 apt-transport-https all 1.6.14 [4,348 B] Fetched 4,348 B in 1s (3,692 B/s) Selecting previously unselected package apt-transport-https. (Reading database ... 186525 files and directories currently installed.) Preparing to unpack .../apt-transport-https_1.6.14_all.deb ... Unpacking apt-transport-https (1.6.14) ... Setting up apt-transport-https (1.6.14) ...
$ sudo curl https://mirrors.aliyun.com/kubernetes/apt/doc/apt-key.gpg | sudo apt-key add –
% Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 2537 100 2537 0 0 10659 0 --:--:-- --:--:-- --:--:-- 10659 OK
加入到 apt 源
sudo tee /etc/apt/sources.list.d/kubernetes.list <<-'EOF' deb https://mirrors.aliyun.com/kubernetes/apt/ kubernetes-xenial main EOF
$ sudo apt-get update
$ sudo apt-get install -y kubectl
Reading package lists... Done Building dependency tree Reading state information... Done The following packages were automatically installed and are no longer required: linux-headers-4.15.0-151 linux-headers-4.15.0-151-generic linux-headers-4.15.0-158 linux-headers-4.15.0-158-generic linux-image-4.15.0-151-generic linux-image-4.15.0-158-generic linux-modules-4.15.0-151-generic linux-modules-4.15.0-158-generic linux-modules-extra-4.15.0-151-generic linux-modules-extra-4.15.0-158-generic Use 'sudo apt autoremove' to remove them. The following NEW packages will be installed: kubectl 0 upgraded, 1 newly installed, 0 to remove and 85 not upgraded. Need to get 9,057 kB of archives. After this operation, 46.9 MB of additional disk space will be used. Get:1 https://mirrors.aliyun.com/kubernetes/apt kubernetes-xenial/main amd64 kubectl amd64 1.22.4-00 [9,057 kB] Fetched 9,057 kB in 3s (3,516 kB/s) Selecting previously unselected package kubectl. (Reading database ... 186529 files and directories currently installed.) Preparing to unpack .../kubectl_1.22.4-00_amd64.deb ... Unpacking kubectl (1.22.4-00) ... Setting up kubectl (1.22.4-00) ...
4、安装并启动minikube
5、验证和使用minikube
6、部署 dashboard
$ minikube dashboard
🔌 Enabling dashboard ... ▪ Using image registry.cn-hangzhou.aliyuncs.com/google_containers/dashboard:v2.3.1 ▪ Using image registry.cn-hangzhou.aliyuncs.com/google_containers/metrics-scraper:v1.0.7 🤔 Verifying dashboard health ... 🚀 Launching proxy ... 🤔 Verifying proxy health ... 🎉 Opening http://127.0.0.1:35845/api/v1/namespaces/kubernetes-dashboard/services/http:kubernetes-dashboard:/proxy/ in your default browser... 👉 http://127.0.0.1:35845/api/v1/namespaces/kubernetes-dashboard/services/http:kubernetes-dashboard:/proxy/ ^C
我这里只能通过 curl 测试
$ curl http://127.0.0.1:40999/api/v1/namespaces/kubernetes-dashboard/services/http:kubernetes-dashboard:/proxy/
按照以上转发方式,先找到 dashboard 的服务和端口
$ kubectl get svc -A
NAMESPACE NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE default hello-minikube NodePort 10.100.100.74 <none> 8080:30430/TCP 38m default kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 42m kube-system kube-dns ClusterIP 10.96.0.10 <none> 53/UDP,53/TCP,9153/TCP 42m kubernetes-dashboard dashboard-metrics-scraper ClusterIP 10.104.177.189 <none> 8000/TCP 35m kubernetes-dashboard kubernetes-dashboard ClusterIP 10.98.125.117 <none> 80/TCP 35m
转发到 30001 端口到 service 的 80 端口
kubectl port-forward -n kubernetes-dashboard –address 0.0.0.0 service/kubernetes-dashboard 30001:80
这样子,就可以在桌面电脑打开 dashboard 了
http://192.168.1.206:30001/#/workloads?namespace=default
7、minikube addons
先列举在这里,后续学习时再继续
$ minikube addons list
|-----------------------------|----------|--------------|-----------------------| | ADDON NAME | PROFILE | STATUS | MAINTAINER | |-----------------------------|----------|--------------|-----------------------| | ambassador | minikube | disabled | unknown (third-party) | | auto-pause | minikube | disabled | google | | csi-hostpath-driver | minikube | disabled | kubernetes | | dashboard | minikube | enabled ✅ | kubernetes | | default-storageclass | minikube | enabled ✅ | kubernetes | | efk | minikube | disabled | unknown (third-party) | | freshpod | minikube | disabled | google | | gcp-auth | minikube | disabled | google | | gvisor | minikube | disabled | google | | helm-tiller | minikube | disabled | unknown (third-party) | | ingress | minikube | disabled | unknown (third-party) | | ingress-dns | minikube | disabled | unknown (third-party) | | istio | minikube | disabled | unknown (third-party) | | istio-provisioner | minikube | disabled | unknown (third-party) | | kubevirt | minikube | disabled | unknown (third-party) | | logviewer | minikube | disabled | google | | metallb | minikube | disabled | unknown (third-party) | | metrics-server | minikube | disabled | kubernetes | | nvidia-driver-installer | minikube | disabled | google | | nvidia-gpu-device-plugin | minikube | disabled | unknown (third-party) | | olm | minikube | disabled | unknown (third-party) | | pod-security-policy | minikube | disabled | unknown (third-party) | | portainer | minikube | disabled | portainer.io | | registry | minikube | disabled | google | | registry-aliases | minikube | disabled | unknown (third-party) | | registry-creds | minikube | disabled | unknown (third-party) | | storage-provisioner | minikube | enabled ✅ | kubernetes | | storage-provisioner-gluster | minikube | disabled | unknown (third-party) | | volumesnapshots | minikube | disabled | kubernetes | |-----------------------------|----------|--------------|-----------------------|
$ minikube addons enable ingress
▪ Using image registry.cn-hangzhou.aliyuncs.com/google_containers/nginx-ingress-controller:v1.0.4 ▪ Using image registry.cn-hangzhou.aliyuncs.com/google_containers/kube-webhook-certgen:v1.1.1 ▪ Using image registry.cn-hangzhou.aliyuncs.com/google_containers/kube-webhook-certgen:v1.1.1 🔎 Verifying ingress addon... 🌟 The 'ingress' addon is enabled
$ minikube addons enable ingress-dns
▪ Using image registry.cn-hangzhou.aliyuncs.com/google_containers/minikube-ingress-dns:0.0.2 🌟 The 'ingress-dns' addon is enabled
原文链接:https://blog.csdn.net/u010953609/article/details/121489147