1 离线安装–安装包制作(mutli_arch)
1.1 下载kubekey
install_path=/data
kkversion=v2.2.1
mkdir $install_path
cd $install_path
curl -L https://github.com/kubesphere/kubekey/releases/download/$kkversion/kubekey-$kkversion-linux-amd64.tar.gz -o kubekey-$kkversion-linux-amd64.tar.gz
tar zxvf kubekey-$kkversion-linux-amd64.tar.gz
#生成id_rsa key
ssh-keygen -f /root/.ssh/id_rsa -P ''
1.2 生成manifest-sample.yaml
#./kk create manifest
#修改manifest-sample.yaml
cat > manifest-sample.yaml << 'EOF'
apiVersion: kubekey.kubesphere.io/v1alpha2
kind: Manifest
metadata:
name: sample
spec:
arches:
- amd64
- arm64 #增加arm64架构
operatingSystems:
- arch: amd64
type: linux
id: centos
version: "7"
osImage: CentOS Linux 7 (Core)
repository:
iso:
localPath:
url: https://github.com/kubesphere/kubekey/releases/download/v2.2.0/centos7-rpms-amd64.iso
- arch: arm64 #增加arm64架构
type: linux
id: centos
version: "7"
osImage: CentOS Linux 7 (Core)
repository:
iso:
localPath:
url: https://github.com/kubesphere/kubekey/releases/download/v2.2.0/centos7-rpms-arm64.iso
kubernetesDistributions:
- type: kubernetes
version: v1.23.7
components:
helm:
version: v3.6.3
cni:
version: v0.9.1
etcd:
version: v3.4.13
containerRuntimes:
- type: containerd
version: 1.6.4
crictl:
version: v1.24.0
##
# docker-registry:
# version: "2"
harbor:
version: v2.4.1
docker-compose:
version: v2.2.2
images:
- registry.cn-beijing.aliyuncs.com/kubesphereio/cni:v3.20.0
- registry.cn-beijing.aliyuncs.com/kubesphereio/coredns:1.8.6
- registry.cn-beijing.aliyuncs.com/kubesphereio/k8s-dns-node-cache:1.15.12
- registry.cn-beijing.aliyuncs.com/kubesphereio/kube-apiserver:v1.23.7
- registry.cn-beijing.aliyuncs.com/kubesphereio/kube-controller-manager:v1.23.7
- registry.cn-beijing.aliyuncs.com/kubesphereio/kube-controllers:v3.20.0
- registry.cn-beijing.aliyuncs.com/kubesphereio/kube-proxy:v1.23.7
- registry.cn-beijing.aliyuncs.com/kubesphereio/kube-scheduler:v1.23.7
- registry.cn-beijing.aliyuncs.com/kubesphereio/node:v3.20.0
- registry.cn-beijing.aliyuncs.com/kubesphereio/pause:3.6
- registry.cn-beijing.aliyuncs.com/kubesphereio/pod2daemon-flexvol:v3.20.0
registry:
auths: {}
EOF
1.2导出并生成离线安装包
export KKZONE=cn
./kk artifact export -m manifest-sample.yaml -o kubernetes_v1.23.7_mutli.tar.gz
2.2 生成离线集群配置文件
./kk create config --with-kubernetes v1.23.7 -f config-sample.yaml
#修改config-sample.yaml文件
kind: Cluster
metadata:
name: sample
spec:
hosts:
- {name: master01, address: 192.168.11.101, internalAddress: 192.168.11.101, user: root, password: "123456", arch: amd64}
- {name: node01, address: 192.168.11.102, internalAddress: 192.168.11.102, user: root, password: "123456", arch: amd64}
- {name: registry, address: 192.168.11.100, internalAddress: 192.168.11.100, user: root, password: "123456", arch: amd64}
roleGroups:
etcd:
- master01
control-plane:
- master01
worker:
- master01
- node01
registry:
- registry
controlPlaneEndpoint:
## Internal loadbalancer for apiservers
# internalLoadbalancer: haproxy
domain: lb.lady.cn
address: ""
port: 6443
kubernetes:
version: v1.23.7
clusterName: cluster.local
autoRenewCerts: true
containerManager: containerd
etcd:
type: kubekey
network:
plugin: calico
kubePodsCIDR: 10.178.64.0/18
kubeServiceCIDR: 10.178.0.0/18
## multus support. https://github.com/k8snetworkplumbingwg/multus-cni
multusCNI:
enabled: false
registry:
type: harbor
auths:
"dockerhub.kubekey.local":
username: admin
password: Harbor12345
skipTLSVerify: true
plainHTTP: false
# 设置集群部署时使用的私有仓库
privateRegistry: "dockerhub.kubekey.local"
#privateRegistry: ""
namespaceOverride: "kubesphereio"
registryMirrors: []
insecureRegistries: []
addons: []
# - name: traefik
# sources:
# yaml:
# path:
# - /root/traefik.yaml
3.1、创建私仓库
./kk init registry -f config-sample.yaml -a kubernetes_v1.23.7_mutli.tar.gz
3.2创建仓库的project
cat > create_project_harbor.sh << 'EOF'
url="https://dockerhub.kubekey.local"
user="admin"
passwd="Harbor12345"
harbor_projects=(library
kubesphereio
kubesphere
calico
coredns
openebs
csiplugin
minio
mirrorgooglecontainers
osixia
prom
thanosio
jimmidyson
grafana
elastic
istio
jaegertracing
jenkins
weaveworks
openpitrix
joosthofman
nginxdemos
fluent
kubeedge
)
for project in "${harbor_projects[@]}"; do
echo "creating $project"
curl -u "${user}:${passwd}" -X POST -H "Content-Type: application/json" "${url}/api/v2.0/projects" -d "{ \"project_name\": \"${project}\", \"public\": true}" -k
done
EOF
bash create_project_harbor.sh
3.3 上传镜像包到私仓中(可略过)
./kk artifact images push -f config-sample.yaml -a kubernetes_v1.23.7_mutli.tar.gz
3、通过离线包安装kubernetes集群
./kk create cluster -f config-sample.yaml -a kubernetes_v1.23.7_mutli.tar.gz --with-packages -y