k8s简介: 规划: 所需软件包: 安装部署: 到这里 三台服务器docker 安装完成!!! master安装; node节点安装: 到此node节点和master已安装完成!!! 配置etcd节点: vim /etc/etcd/etcd.conf 重启服务并计入开机自启: 配置master节点 启动核心组件: node节点配置: kubelet配置(node节点) 启动服务: 到此安装完成,验证节点状态: master上执行: 所有节点都已存在!!! 网络配置,所有节点(flannel): ansible k8s -m yum -a “name=flannel state=installed” master 创建网络并验证: master重启服务: 配置镜像仓库: master节点 到此k8s 基础环境搭建完成!!! 第一次写文章,有很多不足的地方,请各位大神指导!!谢谢
k8s全称kubernetes,k8s是一个完备的分布式系统,具备集群管理,自我修复、滚动升级和在线扩容能力。同时还提供了完善的管理工具,包含了开发,测试,运维各个环节。
ip
Hostname
192.168.100.203
k8s-master
192.168.100.204
k8s-node1
192.168.100.205
k8s-node2
docker-k8s.tar
k8s-master.zip
k8s-node.tar
docker安装:(三台机器全部需要安装)
解压后会出现pkg目录,查看pkg目录下的安装是否正常
k8s-master:
tar -xf docker-k8s.tar
安装pkg目录下的所有软件包:yum localinstall *.rpm
k8s-node1:
tar -xf k8s-node.tar
安装pkg目录下的所有软件包:yum localinstall *.rpm
k8s-node2:
tar -xf k8s-node.tar
安装pkg目录下的所有软件包:yum localinstall *.rpm
k8s-master安装:(只在master节点安装)
进入到解压目录
/opt/packages/k8s-master
unzip k8s-master.zip
安装软件包:
yum localinstall -y *.rpm
拷贝安装到packages目录下
ansible node -m copy -a “src=/data/packages/k8s/k8s-node.tar dest=/opt/packages”
k8s-node1:
mkdir node
tar -xf k8s-node.tar -C node
yum install -y *.rpm
k8s-node2:
mkdir node
tar -xf k8s-node.tar -C node
yum install -y *.rpm
修改以下两行:
** 6 ETCD_LISTEN_CLIENT_URLS=“https://0.0.0.0:2379” —-监听地址**
21 ETCD_ADVERTISE_CLIENT_URLS=“https://192.168.100.203:2379” —-客户端连接地址,本地ip地址
systemctl restart etcd
systemctl enable etcd
测试:
etcd配置成功!!!
apiserver配置:
vim /etc/kubernetes/apiserver
KUBE_API_ADDRESS=”–insecure-bind-address=0.0.0.0″ —监听地址
KUBE_API_PORT=”–port=8080″ —api端口
KUBELET_PORT=”–kubelet-port=10250″ —kublete端口
KUBE_ETCD_SERVERS=”–etcd-servers=https://192.168.100.203:2379″ —etcd地址
KUBE_SERVICE_ADDRESSES=”–service-cluster-ip-range=10.254.0.0/16″ —service地址范围。组件
control=NamespaceLifecycle,NamespaceExists,LimitRanger,SecurityContextDeny,ResourceQuota” —去掉ServiceAccount,认证相关,因为我们无法获取认证,所以去掉
systemctl enable kube-apiserver
systemctl start kube-apiserver
systemctl enable kube-controller-manager
systemctl start kube-controller-manager
systemctl enable kube-scheduler
systemctl start kube-scheduler
k8s-node1和k8s-node2全部操作:
vim /etc/kubernetes/config
KUBE_MASTER=”–master=https://192.168.100.203:8080″
vim /etc/kubernetes/kubelet
KUBELET_ADDRESS=”–address=0.0.0.0″ —–监听地址
KUBELET_PORT=”–port=10250″ —–kublete端口
KUBELET_HOSTNAME=”–hostname-override=192.168.100.205″ —–hostname本机ip地址即可
KUBELET_API_SERVER=”–api-servers=https://192.168.100.203:8080″ —–apiserver地址
KUBELET_POD_INFRA_CONTAINER=”–pod-infra-container-image=registry.access.redhat.com/rhel7/pod-infrastructure:latest”
systemctl enable kubelet
systemctl start kubelet
systemctl enable kube-proxy
systemctl start kube-proxy
kubectl get nodes
修改配置文件:
k8s-master
sed -i ‘s#127.0.0.1:2379#192.168.100.203:2379#g’ /etc/sysconfig/flanneld
k8s-node1
sed -i ‘s#127.0.0.1:2379#192.168.100.203:2379#g’ /etc/sysconfig/flanneld
k8s-node2
sed -i ‘s#127.0.0.1:2379#192.168.100.203:2379#g’ /etc/sysconfig/flanneld
etcdctl mk /atomic.io/network/config ‘{ “Network”: “172.16.0.0/16”}’
etcdctl get /atomic.io/network/config
成功!!!
[root@k8s-master ~]# systemctl restart kube-apiserver
[root@k8s-master ~]# systemctl restart docker
[root@k8s-master ~]# systemctl restart kube-controller-manager
[root@k8s-master ~]# systemctl restart kube-scheduler
[root@k8s-master ~]# systemctl start flanneld
[root@k8s-master ~]# systemctl eanble flanneld
node节点重启服务:
ansible node -m service -a ‘name=flanneld state=started’
ansible node -m service -a ‘name=flanneld enabled=yes’
ansible node -m service -a ‘name=docker state=restarted’
ansible node -m service -a ‘name=kubelet state=restarted’
查看网卡:ifconfig -a
修改docker 配置文件:
vim /etc/sysconfig/docker
–registry-mirror=https://换成你自己的阿里云加速地址或者docker’官方地址 –insecure-registry=192.168.100.203:5000
重启docker
systemctl restart docker
创建本地仓库:
[root@k8s-master ~]# docker run -d -p 5000:5000 –restart=always –name registry -v /opt/myregistry:/var/lib/registry registry
测试:
[root@k8s-master ~]# docker pull nginx
docker tag nginx 192.168.100.203/test/nginx:v1
上传镜像:
[root@k8s-master ~]# docker push 192.168.100.203:5000/test/nginx:v1
node节点:
node1
[root@k8s-node1 node]# vim /etc/sysconfig/docker
–insecure-registry=192.168.100.203:5000
node2
[root@k8s-node2 /]# vim /etc/sysconfig/docker
–insecure-registry=192.168.100.203:5000
测试仓库:
docker pull 192.168.100.203:5000/test/nginx:v1
本地镜像仓库完成!!!
本网页所有视频内容由 imoviebox边看边下-网页视频下载, iurlBox网页地址收藏管理器 下载并得到。
ImovieBox网页视频下载器 下载地址: ImovieBox网页视频下载器-最新版本下载
本文章由: imapbox邮箱云存储,邮箱网盘,ImageBox 图片批量下载器,网页图片批量下载专家,网页图片批量下载器,获取到文章图片,imoviebox网页视频批量下载器,下载视频内容,为您提供.
阅读和此文章类似的: 全球云计算