参考:
rianbond快速安装k8s
参考:
kubeasz
一、环境准备
(1)升级内核:
centos7升级内核
(2)更新系统软件和安装python
yum update
yum install python -y
(3)安装ansible及准备ssh免密登陆
curl -O https://bootstrap.pypa.io/pip/2.7/get-pip.py
python get-pip.py
python -m pip install --upgrade "pip < 21.0"
pip install ansible -i https://mirrors.aliyun.com/pypi/simple/
ssh-keygen -t ed25519 -N '' -f ~/.ssh/id_ed25519
ssh-keygen -t rsa -b 2048 -N '' -f ~/.ssh/id_rsa
ssh-copy-id $IPs
ssh $IPs ln -s /usr/bin/python3 /usr/bin/python
二、安装
(1)下载项目源码、二进制及离线镜像
export release=3.0.0
wget https://github.com/easzlab/kubeasz/releases/download/${release}/ezdown
chmod +x ./ezdown
./ezdown -D
(2)创建集群配置实例
ezctl new k8s-01
2021-01-19 10:48:23 DEBUG generate custom cluster files in /etc/kubeasz/clusters/k8s-01
2021-01-19 10:48:23 DEBUG set version of common plugins
2021-01-19 10:48:23 DEBUG cluster k8s-01: files successfully created.
2021-01-19 10:48:23 INFO next steps 1: to config '/etc/kubeasz/clusters/k8s-01/hosts'
2021-01-19 10:48:23 INFO next steps 2: to config '/etc/kubeasz/clusters/k8s-01/config.yml'
(3)配置hosts
hosts详解(类似)
[etcd]
192.168.1.1 NODE_NAME=etcd1
192.168.1.2 NODE_NAME=etcd2
192.168.1.3 NODE_NAME=etcd3
[kube-master]
192.168.1.1
192.168.1.2
[kube-node]
192.168.1.3
192.168.1.4
[harbor]
[ex-lb]
[chrony]
[all:vars]
CONTAINER_RUNTIME="docker"
CLUSTER_NETWORK="flannel"
PROXY_MODE="ipvs"
SERVICE_CIDR="10.68.0.0/16"
CLUSTER_CIDR="172.20.0.0/16"
NODE_PORT_RANGE="20000-40000"
CLUSTER_DNS_DOMAIN="cluster.local."
bin_dir="/opt/kube/bin"
ca_dir="/etc/kubernetes/ssl"
base_dir="/etc/ansible"
(4)开始安装
ezctl setup k8s-01 all
...
三、helm安装
(1)首先:执行以下命令 shell
wget https://goodrain-pkg.oss-cn-shanghai.aliyuncs.com/pkg/helm && chmod +x helm && mv helm /opt/kube/bin/
(2)检查helm shell
helm version
执行以上命令,正常应返回version.BuildInfo{Version:"v3.4.2", GitCommit:"xxxxx", GitTreeState:"clean", GoVersion:"go1.14.13"},注意版本号是否为v3.x.x
(3)不安全警告信息
WARNING: Kubernetes configuration file is group-readable. This is insecure. Location: /root/.kube/config
WARNING: Kubernetes configuration file is world-readable. This is insecure. Location: /root/.kube/config
version.BuildInfo{Version:"v3.6.3", GitCommit:"d506314abfb5d21419df8c7e7e68012379db2354", GitTreeState:"clean", GoVersion:"go1.16.5"}
解决这个告警,修改权限即可:
[root@master1 kubeasz]
[root@master1 kubeasz]
[root@master1 kubeasz]
version.BuildInfo{Version:"v3.6.3", GitCommit:"d506314abfb5d21419df8c7e7e68012379db2354", GitTreeState:"clean", GoVersion:"go1.16.5"}
|