0%

远程搭建minikube环境折腾记录

安装minikube

  • 提前安装好docker并启动, 用docker作为虚拟集群的驱动
1
2
3
4
5
6
7
8
rpm系列:
curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-latest.x86_64.rpm
rpm -Uvh minikube-latest.x86_64.rpm

dpkg系列:
curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube_latest_amd64.deb
dpkg -i minikube_latest_amd64.deb

启动minikube(docker)

1
2
3
4
5
6
7
8
9
10
11
12
13
# 非root用户把当前用户加入docker用户组
sudo usermod -aG docker $USER && newgrp docker

# root用户, 执行时额外加上`--force`强制执行

# docker作为驱动, 默认单节点方式
minikube start -d docker

# 额外启动两个node节点
minikube start -n3 -d docker

# 检查启动状态
minikube kubectl -- get pods -A

启动dashbord

  • 没有放在后台, 方便随时停止
1
2
3
4
5
# 可选: 启动额外的监控
minikube addons enable metrics-server

# 启动dashbord, 要拉取一些镜像, 比较慢
minikube dashboard --url
  • 把url 复制到本地浏览器中

远程Linux机器转发dashbord

  • dashbord默认没有暴漏在公网, 远程Linux启动的话只能在远程机器上访问
  • 如果允许开启ssh 隧道的话, 直接ssh遂穿到本地就行ssh -L 40439:localhost:40439 root@aaabbb
  • 或者把dashbord 直接暴漏在公网, 比较危险

x11转发远程窗口方式

  • 由于安全策略, 禁止任何ssh隧道, 这里直接使用x11转发浏览器窗口

远端开启x11转发

1
2
3
4
5
6
7
8
9
10
vim /etc/ssh/ssh_config

#打开下面的选项:
X11Forwarding yes
X11DisplayOffset 10
X11UseLocalhost yes

#重启sshd
systemctl restart sshd

远端安装firefox, xclock

1
dnf install xclock firefox

本地安装putty+VcXsrv

  • vcxsrv
  • putty
  • 或者 mobaxterm 整合了两个, 省去配置, 不过是商业软件, 注意版权
  • RDP/VNC等方式就要自己折腾了

配置VcXsrv

  • multiple windows 模式, display number 设置为0吧, 不自动探测了
  • 关闭访问控制(disable access control)
  • 启动后放在后台等待

配置putty并启动firefox, 打开远端的localhost网页

hello node 测试

1
2
3
4
5
6
7
# 创建
kubectl create deployment hello-node --image=registry.k8s.io/e2e-test-images/agnhost:2.39 -- /agnhost netexec --http-port=8080
# 暴漏服务
kubectl expose deployment hello-node --type=LoadBalancer --port=8080
# 查看地址
kubectl get services
minikube service hello-node