手动部署k8s太过于痛苦,随即发现kubekey这样的工具。
准备工作:wget <https://github.com/kubesphere/kubekey/releases/download/v3.1.1/kubekey-v3.1.1-linux-amd64.tar.gz> && tar zxvf kubekey-v3.1.1-linux-amd64.tar.gz
apiVersion: kubekey.kubesphere.io/v1alpha2
kind: Cluster
metadata:
name: sample
spec:
hosts:
- {name: master, address: 192.168.1.15, internalAddress: 192.168.1.15, user: root, password: "xxx"} #修改集群IP,用户名密码
- {name: node1, address: 192.168.1.16, internalAddress: 192.168.1.16, user: root, password: "xxx"} #修改集群IP,用户名密码
- {name: node2, address: 192.168.1.17, internalAddress: 192.168.1.17, user: root, password: "xxx"} #修改集群IP,用户名密码
roleGroups:
registry:
- master
etcd:
- master
control-plane:
- master
worker:
- node1
- node2
controlPlaneEndpoint:
domain: lb.k8s.local # lb address
address: ""
port: 6443
kubernetes:
version: "1.28.6" # 配置k8s版本,可以根据这个命令查看支持的k8s版本`./kk version --show-supported-k8s`
clusterName: my
autoRenewCerts: true
containerManager: docker
etcd:
type: kubekey
registry:
auths:
"192.168.1.18:443":
username: admin
password: Harbor12345
certsPath: "/etc/docker/certs.d/192.168.1.18:443"
privateRegistry: "192.168.1.18:443"
type: harbor
namespaceOverride: "kubesphere"
registryMirrors: []
insecureRegistries: []
network:
plugin: calico
kubePodsCIDR: 10.233.64.0/18
kubeServiceCIDR: 10.233.0.0/18
multusCNI:
enabled: false
addons: []
kubectl get node 查看集群状态
\可选 仓库验证:https://ip+443(admin/Harbor12345)
无法访问外网情况
准备文件:kubekey-v3.1.1-linux-amd64.tar.gz、images.tar.gz、cluster.yaml、rpm.tar.gz、create_project_harbor.sh
kubekey-v3.1.1-linux-amd64.tar.gz
images.tar.gz: 通过export KKZONE=cn ./kk create manifest --with-kubernetes v1.28.6 --with-registry && ./kk artifact export -m manifest-sample.yaml -o image.tar.gz
cluster.yaml: 文件详情
rpm.tar.gz: 包含conntrack和socat, 下载地址
create_project_harbor.sh: 下载地址
上传kubekey-v3.1.1-linux-amd64.tar.gz文件
tar zxvf kubekey-v3.1.1-linux-amd64.tar.gz
上传:images.tar.gz、cluster.yaml
1. export KKZONE=cn
2. ./kk init registry -f cluster.yaml -a images.tar.gz
上传:rpm.tar.gz
1. rpm -ivh libnetfilter_*.rpm
2. rpm -ivh socat-*
上传:images.tar.gz、create_project_harbor.sh
1. sh create_project_harbor.sh
2. ./kk create cluster -f cluster.yaml -a images.tar.gz