K8S入門系列之集羣yum安裝-->初試篇(一)

kubernetes master 節點包含的組件:

一、kube-apiserver :集羣核心,集羣API接口、集羣各個組件通訊的中樞;集羣安全控制; 二、kube-scheduler: 集羣調度器 ,根據node負載(cpu、內存、存儲、策略等)將pod分配到合適node。 三、kube-controller-manager:集羣狀態管理器 。當集羣狀態與集羣指望值不一樣時,該控制器會根據已有策略將其恢復到指定狀態。 kube-scheduler、kube-controller-manager 和 kube-apiserver 三者的功能緊密相關,前須要部署在同一臺機器上。 四、etcd 一個高可用的K/V鍵值對存儲和服務發現系統node

注意:集羣只能有一個 kube-scheduler、kube-controller-manager 進程處於工做狀態,若是運行多個,則須要經過選舉產生一個 leaderlinux

kubernetes node 節點包含的組件:

一、kubelet 在Node節點上按照配置文件中定義的容器規格啓動容器 二、kube-proxy 提供網絡代理服務,將service與pod打通。 三、flannel 實現誇主機的容器網絡的通訊 四、docker 這個就不用說了!docker

安裝環境準備:

一、關閉防火牆服務,避免與docker容器的防火牆規則衝突。api

[root@localhost ~]# systemctl disable firewalld
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
   Active: inactive (dead)
     Docs: man:firewalld(1)

二、關閉selinux 修改/etc/selinux/config爲SELINUX=disabled安全

[root@localhost ~]# getenforce 
Disabled

1、master安裝部署

一、安裝master組件:

kubernetes-master (包含:kube-apiserver、kube-scheduler、kube-controller-manager) etcd服務器

[root@localhost ~]# yum install etcd kubernetes-master -y

二、編輯/etc/etcd/etcd.conf文件

ETCD_DATA_DIR="/var/lib/etcd/default.etcd"
ETCD_LISTEN_CLIENT_URLS="http://0.0.0.0:2379"        #監聽全部IP的2379端口
ETCD_NAME="default"        #etcd名字,沒有高可用只有一臺的話可用默認!
ETCD_ADVERTISE_CLIENT_URLS="http://localhost:2379"

三、編輯/etc/kubernetes/apiserver文件

###
# kubernetes system config
#
# The following values are used to configure the kube-apiserver
#

# The address on the local server to listen to.
KUBE_API_ADDRESS="--insecure-bind-address=0.0.0.0"

# The port on the local server to listen on.
KUBE_API_PORT="--port=8080"

# Port minions listen on
KUBELET_PORT="--kubelet-port=10250"

# Comma separated list of nodes in the etcd cluster
KUBE_ETCD_SERVERS="--etcd-servers=http://192.168.1.201:2379"

# Address range to use for services
KUBE_SERVICE_ADDRESSES="--service-cluster-ip-range=10.254.0.0/16"

# default admission control policies
KUBE_ADMISSION_CONTROL="--admission-control=NamespaceLifecycle,NamespaceExists,LimitRanger,ResourceQuota"

# Add your own!
KUBE_API_ARGS=""

四、/etc/kubernetes/config

KUBE_MASTER="--master=http://127.0.0.1:8080" 默認指向本機不需修改!網絡

啓動etcd、kube-apiserver、kube-controller-manager、kube-scheduler等服務,並設置開機啓動。

五、在etcd中定義flannel網絡

[root@master01 ~]# etcdctl mk /atomic.io/network/config '{"Network":"172.80.0.0/16"}'

2、node安裝部署 (適用全部node)

1,安裝flannel和kubernetes-node

[root@node01 ~]# yum install kubernetes-node flannel -y

二、爲flannel網絡指定etcd服務,修改/etc/sysconfig/flanneld文件

# Flanneld configuration options  

# etcd url location.  Point this to the server where etcd runs
FLANNEL_ETCD_ENDPOINTS="http://192.168.1.201:2379"    # 192.168.1.201爲etcd所在服務器的IP(可設置多個--高可用)!

# etcd config key.  This is the configuration key that flannel queries
# For address range assignment
FLANNEL_ETCD_PREFIX="/atomic.io/network"

# Any additional options that you want to pass
#FLANNEL_OPTIONS=""

三、修改/etc/kubernetes/config文件

###
# kubernetes system config
#
# The following values are used to configure various aspects of all
# kubernetes services, including
#
#   kube-apiserver.service
#   kube-controller-manager.service
#   kube-scheduler.service
#   kubelet.service
#   kube-proxy.service
# logging to stderr means we get it in the systemd journal
KUBE_LOGTOSTDERR="--logtostderr=true"

# journal message level, 0 is debug
KUBE_LOG_LEVEL="--v=0"

# Should this cluster be allowed to run privileged docker containers
KUBE_ALLOW_PRIV="--allow-privileged=false"

# How the controller-manager, scheduler, and proxy find the apiserver
KUBE_MASTER="--master=http://192.168.1,201:8080"        #192.168.1.201爲master所在服務器的IP!

四、修改node節點配置文件/etc/kubernetes/kubelet

###
# kubernetes kubelet (minion) config

# The address for the info server to serve on (set to 0.0.0.0 or "" for all interfaces)
KUBELET_ADDRESS="--address=0.0.0.0"

# The port for the info server to serve on
KUBELET_PORT="--port=10250"

# You may leave this blank to use the actual hostname
KUBELET_HOSTNAME="--hostname-override=192.168.1.202"        #192.168.1.202爲本機node的IP!

# location of the api-server
KUBELET_API_SERVER="--api-servers=http://192.168.1.201:8080"    #192.168.1.201爲apiserver所在服務器的IP!

# pod infrastructure container
KUBELET_POD_INFRA_CONTAINER="--pod-infra-container-image=registry.access.redhat.com/rhel7/pod-infrastructure:latest"

# Add your own!
KUBELET_ARGS=""

五、啓動flanneld,docker,kube-proxy,kubelet服務,並設置開機啓動。要按如下順序etcd—->flannel—–>docker啓動,不然會致使pod裏邊的ip會和其餘node節點的pod不在一個網段,通訊就有問題。

相關文章
相關標籤/搜索