手机版
你好,游客 登录 注册
背景:
阅读新闻

yum方式安装kubernetes

[日期:2019-03-24] 来源:Linux社区  作者:omgasw [字体: ]

环境准备 master01 node01 node02,连通网络,修改hosts文件,确认3台主机相互解析

 

vim /etc/hosts

127.0.0.1  localhost localhost.localdomain localhost4 localhost4.localdomain4
::1        localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.1.201 master01
192.168.1.202 node01
192.168.1.203 node02

 

主机配置阿里YUM源

mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup && curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

 

开始部署kubernetes

1.在master01安装etcd

yum install etcd -y

安装完成,修改etcd配置文件/etc/etcd/etcd.conf

vim /etc/etcd/etcd.conf

ETCD_LISTEN_CLIENT_URLS="http://0.0.0.0:2379"    #修改监听地址
ETCD_LISTEN_CLIENT_URLS="http://192.168.1.201:2379"    #修改etcd地址为本机地址

设置服务启动

systemctl start etcd && systemctl enable etcd

2.在所有主机安装kubernetes

yum install kubernetes -y

3.配置master

vim /etc/kubernetes/config

KUBE_MASTER="--master=http://192.168.1.201:8080"    #修改kube_master地址

vim /etc/kubernetes/apiserver

KUBE_API_ADDRESS="--insecure-bind-address=0.0.0.0"    #修改监听地址
KUBE_ETCD_SERVERS="--etcd-servers=http://192.168.1.201:2379"    #修改etcd地址
KUBE_ADMISSION_CONTROL="--admission-control=NamespaceLifecycle,NamespaceExists,LimitRanger,SecurityContextDeny,ResourceQuota"    #删除认证参数ServiceAccount

设置服务启动,启动顺序apiserver>scheduler=controller-manager

systemctl start docker && systemctl enable docker
systemctl start kube-apiserver && systemctl enable kube-apiserver
systemctl start kube-scheduler && systemctl enable kube-scheduler
systemctl start kube-controller-manager && systemctl enable kube-controller-manager

4.配置node

vim /etc/kubernetes/config

KUBE_MASTER="--master=http://192.168.1.201:8080"    #修改master地址

vim /etc/kubernetes/kubelet

KUBELET_ADDRESS="--address=192.168.1.202"    #修改kubelet地址
KUBELET_HOSTNAME="--hostname-override=192.168.1.202"    #修改kubelet主机名
KUBELET_API_SERVER="--api-servers=http://192.168.1.201:8080"    #修改apiserver地址

设置服务启动

systemctl start docker && systemctl enable docker
systemctl start kubelet && systemctl enable kubelet
systemctl start kube-proxy && systemctl enable kube-proxy

5.部署完成,查看集群状态

kubectl get nodes

[root@node02 kubernetes]# kubectl -s http://192.168.1.201:8080 get nodes -o wide
NAME            STATUS    AGE      EXTERNAL-IP
192.168.1.202  Ready    29s      <none>
192.168.1.203  Ready    16m      <none>

 6.在所有主机安装flannel

yum install flannel -y

vim /etc/sysconfig/flanneld

FLANNEL_ETCD_ENDPOINTS="http://192.168.1.201:2379"    #修改etcd地址

etcdctl mk /atomic.io/network/config '{ "Network": "172.16.0.0/16" }'    #在etcd主机设置容器网络

master主机重启服务

systemctl start flanneld && systemctl enable flanneld
systemctl restart docker
systemctl restart kube-apiserver
systemctl restart kube-scheduler
systemctl restart kube-controller-manager

node主机重启服务

systemctl start flanneld && systemctl enable flanneld
systemctl restart docker
systemctl restart kubelet
systemctl restart kube-proxy

Linux公社的RSS地址https://www.linuxidc.com/rssFeed.aspx

本文永久更新链接地址https://www.linuxidc.com/Linux/2019-03/157693.htm

linux
相关资讯       Kubernetes安装 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款