KUBERNETES-1.52 集羣搭建

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


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章