kubekey
##三节点安装kubesphere 节点信息
master1 address: 192.168.1.219
worker1 address: 192.168.1.221
worker2 address: 192.168.1.222
##预装软件插件
yum update
yum install -y openssl openssl-devel socat epel-release conntrack-tools wget
date
mkdir /data/kubekey
mkdir /data/kubesphere
##单网卡,跳过网络bond
|清空网卡配置。
|
|ifdown em1
|ifdown em2
|rm -rf /etc/sysconfig/network-scripts/ifcfg-em1
|rm -rf /etc/sysconfig/network-scripts/ifcfg-em2
|创建 bond 网卡。
|
|nmcli con add type bond con-name bond0 ifname bond0 mode 802.3ad ip4 192.168.60.152/24 gw4 192.168.60.254
|设置 bond 模式。
|
|nmcli con mod id bond0 bond.options mode=802.3ad,miimon=100,lacp_rate=fast,xmit_hash_policy=layer2+3
|将物理网卡绑定至 bond。
|
|nmcli con add type bond-slave ifname em1 con-name em1 master bond0
|nmcli con add type bond-slave ifname em2 con-name em2 master bond0
|修改网卡模式。
|
|vi /etc/sysconfig/network-scripts/ifcfg-bond0
|BOOTPROTO=static
|重启 Network Manager。
|
|systemctl restart NetworkManager
|nmcli con # Display NIC information
|修改主机名和 DNS。
|
|hostnamectl set-hostname worker-1
|vim /etc/resolv.conf
|设置时间
|开启时间同步。
|
|yum install -y chrony
|systemctl enable chronyd
|systemctl start chronyd
|timedatectl set-ntp true
##单网卡,跳过网络bond
##禁用防火墙
iptables -F
systemctl status firewalld
systemctl stop firewalld
systemctl disable firewalld
##设置时间区域语言
timedatectl set-timezone Asia/Shanghai
cp /etc/locale.conf /etc/locale.conf.bak
echo 'LANG=zh_CN.UTF-8' > /etc/locale.conf
source /etc/locale.conf
date
###下载 KubeKey
##先执行以下命令以确保您从正确的区域下载 KubeKey:
export KKZONE=cn
##执行以下命令下载 KubeKey:
curl -sfL https://get-kk.kubesphere.io | VERSION=v1.0.1 sh -
##为 kk 文件添加可执行权限。
chmod +x kk
##生成安装配置文件
./kk creat config --with-kubernetes v1.17.9 --with-kubesphere v3.0.0
在 KubeSphere 上充分测试过的 Kubernetes 版本:v1.15.12、v1.16.13、v1.17.9(默认)和 v1.18.6。
如果您在这一步的命令中不添加标志 --with-kubesphere,则不会部署 KubeSphere,只能使用配置文件中的 addons 字段安装 KubeSphere,或者在您后续使用 ./kk create cluster 命令时再次添加该标志。
如果您添加标志 --with-kubesphere 时不指定 KubeSphere 版本,则会安装最新版本的 KubeSphere。
系统将创建默认的 config-sample.yaml 文件。您可以根据您的环境修改此文件。
vim config-sample.yaml ##以下为文件修改的部分,根据具体情况,节点,修改IP,节点数,以下为一主两辅,共3点配置。【配置需要完全复制!需要一样】
--------------以下为配置----------------------------------
hosts:
- {name: master1, address: 192.168.1.219, internalAddress: 192.168.1.219, user: root, password: Htyc@htyc}
- {name: worker1, address: 192.168.1.221, internalAddress: 192.168.1.221, user: root, password: Htyc@htyc}
- {name: worker2, address: 192.168.1.222, internalAddress: 192.168.1.222, user: root, password: Htyc@htyc}
roleGroups:
etcd:
- master1
master:
- master1
worker:
- worker1
- worker2
controlPlaneEndpoint:
domain: lb.kubesphere.local
address: ""
port: "6443"
--------------以上为配置----------------------------------
##执行以下命令使用自定义的配置文件创建集群:
./kk create cluster -f config-sample.yaml
##验证安装脚本,信息如上图,说明脚本正常,输入yes开始安装。
安装结束后,您可以执行以下命令查看安装日志:
kubectl logs -n kubesphere-system $(kubectl get pod -n kubesphere-system -l app=ks-install -o jsonpath='{.items[0].metadata.name}') -f
以下为成功时日志信息
**************************************************
task monitoring status is running
task multicluster status is successful
total: 2 completed:1
**************************************************
task monitoring status is running
task multicluster status is successful
total: 2 completed:1
**************************************************
task monitoring status is successful
task multicluster status is successful
total: 2 completed:2
**************************************************
#####################################################
### Welcome to KubeSphere! ###
#####################################################
Console: http://192.168.1.219:30880
Account: admin
Password: P@88w0rd
NOTES:
1. After logging into the console, please check the
monitoring status of service components in
the "Cluster Management". If any service is not
ready, please wait patiently until all components
are ready.
2. Please modify the default password after login.
#####################################################
https://kubesphere.io 2021-04-15 18:05:09
#####################################################
更新系统。
yum update
启用 overlay2 内核模块。
echo "overlay2" | sudo tee -a /etc/modules-load.d/overlay.conf
刷新动态生成的 grub2 配置。
sudo grub2-set-default 0
调整内核参数并使修改生效。
cat <<EOF | sudo tee -a /etc/sysctl.conf
vm.max_map_count = 262144
fs.may_detach_mounts = 1
net.ipv4.ip_forward = 1
vm.swappiness=1
kernel.pid_max =1000000
fs.inotify.max_user_instances=524288
EOF
sudo sysctl -p
调整系统限制。
vim /etc/security/limits.conf
* soft nofile 1024000
* hard nofile 1024000
* soft memlock unlimited
* hard memlock unlimited
root soft nofile 1024000
root hard nofile 1024000
root soft memlock unlimited
删除旧的限制配置。
sudo rm /etc/security/limits.d/20-nproc.conf
重启系统。
reboot