安装插件
microk8s enable dashboard
查看dashboard 地址
由于dashboard是在kube-system的namespace中,我们可以使用下面指令查看它服务的地址。
microk8s kubectl get service -n kube-system kubernetes-dashboard
可以得到地址是https://10.152.183.167。
登录dashboard
由于上述地址是kubernetes内部地址,不是Ubuntu Desktop虚拟机的地址,我们就在虚拟机内部访问。
获取登录token
在ubuntu内终端执行下面指令
kubectl create token default
将获取的token填入网页
然后选择对应的命名空间(namespace),就可以看到相关资源了。
题外
Hyper-V上Ubuntu Desktop版的分辨率很低,不能完全展示dashboard。我们可以通过下面方法调整其大小。
修改Hyper-V上Ubuntu分辨率
sudo vi /etc/default/grub
会看到下面的内容
# If you change this file, run 'update-grub' afterwards to update
# /boot/grub/grub.cfg.
# For full documentation of the options in this file, see:
# info -f grub -n 'Simple configuration'
GRUB_DEFAULT=0
GRUB_TIMEOUT_STYLE=hidden
GRUB_TIMEOUT=0
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
GRUB_CMDLINE_LINUX=""
# Uncomment to enable BadRAM filtering, modify to suit your needs
# This works with Linux (no patch required) and with any kernel that obtains
# the memory map information from GRUB (GNU Mach, kernel of FreeBSD ...)
#GRUB_BADRAM="0x01234567,0xfefefefe,0x89abcdef,0xefefefef"
# Uncomment to disable graphical terminal (grub-pc only)
#GRUB_TERMINAL=console
# The resolution used on graphical terminal
# note that you can use only modes which your graphic card supports via VBE
# you can see them in real GRUB with the command `vbeinfo'
#GRUB_GFXMODE=640x480
# Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux
#GRUB_DISABLE_LINUX_UUID=true
# Uncomment to disable generation of recovery mode menu entries
#GRUB_DISABLE_RECOVERY="true"
# Uncomment to get a beep at grub start
#GRUB_INIT_TUNE="480 440 1"
对GRUB_CMDLINE_LINUX_DEFAULT的内容进行修改,新增分辨率信息(本例以1920*1440)。
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash video=hyperv_fb:1920*1440"
wq保存文件后,执行
sudo update-grub
sudo apt install linux-image-extra-virtual
然后关闭虚拟机。使用管理员身份打开Windows主机的Powershell,执行下面命令
set-vmvideo -vmname "Ubuntu 22 Desktop" -horizontalresolution:1920 -verticalresolution:1440 -resolutiontype single
再启动虚拟机,就可以看到分辨率变大了。
参考资料
- https://microk8s.io/docs/addon-dashboard
- https://superuser.com/questions/1660150/change-screen-resolution-of-ubuntu-vm-in-hyper-v