Kubernetes的安裝配置

1.環境準備:node

  三臺服務器:linux

  192.168.42.128  master+nodegit

  192.168.42.129  node1docker

  192.168.42.130  node2centos

2.準備yum源api

vi virt7-docker-common-release.repo

[virt7-docker-common-release]
    name=virt7-docker-common-release
    baseurl=http://cbs.centos.org/repos/virt7-docker-common-release/x86_64/os/
    gpgcheck=0

3.安裝組件分類服務器

master包含     kube-apiserver 
               kube-scheduler 
               kube-controller-manager 
               etcd四個組件
node包含       kube-proxy 
               kubelet 
               flannel 3個組件                   


1. kube-apiserver:位於master節點,接受用戶請求。
2. kube-scheduler:位於master節點,負責資源調度,即pod建在哪一個node節點。
3. kube-controller-manager:位於master節點,包含ReplicationManager,Endpointscontroller,Namespacecontroller,and Nodecontroller等。
4. etcd:分佈式鍵值存儲系統,共享整個集羣的資源對象信息。
5. kubelet:位於node節點,負責維護在特定主機上運行的pod。
6. kube-proxy:位於node節點,它起的做用是一個服務代理的角色
7. flannel:網絡配置

4.關閉而且禁用防火牆網絡

systemctl stop firewalld
systemctl disable firewalld

5.關閉而且禁用Enforcing分佈式

setenforce 0
getenforce

vi /etc/selinux/config
修改:SELINUX=disabled

6.設置NTP同步ide

*/5 * * * * /usr/sbin/ntpdate cn.ntp.org.cn

7.安裝kubernetes master節點

yum install etcd

Dependencies Resolved

=================================================================================================
 Package       Arch            Version                Repository                            Size
=================================================================================================
Installing:
 etcd          x86_64          2.0.9-1.el7            virt7-docker-common-release          2.9 M

Transaction Summary
=================================================================================================
Install  1 Package

 

yum install kubernetes

Dependencies Resolved

=================================================================================================
 Package              Arch      Version                     Repository                      Size
=================================================================================================
Installing:
 kubernetes           x86_64    1.1.0-0.4.git2bfa9a1.el7    virt7-docker-common-release     26 k
Installing for dependencies:
 docker               x86_64    1.6.2-4.gitc3ca5bb.el7      virt7-docker-common-release    5.0 M
 kubernetes-client    x86_64    1.1.0-0.4.git2bfa9a1.el7    virt7-docker-common-release    3.0 M
 kubernetes-master    x86_64    1.1.0-0.4.git2bfa9a1.el7    virt7-docker-common-release     14 M
 kubernetes-node      x86_64    1.1.0-0.4.git2bfa9a1.el7    virt7-docker-common-release    9.8 M
 socat                x86_64    1.7.2.2-5.el7               base                           255 k

Transaction Summary
=================================================================================================
Install  1 Package (+5 Dependent packages)

vi /etc/etcd/etcd.conf

# [member]
ETCD_NAME=default
ETCD_DATA_DIR="/var/lib/etcd/default.etcd"
#ETCD_SNAPSHOT_COUNTER="10000"
#ETCD_HEARTBEAT_INTERVAL="100"
#ETCD_ELECTION_TIMEOUT="1000"
#ETCD_LISTEN_PEER_URLS="http://localhost:2380,http://localhost:7001" ETCD_LISTEN_CLIENT_URLS="http://0.0.0.0:2379"
#ETCD_MAX_SNAPSHOTS="5"
#ETCD_MAX_WALS="5"
#ETCD_CORS=""
#
#[cluster]
#ETCD_INITIAL_ADVERTISE_PEER_URLS="http://localhost:2380,http://localhost:7001"
# if you use different ETCD_NAME (e.g. test), set ETCD_INITIAL_CLUSTER value for this name, i.e. "test=http://..."
#ETCD_INITIAL_CLUSTER="default=http://localhost:2380,default=http://localhost:7001"
#ETCD_INITIAL_CLUSTER_STATE="new"
#ETCD_INITIAL_CLUSTER_TOKEN="etcd-cluster"
#ETCD_ADVERTISE_CLIENT_URLS="http://localhost:2379,http://localhost:4001" ETCD_ADVERTISE_CLIENT_URLS="http://localhost:2379"
#ETCD_DISCOVERY=""
#ETCD_DISCOVERY_SRV=""
#ETCD_DISCOVERY_FALLBACK="proxy"
#ETCD_DISCOVERY_PROXY=""
#
#[proxy]
#ETCD_PROXY="off"
#
#[security]
#ETCD_CA_FILE=""
#ETCD_CERT_FILE=""
#ETCD_KEY_FILE=""
#ETCD_PEER_CA_FILE=""
#ETCD_PEER_CERT_FILE=""
#ETCD_PEER_KEY_FILE=""

vi /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=127.0.0.1" 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://127.0.0.1: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,SecurityContextDeny,ServiceAccount,ResourceQuota"

# Add your own!
KUBE_API_ARGS=""

vi /etc/kubernetes/controller-manager

###
# The following values are used to configure the kubernetes controller-manager

# defaults from config and apiserver should be adequate

# Add your own!
#KUBE_CONTROLLER_MANAGER_ARGS="" KUBE_CONTROLLER_MANAGER_ARGS="--node-monitor-grace-period=10s --pod-eviction-timeout=10s"

vi /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.42.128:8080"

設置服務啓動

systemctl status etcd kube-apiserver kube-scheduler kube-controller-manager
systemctl enable etcd kube-apiserver kube-scheduler kube-controller-manager

定義kubernetes的網絡

etcdctl mk /coreos.com/network/config '{"Network":"172.17.0.0/16"}' 

 

8.安裝kubernetes node節點

yum -y install kubernetes-node

Dependencies Resolved

=================================================================================================
 Package              Arch      Version                     Repository                      Size
=================================================================================================
Installing:
 kubernetes-node      x86_64    1.1.0-0.4.git2bfa9a1.el7    virt7-docker-common-release    9.8 M
Installing for dependencies:
 docker               x86_64    1.6.2-4.gitc3ca5bb.el7      virt7-docker-common-release    5.0 M
 kubernetes-client    x86_64    1.1.0-0.4.git2bfa9a1.el7    virt7-docker-common-release    3.0 M
 socat                x86_64    1.7.2.2-5.el7               base                           255 k

Transaction Summary
=================================================================================================
Install  1 Package (+3 Dependent packages)
yum -y install flannel

Dependencies Resolved

=================================================================================================
 Package         Arch           Version                Repository                           Size
=================================================================================================
Installing:
 flannel         x86_64         0.2.0-7.el7            virt7-docker-common-release         1.3 M

Transaction Summary
=================================================================================================
Install  1 Package

修改配置文件/etc/kubernetes

vi /etc/kubernetes/config

[root@node1 kubernetes]# cat /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://127.0.0.1:8080" KUBE_MASTER="--master=http://192.168.42.128:8080"

vi /etc/kubernetes/kubelet

[root@node1 kubernetes]# cat /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=127.0.0.1"

# 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=127.0.0.1" KUBELET_HOSTNAME="--hostname-override=192.168.42.129"

# location of the api-server
#KUBELET_API_SERVER="--api-servers=http://127.0.0.1:8080" KUBELET_API_SERVER="--api-servers=http://192.168.42.128:8080"

# Add your own!
#KUBELET_ARGS="" KUBELET_ARGS="--pod-infra-container-image=kubernetes/pause"

vi /etc/sysconfig/flanneld

# Flanneld configuration options  

# etcd url location.  Point this to the server where etcd runs
#FLANNEL_ETCD="http://127.0.0.1:4001" FLANNEL_ETCD="http://192.168.42.128:2379"

# etcd config key.  This is the configuration key that flannel queries
# For address range assignment
FLANNEL_ETCD_KEY="/coreos.com/network"

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

啓動服務

systemctl status kube-proxy flanneld kubelet docker
systemctl enable kube-proxy flanneld kubelet docker
相關文章
相關標籤/搜索