环境
阿里云国内 ubuntu18.04,因为k8s的镜像在k8s.gcr.io下,这个地址指向的是谷歌的服务器,所以被墙了,国内无法正常访问此仓库。而且microk8s版本更新,导致目前网上找到的方法无效,是针对老版本的,目前我使用的是v1.15.0。
安装步骤
安装microk8s
1
2apt install snapd
snap install microk8s --classic查看microk8s状态
1
microk8s.status
在这里你可以看到插件的安装情况
- microk8s.kubectl重命名为kubectl
1
snap alias microk8s.kubectl kubectl
以上为正常的安装步骤,请参考官网 https://microk8s.io/docs/
给microk8s配梯子
安装ss
1
2apt-get install python-pip
pip install git+https://github.com/shadowsocks/shadowsocks.git@master连接梯子
1
nohup sslocal -s (ip) -p (port) -k (password) &
设置microk8s通过梯子拉取镜像。编辑 /var/snap/microk8s/current/args/containerd-env
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18# To start containerd behind a proxy you need to add an HTTPS_PROXY
# environment variable in this file. HTTPS_PROXY is of the following form:
# HTTPS_PROXY=http://username:password@proxy:port/
# where username: and password@ are optional. eg:
#
HTTPS_PROXY=socks5://127.0.0.1:1080
#
#
# Remember to restart the containerd daemon after editing this file:
#
# sudo systemctl restart snap.microk8s.daemon-containerd.service
#
#
# Attempt to change the maximum number of open file descriptors
# this get inherited to the running containers
#
ulimit -n 65536 || true
这里注意,之前版本是修改 /var/snap/microk8s/current/args/dockerd-env,新版本有已经没有这个文件了。目前我安装的microk8s版本是v1.15.0,不排除可能在以后的版本发生变化。
- 重启启动daemon-containerd服务
1
sudo systemctl restart snap.microk8s.daemon-containerd.service
v1.5.2