seals部署kubernetes1.14.1
Posted 冬眠的熊哎
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了seals部署kubernetes1.14.1相关的知识,希望对你有一定的参考价值。
注意事项
1.需要纯净的linux系统、ubunt16.04,centos7
2.新版本sealos离线包自带docker、如没安装docker,会自动安装
3.尽量使用新版本sealos
4.必须同步服务器时间,时间保持一致
5.master节点CPU必须2c以上
6.cni组件选择cilium时要求内核版本不低于5.4
网络参数:
pod的IP地址段,也称为cidr
#podcidr参数指定自定义pod网段 如
--podcidr 10.244.0.0/16
#svccidr参数指定clusterip网段 如
--svccidr 10.93.0.0/12
seals 架构
使用sealos部署k8s
1、环境准备
关闭firwalld(所有节点执行)
[root@VM-4-11-centos ~]# systemctl stop firewalld
[root@VM-4-11-centos ~]# systemctl disable firewalld
关闭selinux(所有节点执行)
[root@VM-4-11-centos ~]# setenforce 0
[root@VM-4-11-centos ~]# vim /etc/selinux/config
修改SELINUX=enforcing 为 SELINUX=disabled
配置所有主机名,主机名不允许重复
timedatectl set-timezone Asia/Shanghai #都要执行
hostnamectl set-hostname master1 #master1执行
hostnamectl set-hostname node1 #node1执行
所有节点在 /etc/hosts 中添加解析
cat <<EOF > /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
172.17.100.136 matser1
172.17.118.213 node1
EOF
2、配置时间同步
timedatectl set-timezone Asia/Shanghai
chronyc -a makestep
3、安装docker
cd /tmp
tar -zxf docker-18.06.3-ce.tgz -C /usr/local/bin
cd /usr/local/bin
mv docker dockerad
mv dockerad/* ./
rm -rf dockerad
vim /usr/lib/systemd/system/docker.service
[Unit]
Description=Docker Application Container Engine
Documentation=http://docs.docker.com
[Service]
Environment=PATH=/usr/local/bin:/usr/bin:/usr/sbin
EnvironmentFile=-/run/flannel/docker
ExecStart=/usr/local/bin/dockerd --graph=/data/docker --log-level=error $DOCKER_NETWORK_OPTIONS
ExecReload=/bin/kill -s HUP $MAINPID
Restart=on-failure
RestartSec=5
LimitNOFILE=infinity
LimitNPROC=infinity
LimitCORE=infinity
Delegate=yes
KillMode=process
ExecStartPost=/sbin/iptables -I FORWARD -s 0.0.0.0/0 -j ACCEPT
[Install]
WantedBy=multi-user.target
systemctl start docker
systemctl enable docker
systemctl status docker
4、下载安装sealos
wget -c https://github.com/fanux/sealos/releases/download/v3.3.8/sealos && chmod +x sealos && mv sealos /usr/bin/
5、下载k8s安装包
wget https://github.com/sealstore/cloud-kernel/releases/download/offline/kube1.14.1.tar.gz
6、部署单master多node集群(admin 是服务器的密码)
[root@master1 ~]# sealos init --passwd admin \\
> --master 172.17.100.x \\
> --node 172.17.100.x \\
> --pkg-url /root/kube1.14.1.tar.gz \\ #/root/kube1.14.1.tar.gz 是安装包的目录
> --version v1.14.1
7、配置多master节点多node集群
sealos init --passwd admin \\
--master 192.168.200.x \\
--master 192.168.200.x \\
--master 192.168.200.x \\
--node 192.168.200.x \\
--pkg-url /root/kube1.14.1.tar.gz \\
--version v1.14.1
8、查看node状态、pod状态
[root@master1 ~]# kubectl get node
NAME STATUS ROLES AGE VERSION
master1 Ready master 44m v1.14.1
node1 Ready <none> 43m v1.14.1
[root@master1 ~]# kubectl get pod -n kube-system
NAME READY STATUS RESTARTS AGE
calico-kube-controllers-7cc5c56498-vgbks 1/1 Running 0 46m
calico-node-4qh22 1/1 Running 0 27m
calico-node-zk9q7 1/1 Running 0 46m
coredns-fb8b8dccf-lqpwf 1/1 Running 0 46m
coredns-fb8b8dccf-vt7nj 1/1 Running 0 46m
etcd-master1 1/1 Running 0 45m
kube-apiserver-master1 1/1 Running 0 45m
kube-controller-manager-master1 1/1 Running 0 45m
kube-proxy-6f8cp 1/1 Running 0 46m
kube-proxy-6n4rh 1/1 Running 0 46m
kube-scheduler-master1 1/1 Running 0 45m
kube-sealyun-lvscare-node1 1/1 Running 0 46m
9、验证
创建一个deployment和pod
[root@master1 ~]# kubectl create deployment my-tomcat --image=tomcat:7.0.75
deployment.apps/my-tomcat created
查看一下deployment和pod的信息
[root@master1 ~]# kubectl get deployment
NAME READY UP-TO-DATE AVAILABLE AGE
my-tomcat 1/1 1 1 30m
创建一个svc使应用在外部客户端访问
[root@master1 ~]# kubectl expose deployment my-tomcat --name=tomcat --port=8080 --type=NodePort
service/tomcat exposed
使用宿主机节点的IP加上暴露的端口进行访问
验证完成,部署完成
以上是关于seals部署kubernetes1.14.1的主要内容,如果未能解决你的问题,请参考以下文章
二进制安装kubernetes1.14.1-pod基础-07
二进制安装kubernetes1.14.1-pod配置清单之客户端访问方式03
研发运维双管齐下!Seal AppManager的正确打开方式