1.安装docker
1.1 下载docker离线包
地址: https://download.docker.com/linux/static/stable/
进入aarch64目录,下载需要的docker版本
下载后上传至服务器解压
代码语言:javascript复制tar -xvf docker-20.10.7.tgz
# 将 docker 文件移动到 /usr/bin 目录下
cp -p docker/* /usr/bin
1.2 编写docker.service
代码语言:javascript复制vim docker.service
内容如下:
代码语言:javascript复制[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network-online.target firewalld.service
Wants=network-online.target
[Service]
Type=notify
# the default is not to use systemd for cgroups because the delegate issues still
# exists and systemd currently does not support the cgroup feature set required
# for containers run by docker
ExecStart=/usr/bin/dockerd
ExecReload=/bin/kill -s HUP $MAINPID
# Having non-zero Limit*s causes performance problems due to accounting overhead
# in the kernel. We recommend using cgroups to do container-local accounting.
LimitNOFILE=infinity
LimitNPROC=infinity
LimitCORE=infinity
# Uncomment TasksMax if your systemd version supports it.
# Only systemd 226 and above support this version.
#TasksMax=infinity
TimeoutStartSec=0
# set delegate yes so that systemd does not reset the cgroups of docker containers
Delegate=yes
# kill only the docker process, not all processes in the cgroup
KillMode=process
# restart the docker process if it exits prematurely
Restart=on-failure
StartLimitBurst=3
StartLimitInterval=60s
[Install]
WantedBy=multi-user.target
添加到系统服务
# 将 docker.service 移到 /etc/systemd/system/ 目录
代码语言:javascript复制cp docker.service /etc/systemd/system/
# 设置 docker.service 文件权限
chmod x /etc/systemd/system/docker.service
# 重新加载配置文件
systemctl daemon-reload
# 启动docker
systemctl start docker
# 设置 docker 开机自启
systemctl enable docker.service
1.3 验证docker的安装
2.安装KubeShpere
参考:三步搞定 ARM64 离线部署 Kubernetes KubeSphere
2.1 下载离线包
代码语言:javascript复制curl -Ok https://kubesphere-installer.pek3b.qingstor.com/offline/v3.0.0/kubesphere-core-v3.0.0-offline-linux-arm64.tar.gz
2.2 创建配置文件
代码语言:javascript复制./kk create config
生产后修改配置文件内容
代码语言:javascript复制apiVersion: kubekey.kubesphere.io/v1alpha1
kind: Cluster
metadata:
name: sample
spec:
hosts:
# 注意指定节点 arch 为 arm64
- {name: node1, address: 192.168.0.163, internalAddress: 192.168.0.163, password: 123456, arch: arm64}
roleGroups:
etcd:
- node1
master:
- node1
worker:
- node1
controlPlaneEndpoint:
domain: lb.kubesphere.local
address: ""
port: 6443
kubernetes:
version: v1.17.9
imageRepo: kubesphere
clusterName: cluster.local
network:
plugin: calico
kubePodsCIDR: 10.233.64.0/18
kubeServiceCIDR: 10.233.0.0/18
registry:
registryMirrors: []
insecureRegistries: []
privateRegistry: dockerhub.kubekey.local #添加此行
addons: []
2.3 导入registry
解压后进入kubesphere-core-v3.0.0-offline-linux-arm64/kubesphere-images-v3.0.0目录
执行导入
代码语言:javascript复制docker load < registry.tar
创建测试用自签名镜像仓库:
代码语言:javascript复制./kk init os -f config-sample.yaml --add-images-repo
注意:由 kk 启动的镜像仓库端口为443,请确保所有机器均可访问当前机器443端口
2.4 导入镜像
进入kubesphere-all-v3.0.0-offline-linux-arm64/kubesphere-images-v3.0.0 使用 offline-installation-tool.sh 将镜像导入之前准备的仓库中:
代码语言:javascript复制# 脚本后镜像仓库地址请填写真实仓库地址
./offline-installation-tool.sh -l images-list-v3.0.0.txt -d kubesphere-images -r dockerhub.kubekey.local
2.5 执行安装
代码语言:javascript复制# 以上准备工作完成且再次检查配置文件无误后,执行安装。
./kk create cluster -f config-sample.yaml --with-kubesphere
2.6 查看日志&验证
代码语言:javascript复制kubectl logs -n kubesphere-system $(kubectl get pod -n kubesphere-system -l app=ks-install -o jsonpath='{.items[0].metadata.name}') -f
如果使用的云服务器,记得开放安全组30880端口
3.遇到的问题
● 查看安装日志时提示:standard_init_linux.go:228: exec user process caused: exec format error
原因:config-sample.yaml中未添加 registry. dockerhub.kubekey.local 导致k8s安装过程中使用了x86架构的ks-install镜像。修改配置文件后,重新执行安装即可。