k8s|一键离线部署kubernets环境

作者:吴业亮
【k8s|一键离线部署kubernets环境】博客:http://blog.csdn.net/wylfengyujiancheng
每次部署kubernetes都要手动部署环境,这个体力活重复很没意义,于是抽空写了如下脚本和源,可以做到在离线的情况下执行脚本一键部署环境。
1、环境信息

# cat /etc/centos-release CentOS Linux release 7.5.1804 (Core)

kubernets版本
v1.13.1

节点:
10.13.7.61 控制节点 10.13.7.65 计算节点 10.13.7.69 计算节点

2、部署环境(本地源是基于1804-minimal做的)
下载操作系统iso
https://mirrors.tuna.tsinghua.edu.cn/centos-vault/7.5.1804/isos/x86_64/CentOS-7-x86_64-Minimal-1804.iso

3、安装系统

4、通过ftp工具将deploy-kubernetes.tar.gz上传到controller节点上
下载地址:
链接:https://pan.baidu.com/s/1QNIkrKG3cqnd_Vvnya5wOQ 提取码:j8ia

5、解压压缩包
# tar -zxvf deploy-kubernetes.tar.gz

6、修改配置文件./deploy-kubernetes/config/installrc
#部署的k8s压缩包名称 K8S_FILE=k8s1.13 #部署的kubernets版本 KUBERNETS_VERSION=v1.13.1 #pod的网段 NETWORK_CIDR=192.168.0.0/16 #kubernets环境的控制节点 CONTROLLER_NODE=10.13.7.61 #各个节点的root密码 NODE_ROOT_PASSWD=Changeme_123

7、将各个节点的IP和主机名写入hosts文件./deploy-kubernetes/config/hosts
127.0.0.1localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1localhost localhost.localdomain localhost6 localhost6.localdomain6 10.13.7.61 node1 10.13.7.65 node2 10.13.7.69 node3

8、在控制节点输入1安装控制节点
#bash main.sh 1) Install controller. 2) Install node. 0) Quit please input one number for install :1

9、在控制节点输入2安装计算节点
#bash main.sh 1) Install controller. 2) Install node. 0) Quit please input one number for install :2

10、通过token登录web界面
https://controller-IP:31234
k8s|一键离线部署kubernets环境
文章图片

获取token方法
在控制节点上执行
# get-token Name:admin-token-k24gk Namespace:kube-system Labels: Annotations:kubernetes.io/service-account.name: admin kubernetes.io/service-account.uid: 40ebbdea-a709-11e9-88a8-fa163eeab11eType:kubernetes.io/service-account-tokenData =https://www.it610.com/article/=== ca.crt:1025 bytes namespace:11 bytes token:eyJhbGciOiJSUzI1NiIsImtpZCI6IiJ9.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJrdWJlLXN5c3RlbSIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VjcmV0Lm5hbWUiOiJhZG1pbi10b2tlbi1rMjRnayIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VydmljZS1hY2NvdW50Lm5hbWUiOiJhZG1pbiIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VydmljZS1hY2NvdW50LnVpZCI6IjQwZWJiZGVhLWE3MDktMTFlOS04OGE4LWZhMTYzZWVhYjExZSIsInN1YiI6InN5c3RlbTpzZXJ2aWNlYWNjb3VudDprdWJlLXN5c3RlbTphZG1pbiJ9.xjlLL-4zH1UYJjRUpxbhvR8Ul5rCv8aSIURfw7_GCcZeuPekPOZbroyoP-C6qMRIJBwSnVHUJrC09ic_ePc8oLs9QURPZmYzQKb54MGQLnrC4kg0K_UMhi4jV3FPPEaEsDxSclfWZOt8OG8RtJHPDAA8w2-nYL7uWOwnBHEQalha0eDZ24qYsU1CcqLSrnE9V_5_vR4f4rcu2Y08oio_jJPCryZtq787v4UkXkm_cu-UUd7-CFXktKMSSU0Dy2edNEjcik7qfbUNZWrc1Z6edAv6usQpskTGJ7UiudZb6ffENPPmqQavYByb2bRynK8DWRp7S6qOG8uQgKgbvAb5Fw

k8s|一键离线部署kubernets环境
文章图片

代码下载路径:
链接:https://pan.baidu.com/s/1C3BQ9WwGmofxiwcm1zPwcQ提取码:zpa2

    推荐阅读