yum 安装kubernetes

部署环境:centos7

最少准备三台机器

一台master .两台node

yum 安装kubernetes

 

yum 安装kubernetes

做好域名解析

vim /etc/hosts

yum 安装kubernetes

在所有节点执行:

[root@k8smaster ~]# setenforce 0

setenforce: SELinux is disabled

[root@k8smaster ~]# iptables -F

[root@k8smaster ~]# iptables -t nat -F

[root@k8smaster ~]# iptables -I FORWARD -s 0.0.0.0/0 -d 0.0.0.0/0 -j ACCEPT

[root@k8snode3 ~]# yum -y install ntp

[root@k8snode3 ~]# ntpdate pool.ntp.org

3 Nov 20:18:34 ntpdate[10115]: adjust time server 119.28.206.193 offset 0.002529 sec

[root@k8snode3 ~]# systemctl start ntpd

[root@k8snode3 ~]# systemctl enable ntpd

Created symlink from /etc/systemd/system/multi-user.target.wants/ntpd.service to /usr/lib/systemd/system/ntpd.service.

[root@k8snode3 ~]#

 

[root@k8smaster yum.repos.d]# wget http://mirrors.aliyun.com/repo/Centos-7.repo

[root@k8smaster yum.repos.d]# yum clean all

[root@k8smaster yum.repos.d]# yum update

Delta RPMs disabled because /usr/bin/applydeltarpm not installed.

yum 安装kubernetes

[root@k8smaster ~]# vim /etc/etcd/etcd.conf

[root@k8smaster ~]# mkdir -p /data/etcd0/

 

配置源

docker-ce.repo

yum 安装kubernetes

kubernetes

[kubernetes]

name=Kubernetes Repobaseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64/ gpgcheck=1

gpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg

enabled=1

如图所示:

yum 安装kubernetes

使用#yum repolist生成新源

yum 安装kubernetes

 

一配置ip 做域名解析

yum 安装kubernetes

 

二配置免密码登陆

root@k8smaster ~]# ssh-keygen -t rsa

yum 安装kubernetes

 

拷贝到其他节点:

yum 安装kubernetes

把docker-ce kubernetes.repo 复制到其他节点,操作如下:

scp kubernetes.repo docker-ce.repo k8snode1:/etc/yum.repos.d/

 

yum 安装kubernetes

同样把kubernetes.repo 复制到其他节点

 

在master端 安装

[root@k8smaster ~]# yum install kubernetes-master etcd flannel -y

yum 安装kubernetes

 

 

配置/etc/etcd/etcd.conf配置文件:

备份配置文件:

yum 安装kubernetes

[root@k8smaster etcd]# cp -v etcd.conf{,.bak}

"etcd.conf" -> "etcd.conf.bak"

[root@k8smaster etcd]# ll

总用量 8

-rw-r–r– 1 root root 1686 11月 3 22:29 etcd.conf

-rw-r–r– 1 root root 1686 11月 3 22:35 etcd.conf.bak

 

先测试是否能启动然后在修改配置文件:

yum 安装kubernetes

上面显示是能正常启动的

[root@k8smaster ~]# vim /etc/etcd/etcd.conf

ETCD_INITIAL_ADVERTISE_PEER_URLS="http://192.168.0.20:2380"

ETCD_ADVERTISE_CLIENT_URLS="http://192.168.0.20:2379"

 

ETCD_INITIAL_CLUSTER="etcd0=http://192.168.0.20:2380,etcd1=http://192.168.0.21:2380,etcd2=http://192.168.0.22:2380,etcd3=192.168.0.23:2380"

yum 安装kubernetes

 

设置为开机启动:

[root@k8smaster etcd]# systemctl enable etcd

重新加载配置文件并且启动:

[root@k8smaster ~]# systemctl daemon-reload

[root@k8smaster etcd]# systemctl start etcd

[root@k8smaster etcd]# systemctl stop etcd

[root@k8smaster etcd]# vim etcd.conf

[root@k8smaster etcd]# systemctl daemon-reload

[root@k8smaster etcd]# systemctl start etcd

[root@k8smaster etcd]# systemctl status etcd

 

yum 安装kubernetes

到此,master配置文件就配好了

 

systemctl enable etcd kube-apiserver kube-scheduler kube-controller-manager

systemctl start etcd kube-apiserver kube-scheduler kube-controller-manager

下面接着配置/etc/kubernetes/config 配置文件

 

yum 安装kubernetes

 

yum 安装kubernetes

 

yum 安装kubernetes

在node端分别安装:

[root@k8snode1 yum.repos.d]# yum install kubernetes-node etcd docker flannel *rhsm* -y

配置/etc/etcd/etcd.conf

 

yum 安装kubernetes

[root@k8snode1 etcd]# systemctl enable etcd

Created symlink from /etc/systemd/system/multi-user.target.wants/etcd.service to /usr/lib/systemd/system/etcd.service.

如图下面就是已经跑起来了:

yum 安装kubernetes

 

配置文件/etc/kubernetes/config

yum 安装kubernetes

配置文件/etc/kuernetes/kubelet

yum 安装kubernetes

配置fanele网络

vim /etc/sysconfig/flannld

yum 安装kubernetes

[root@k8snode1 sysconfig]# systemctl daemon-reload

[root@k8snode1 sysconfig]# systemctl start etcd

[root@k8snode1 sysconfig]# systemctl startkubelet kube-proxy

[root@k8snode1 sysconfig]# systemctl enable flanneld kubelet kube-proxy

yum 安装kubernetes

以上进程显示能正常启动,配置过程要小心,有可能出现读不到配置文件现象,要一步步来,到处是坑,目前网络还没配置,可以在master端配置,

接下来配置node2

[root@k8snode2 ~]# vim /etc/etcd/ettcd.conf

[root@k8snode2 ~]# vim /etc/etcd/etcd.conf

[root@k8snode2 ~]# systemctl daemon-reload

[root@k8snode2 ~]# systemctl enable etcd

[root@k8snode2 ~]# systemctl start etcd

[root@k8snode2 ~]# systemctl status etcd

yum 安装kubernetes

 

 

yum 安装kubernetes

node2的etcd就OK了,

接下来配置nodes的kubernetes的配置了,配置文件为:

/etc/kubernetes/config

yum 安装kubernetes

配置/etc/kubernetes/kubelet

yum 安装kubernetes

启动服务:

root@k8snode2 ~]# systemctl enable docker

[root@k8snode2 ~]# systemctl start docke

[root@k8snode2 ~]# systemctl start kubelet kube-proxy

[root@k8snode2 ~]# systemctl enable flanneld kubelet kube-proxy

 

到了这里,机器基本配置完毕

在k8smater端查看集群是否成功

使用命令:

kubectl get nodes

yum 安装kubernetes

界面显示已经有两台node节点加入了

 

原创文章,作者:shadow,如若转载,请注明出处:http://www.178linux.com/124476

发表评论

登录后才能评论

This site uses Akismet to reduce spam. Learn how your comment data is processed.

联系我们

400-080-6560

在线咨询

工作时间:周一至周五,9:30-18:30,节假日同时也值班

QR code