操作记录
安装docker
# 清理旧的docker(如果安装过的话)
sudo apt-get remove docker docker-engine docker.io containerd runc
# 安装需要的基础软件(一般都已经存在了)
sudo apt-get install ca-certificates curl gnupg lsb-release
# 添加GPG
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
# 添加apt源
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
# 更新本地apt源信息
sudo apt-get update
# 安装
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin -y
# 将当前用户添加到docker组
sudo usermod -aG docker $USER
# 登录到docker组
newgrp docker
# 验证
docker run hello-world
安装 kubectl
# 安装
sudo snap install kubectl --classic
# 验证
kubectl version --client
安装并启动minikube
# 下载
wget -c https://ghproxy.com/https://github.com/kubernetes/minikube/releases/download/v1.25.2/minikube_1.25.2-0_amd64.deb
# 安装
sudo dpkg -i minikube_1.25.2-0_amd64.deb
rm minikube_1.25.2-0_amd64.deb
# 设置使用docker作为驱动
minikube config set driver docker
# 启动minikube集群
minikube start --driver=docker --image-mirror-country='cn'
配置minikube仪表盘(监听127.0.0.1
只能本机访问)
以supervisor
为例, 如果未安装,请用命令sudo apt install supervisor
安装。
minikube dashboard 配置
sudo vim /etc/supervisor/conf.d/minikube_dashboard.conf
/etc/supervisor/conf.d/minikube_dashboard.conf
:
[program:minikube_dashboard]
user=xxx
directory=/home/xxx
command=/usr/bin/minikube dashboard --url
autostart=true
autorestart=true
startsecs=5
stopsignal=HUP
stopasgroup=true
stopwaitsecs=5
stdout_logfile_maxbytes=20MB
stdout_logfile=/var/log/supervisor/%(program_name)s-out.log
stderr_logfile_maxbytes=20MB
stderr_logfile=/var/log/supervisor/%(program_name)s-err.log
kubectl proxy 配置(开放端口允许外部访问)
sudo vim /etc/supervisor/conf.d/kubectl_proxy.conf
sudo vim /etc/supervisor/conf.d/kubectl_proxy.conf
:
[program:kubectl_proxy]
user=xxx
directory=/home/xxx
command=/snap/bin/kubectl proxy --port=8090 --address=0.0.0.0 --accept-hosts='.*'
autostart=true
autorestart=true
startsecs=5
stopsignal=HUP
stopasgroup=true
stopwaitsecs=5
stdout_logfile_maxbytes=20MB
stdout_logfile=/var/log/supervisor/%(program_name)s-out.log
stderr_logfile_maxbytes=20MB
stderr_logfile=/var/log/supervisor/%(program_name)s-err.log
启动dashboard
# 进入 supervisor
sudo supervisorctl
supervisorctl内操作
# 应用配置更新
update
# 查看minikube dashboard输出
tail -f minikube_dashboard
minikube_dashboard输出如下:
supervisor> tail -f minikube_dashboard
==> Press Ctrl-C to exit <==
- Using image kubernetesui/metrics-scraper:v1.0.7
- Using image kubernetesui/dashboard:v2.3.1
http://127.0.0.1:42213/api/v1/namespaces/kubernetes-dashboard/services/http:kubernetes-dashboard:/proxy/
复制url, 将其中的ip换为机器ip(假设为192.168.1.3
), 端口换为代理端口(此处为8090
), 即可实现外部访问:http://192.168.1.3:8090/api/v1/namespaces/kubernetes-dashboard/services/http:kubernetes-dashboard:/proxy/
评论 (0)