k8s架构图

环境介绍

本次部署使用两台centos7.2虚拟机,最小化安装,一台作为管理节点,一台作为服务节点,均关闭selinux和firewalld服务

主机服务
k8s-masterapiserver,controller-manager,scheduler,etcd
k8s-node1docker,kubelet,kube-proxy,flannel
10.10.84.112    k8s-node1
10.10.84.111    k8s-master k8s-etcd

部署k8s-master:

  • 安装etcd
[root@k8s-master ~]# yum install -y etcd-3.1.9-2.el7.x86_64
[root@k8s-master ~]# vim /etc/etcd/etcd.conf
ETCD_LISTEN_CLIENT_URLS="http://0.0.0.0:2379"
ETCD_ADVERTISE_CLIENT_URLS="http://k8s-etcd:2379"
[root@k8s-master ~]# etcdctl --endpoints http://10.10.84.111:2379 set /atomic.io/network/config '{"Network":"172.17.0.0/16"}'
[root@k8s-master ~]# systemctl enable etcd
[root@k8s-master ~]# systemctl restart etcd
  • 安装kubernets-master
[root@k8s-master ~]# yum -y install kubernetes-master-1.5.2-0.7
[root@k8s-master ~]# vim /etc/kubernetes/apiserver
KUBE_API_ADDRESS="--insecure-bind-address=0.0.0.0"
KUBE_ETCD_SERVERS="--etcd-servers=http://k8s-etcd:2379"
KUBE_ADMISSION_CONTROL="--admission-control=NamespaceLifecycle,NamespaceExists,LimitRanger,ResourceQuota"
[root@k8s-master ~]# vim /etc/kubernetes/config
KUBE_MASTER="--master=http://k8s-master:8080"
[root@k8s-master ~]# systemctl enable kube-apiserver kube-scheduler kube-controller-manager
[root@k8s-master ~]# systemctl start kube-apiserver kube-scheduler kube-controller-manager

测试k8s-master,返回json描述信息

http://k8s-master:8080

json

部署k8s-node

  • 安装docker
[root@k8s-node1 ~]# yum install docker-1.12.6-48.git0fdc778.el7.centos.x86_64
[root@k8s-node1 ~]# systemctl enable docker
[root@k8s-node1 ~]# systemctl start docker
  • 安装flannel
[root@k8s-node1 ~]# yum install flannel-0.7.1-2.el7
[root@k8s-node1 ~]# vim /etc/sysconfig/flanneld
FLANNEL_ETCD_ENDPOINTS="http://k8s-etcd:2379"
FLANNEL_ETCD_PREFIX="/atomic.io/network"
[root@k8s-node1 ~]# systemctl enable flanneld
[root@k8s-node1 ~]# systemctl start flanneld
  • 安装kubernetes-node
[root@k8s-node1 ~]# yum install kubernetes-node-1.5.2-0.7.git269f928.el7.x86_64
[root@k8s-node1 ~]# vim /etc/kubernetes/config
KUBE_MASTER="--master=http://k8s-master:8080"
[root@k8s-node1 ~]# vim /etc/kubernetes/kubelet
KUBELET_HOSTNAME="--hostname-override=k8s-node1"
KUBELET_API_SERVER="--api-servers=http://k8s-master:8080"
[root@k8s-node1 ~]# systemctl enable kubelet kube-proxy
[root@k8s-node1 ~]# systemctl start kubelet kube-proxy

测试

[root@k8s-master ~]# kubectl get node
NAME        STATUS    AGE
k8s-node1   Ready     5m
Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐