码迷,mamicode.com
首页 > Web开发 > 详细

KUBERNETES-1.52 集群搭建

时间:2017-10-30 21:19:20      阅读:347      评论:0      收藏:0      [点我收藏+]

标签:kubernetes   etcd   flannel   

KUBERNETES 集群搭建

基础环境

系统环境

# cat /etc/redhat-release
CentOS Linux release 7.3.1611 (Core)

主机名设置

centos-master   192.168.59.135

centos-minion1  192.168.59.132

centos-minion2  192.168.59.133

关闭Selinux 和 Firewalld 后重启服务器

# systemctl stop firewalld
# systemctl disable firewalld

# setenforce 0
# sed -i ‘s/^SELINUX=.*/SELINUX=disableds/‘ /etc/selinux/config

Master 节点安装部署

#yum install etcd kubernetes -y

安装的版本

# rpm -qa | grep etcd

etcd-3.2.7-1.el7.x86_64

# rpm -qa | grep kubernetes

kubernetes-client-1.5.2-0.7.git269f928.el7.x86_64
kubernetes-1.5.2-0.7.git269f928.el7.x86_64
kubernetes-master-1.5.2-0.7.git269f928.el7.x86_64
kubernetes-node-1.5.2-0.7.git269f928.el7.x86_64

配置ETCD /Etc/Etcd/Etcd.Conf

# cat /etc/etcd/etcd.conf  | grep -Ev "^#|^$"

ETCD_NAME=centos-master
ETCD_DATA_DIR="/var/lib/etcd/default.etcd"
ETCD_LISTEN_PEER_URLS="http://0.0.0.0:2380"
ETCD_LISTEN_CLIENT_URLS="http://0.0.0.0:2379"
ETCD_INITIAL_ADVERTISE_PEER_URLS="http://192.168.59.135:2380"
ETCD_INITIAL_CLUSTER="centos-master=http://192.168.59.135:2380,centos-minion2=http://192.168.59.133:2380,centos-minion1=http://192.168.59.132:2380"
ETCD_INITIAL_CLUSTER_STATE="new"
ETCD_INITIAL_CLUSTER_TOKEN="etcd-cluster"
ETCD_ADVERTISE_CLIENT_URLS="http://192.168.59.135:2379"

配置Kubernetes API Server (/Etc/Kubernetes/Apiserver)

# cat /etc/kubernetes/apiserver  | grep -Ev "^#|^$"

KUBE_API_ADDRESS="--insecure-bind-address=0.0.0.0"
KUBE_API_PORT="--port=8080"
KUBELET_PORT="--kubelet-port=10250"
KUBE_ETCD_SERVERS="--etcd-servers=http://127.0.0.1:2379"
KUBE_SERVICE_ADDRESSES="--service-cluster-ip-range=10.254.0.0/16"
KUBE_ADMISSION_CONTROL="--admission-control=NamespaceLifecycle,NamespaceExists,LimitRanger,SecurityContextDeny,ResourceQuota"
KUBE_API_ARGS=""

配置Kubernetes Config (/Etc/Kubernetes/Config)

# cat /etc/kubernetes/config  | grep -Ev "^#|^$"

KUBE_LOGTOSTDERR="--logtostderr=true"
KUBE_LOG_LEVEL="--v=0"
KUBE_ALLOW_PRIV="--allow-privileged=false"
KUBE_MASTER="--master=http://centos-master:8080"

Minion 节点安装(Minion1和Minion2)

# yum install flannel etcd docker kubernetes -y

配置ETCD (/Etc/Etcd/Etcd.Conf)

# grep -Ev "^#|^$" /etc/etcd/etcd.conf 

ETCD_NAME=centos-minion2
ETCD_DATA_DIR="/var/lib/etcd/default.etcd"
ETCD_LISTEN_PEER_URLS="http://0.0.0.0:2380"
ETCD_LISTEN_CLIENT_URLS="http://0.0.0.0:2379"
ETCD_INITIAL_ADVERTISE_PEER_URLS="http://192.168.59.133:2380"
ETCD_INITIAL_CLUSTER="centos-master=http://192.168.59.135:2380,centos-minion2=http://192.168.59.133:2380,centos-minion1=http://192.168.59.132:2380"
ETCD_INITIAL_CLUSTER_STATE="new"
ETCD_INITIAL_CLUSTER_TOKEN="etcd-cluster"
ETCD_ADVERTISE_CLIENT_URLS="http://192.168.59.133:2379"

# grep -Ev "^#|^$" /etc/etcd/etcd.conf 

ETCD_NAME=centos-minion1
ETCD_DATA_DIR="/var/lib/etcd/default.etcd"
ETCD_LISTEN_PEER_URLS="http://0.0.0.0:2380"
ETCD_LISTEN_CLIENT_URLS="http://0.0.0.0:2379"
ETCD_INITIAL_ADVERTISE_PEER_URLS="http://192.168.59.132:2380"
ETCD_INITIAL_CLUSTER="centos-master=http://192.168.59.135:2380,centos-minion2=http://192.168.59.133:2380,centos-minion1=http://192.168.59.132:2380"
ETCD_INITIAL_CLUSTER_STATE="new"
ETCD_INITIAL_CLUSTER_TOKEN="etcd-cluster"
ETCD_ADVERTISE_CLIENT_URLS="http://192.168.59.132:2379"

配置 Flannel (/Etc/Sysconfig/Flanneld)

# grep -Ev "^#|^$" /etc/sysconfig/flanneld

FLANNEL_ETCD_ENDPOINTS="http://192.168.59.133:2379"
FLANNEL_ETCD_PREFIX="/atomic.io/network"

配置 Kubelet (/Etc/Kubernetes/Kubelet)

# grep -Ev "^#|^$" /etc/kubernetes/kubelet 
KUBELET_ADDRESS="--address=0.0.0.0"
KUBELET_PORT="--port=10250"
KUBELET_HOSTNAME="--hostname-override=centos-minion2"
KUBELET_API_SERVER="--api-servers=http://centos-master:8080"

# 下面请填写你的registry地址,如果你能连接到任何网络,请自动过滤
KUBELET_POD_INFRA_CONTAINER="--pod-infra-container-image=registry.access.redhat.com/rhel7/pod-infrastructure:latest"

# 下面填写你的dns信息,例如
# KUBELET_ARGS="--cluster-dns=192.168.51.198 --cluster-domain=atomic.io/network"
KUBELET_ARGS=""

启动程序 On Master

for SERVICES  in etcd  kube-apiserver kube-controller-manager kube-scheduler;  do
    systemctl restart $SERVICES
    systemctl enable $SERVICES
    systemctl status $SERVICES -l
done

etcd 网络配置

# etcdctl mk /atomic.io/network/config ‘{"Network":"172.17.0.0/16"}‘

启动程序 On Minion

for SERVICES in  etcd kube-proxy kubelet docker flanneld; do
    systemctl restart $SERVICES
    systemctl enable $SERVICES
    systemctl status $SERVICES 
done

查看 Etcd 集群情况 (随便一台都可以)

# etcdctl member list

10a23ff41e3abcb8: name=centos-minion1 peerURLs=http://192.168.59.132:2380 clientURLs=http://192.168.59.132:2379 isLeader=false
168ea6ce7632b2e4: name=centos-minion2 peerURLs=http://192.168.59.133:2380 clientURLs=http://192.168.59.133:2379 isLeader=true
587d83f824bf96c6: name=centos-master peerURLs=http://192.168.59.135:2380 clientURLs=http://192.168.59.135:2379 isLeader=false

# etcdctl cluster-health

member 10a23ff41e3abcb8 is healthy: got healthy result from http://192.168.59.132:2379
member 168ea6ce7632b2e4 is healthy: got healthy result from http://192.168.59.133:2379
member 587d83f824bf96c6 is healthy: got healthy result from http://192.168.59.135:2379
cluster is healthy

查看 节点情况(在 Master)

# kubectl get nodes

NAME             STATUS    AGE
centos-minion1   Ready     1h
centos-minion2   Ready     1h

查看Flannel网卡

[root@centos-minion1 ~]# ifconfig flannel0

flannel0: flags=4305<UP,POINTOPOINT,RUNNING,NOARP,MULTICAST>  mtu 1472
        inet 172.17.34.0  netmask 255.255.0.0  destination 172.17.34.0
        unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  txqueuelen 500  (UNSPEC)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0



[root@centos-minion2 ~]# ifconfig flannel0

flannel0: flags=4305<UP,POINTOPOINT,RUNNING,NOARP,MULTICAST>  mtu 1472
        inet 172.17.59.0  netmask 255.255.0.0  destination 172.17.59.0
        inet6 fe80::2d54:2169:1a0:d364  prefixlen 64  scopeid 0x20<link>
        unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  txqueuelen 500  (UNSPEC)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 3  bytes 144 (144.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0


本文出自 “bamboo” 博客,请务必保留此出处http://wuyebamboo.blog.51cto.com/3344855/1977496

KUBERNETES-1.52 集群搭建

标签:kubernetes   etcd   flannel   

原文地址:http://wuyebamboo.blog.51cto.com/3344855/1977496

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!