centos7 k8s集群部署


安装k8s集群前期准备:
网络环境:centos7版本:
  [root@k8s_master ~]# cat /etc/redhat-release
  CentOS Linux release 7.4.1708 (Core) 关闭firewalld:
  systemctl stop firewalld
  systemctl disable firewalld三台主机基础服务安装:
  [root@k8s_master ~]#yum -y update
  [root@k8s_master ~]#yum -y install net-tools wget vim ntpd
  [root@k8s_master ~]#systemctl enable ntpd
  [root@k8s_master ~]#systemctl start ntpd分别在三台主机,设置主机名:
  Master
  hostnamectl –static set-hostname k8s_master
  Node1
  hostnamectl –static set-hostname k8s_client1
  Node2
  hostnamectl –static set-hostname k8s_client2设置hosts,分别再三台主机执行:部署Master操作:
  安装etcd服务:
  [root@k8s_master ~]# yum -y install etcd编辑配置文件 /etc/etcd/etcd.conf
  [root@k8s_master ~]# cat /etc/etcd/etcd.conf | grep -v “^#”  设置开机启动并验证状态
  [root@k8s_master ~]#systemctl enable etcd
  [root@k8s_master ~]#systemctl start etcd  etcd检查
  [root@k8s_master ~]# etcdctl -C http://k8s_master:4001 cluster-health
  member 8e9e05c52164694d is healthy: got healthy result from http://k8s_master:2379
  cluster is healthy
  [root@k8s_master ~]# etcdctl -C http://k8s_master:2379 cluster-health
  member 8e9e05c52164694d is healthy: got healthy result from http://k8s_master:2379
  cluster is healthy安装docker服务
  [root@k8s_master ~]# yum -y install docker
  设置开机启动,开启服务:
  [root@k8s_master ~]#systemctl enable docker
  [root@k8s_master ~]#systemctl start docker
查看docker版本:
[root@k8s_master ~]# docker version
Client:
Version: 1.12.6
API version: 1.24
Package version: docker-1.12.6-71.git3e8e77d.el7.centos.1.x86_64
Go version: go1.8.3
Git commit: 3e8e77d/1.12.6
Built: Tue Jan 30 09:17:00 2018
OS/Arch: linux/amd64Server:
Version: 1.12.6
API version: 1.24
Package version: docker-1.12.6-71.git3e8e77d.el7.centos.1.x86_64
Go version: go1.8.3
Git commit: 3e8e77d/1.12.6
Built: Tue Jan 30 09:17:00 2018
OS/Arch: linux/amd64安装kubernetes
  [root@k8s_master ~]# yum install kubernetes在kubernetes master上需要运行以下组件:
    Kubernets API Server
    Kubernets Controller Manager
    Kubernets Scheduler修改apiserver服务配置文件:
[root@k8s_master ~]# cat /etc/kubernetes/apiserver | grep -v “^#”修改config配置文件:
[root@k8s_master ~]# cat /etc/kubernetes/config | grep -v “^#”设置开机启动,开启服务
  [root@k8s_master ~]#systemctl enable kube-apiserver kube-controller-manager kube-scheduler
  [root@k8s_master ~]#systemctl start kube-apiserver kube-controller-manager kube-scheduler查看服务端口:
[root@k8s_master ~]# netstat -tnlp部署Node:
安装docker
   参考Master安装方法
安装kubernetes
  参考Master安装方法
配置、启动kubernetes
  node节点上需要运行一下组件
   kubelet kube-proxyNode节点主机做以下配置:
config:
[root@k8s_client1 ~]# cat /etc/kubernetes/config | grep -v “^#”设置开机启动、开启服务
  [root@k8s_client1 ~]# systemctl enable kubelet kube-proxy
  [root@k8s_client1 ~]# systemctl start kubelet kube-proxy查看端口:
[root@k8s_client1 ~]# netstat -ntlpMaster上查看集群中的节点及节点状态
  [root@k8s_master ~]# kubectl get node  [root@k8s_master ~]# kubectl -s http://k8s_master:8080 get nodekubernetes集群搭建完成,还需flannel安装
flannel是CoreOS提供用于解决Dokcer集群跨主机通讯的覆盖网络工具。它的主要思路是:预先留出一个网段,每个主机使用其中一部分,然后每个容器被分配不同的ip;让所有的容器认为大家在同一个直连的网络,底层通过UDP/VxLAN等进行报文的封装和转发。Master/Node上flannel安装:
  [root@k8s_master ~]#yum install flannelflannel配置:
  Master/Node上修改/etc/sysconfig/flanneldMaster:
  [root@k8s_master ~]# cat /etc/sysconfig/flanneld | grep -v “^#”Node:
  [root@k8s_client1 ~]# cat /etc/sysconfig/flanneld | grep -v “^#”添加网络:
[root@k8s_master ~]#etcdctl mk //atomic.io/network/config ‘{“Network”:”172.8.0.0/16″}’Master/Node设置服务开机启动
[root@k8s_master ~]# systemctl enable flanneld
[root@k8s_master ~]# systemctl start flanneldMaster/Node节点重启服务:
Master:Node:
  [root@k8s_client1 ~]#systemctl restart kube-proxy kubelet docker查开发云主机域名看flannel网络:
  Master节点:
[root@k8s_master ~]# ip a
1: lo: mtu 65536 qdisc noqueue state UNKNOWN qlen 1
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens160: mtu 1500 qdisc mq state UP qlen 1000
link/ether 00:50:56:98:3b:d4 brd ff:ff:ff:ff:ff:ff
inet 192.168.3.216/24 brd 192.168.3.255 scope global ens160
valid_lft forever preferred_lft forever
inet6 fe80::250:56ff:fe98:3bd4/64 scope link
valid_lft forever preferred_lft forever
3: flannel0: mtu 1472 qdisc pfifo_fast state UNKNOWN qlen 500
link/none
inet 10.8.57.0/16 scope global flannel0
valid_lft forever preferred_lft forever
inet6 fe80::3578:6e81:8dc9:ed82/64 scope link flags 800
valid_lft forever preferred_lft forever
4: docker0: mtu 1500 qdisc noqueue state DOWN
link/ether 02:42:8b:7c:fd:8d brd ff:ff:ff:ff:ff:ff
inet 10.8.57.1/24 scope global docker0
valid_lft forever preferred_lft forever
  Node节点:
[root@k8s_client1 ~]# ip a
1: lo: mtu 65536 qdisc noqueue state UNKNOWN qlen 1
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens160: mtu 1500 qdisc mq state UP qlen 1000
link/ether 00:50:56:98:65:e0 brd ff:ff:ff:ff:ff:ff
inet 192.168.3.217/24 brd 192.168.3.255 scope global ens160
valid_lft forever preferred_lft forever
inet6 fe80::250:56ff:fe98:65e0/64 scope link
valid_lft forever preferred_lft forever
4: docker0: mtu 1500 qdisc noqueue state DOWN
link/ether 02:42:23:4b:85:6f brd ff:ff:ff:ff:ff:ff
inet 10.8.6.1/24 scope global docker0
valid_lft forever preferred_lft forever
9: flannel0: mtu 1472 qdisc pfifo_fast state UNKNOWN qlen 500
link/none
inet 10.8.6.0/16 scope global flannel0
valid_lft forever preferred_lft forever
inet6 fe80::827:f63e:34ee:1f8e/64 scope link flags 800
valid_lft forever preferred_lft forever

相关推荐: unix系统是什么操作系统?有什么特性

unix系统是什么操作系统?有什么特性?相信有很多人都不太了解,今天小编为了让大家更加了解unix系统,所以给大家总结了以下内容,一起往下看吧。UNIX系统属于哪一类操作系统UNIX操作系统属于分时操作系统。分时操作系统的主要特征就是在一台计算机周围挂上若干台…

免责声明:本站发布的图片视频文字,以转载和分享为主,文章观点不代表本站立场,本站不承担相关法律责任;如果涉及侵权请联系邮箱:360163164@qq.com举报,并提供相关证据,经查实将立刻删除涉嫌侵权内容。

Like (0)
Donate 微信扫一扫 微信扫一扫
Previous 04/01 20:00
Next 04/01 20:00