Kubernetes Cluster Installation Manual

Kubernetes Cluster Installation Manual


本文原文出处: http://blog.csdn.net/bluishglc/article/details/51970734 严禁任何形式的转载,否则将委托CSDN官方维护权益!

Master Node Installation & Configuration

Install Kubernetes which is the Orchestration System for Docker Containers.

For example, Configure Kubernetes Cluster with 1 Master Node and 2 Container Node like follows.

                       +---------------------+
                       |  [  Master Node  ]  |
                       |      kbnode-01      |
                       +----------+----------+
                                  |
+----------------------+          |          +----------------------+
|  [  Slave Node01  ]  |          |          |  [  Slave Node02  ]  |
|      kbnode-02       +----------+----------+       kbnode-03      |
+----------------------+                     +----------------------+

Configure Admon Node on this section.

[1] Install required packages.

[root@kbnode-01 ~]# yum -y install kubernetes etcd flannel

[2] Configure Kubernetes.

# generate RSA key

[root@kbnode-01 ~]# openssl genrsa -out /etc/kubernetes/service.key 2048
[root@kbnode-01 ~]# vi /etc/kubernetes/controller-manager
# line 7: add

KUBE_CONTROLLER_MANAGER_ARGS="--service_account_private_key_file=/etc/kubernetes/service.key
"
[root@kbnode-01 ~]# vi /etc/kubernetes/apiserver
# line 8: change

KUBE_API_ADDRESS="--address=0.0.0.0
"
# line 17: change to Admin Node's hostname or IP address

KUBE_ETCD_SERVERS="--etcd-servers=http://kbnode-01
:2379"
# line 20: IP range for Kubernetes service (change it if need)

KUBE_SERVICE_ADDRESSES="--service-cluster-ip-range=10.254.0.0/16"
# line 26: add

KUBE_API_ARGS="--service_account_key_file=/etc/kubernetes/service.key
"
[root@kbnode-01 ~]# vi /etc/etcd/etcd.conf
# line 7: uncomment

ETCD_LISTEN_PEER_URLS="http://localhost:2380"
# line 8: add etcd Host's hostname or IP address

ETCD_LISTEN_CLIENT_URLS="http://kbnode-01:2379
,http://localhost:2379"
[root@kbnode-01 ~]# vi /etc/kubernetes/config
# line 22: change to Admin Node's hostname or IP address

KUBE_MASTER="--master=http://kbnode-01
:8080"
[root@kbnode-01 ~]# systemctl start etcd kube-apiserver kube-controller-manager kube-scheduler

[root@kbnode-01 ~]# systemctl enable etcd kube-apiserver kube-controller-manager kube-scheduler

[3] Configure Flannel networking.

[root@kbnode-01 ~]# vi flannel-config.json
# create new

# specify network range you like which is used inside Container Nodes

{
  "Network":"172.16.0.0/16",
  "SubnetLen":24,
  "Backend":{
    "Type":"vxlan",
    "VNI":1
  }
}

[root@kbnode-01 ~]# vi /etc/sysconfig/flanneld
# line 4: change to Flannel Host's hostname or IP address

FLANNEL_ETCD="http://kbnode-01
:2379"
# line 8: confirm the parameter

FLANNEL_ETCD_KEY="/atomic.io/network"
[root@kbnode-01 ~]# etcdctl set atomic.io/network/config < flannel-config.json

[root@kbnode-01 ~]# systemctl start flanneld

[root@kbnode-01 ~]# systemctl enable flanneld

[4] Make sure th settings. It’s OK if following result is displayed.

[root@kbnode-01 ~]# kubectl cluster-info

Kubernetes master is running at http://localhost:8080 

Slave Node Installation & Configuration

Install Kubernetes which is the Orchestration System for Docker Containers.
For example, Configure Kubernetes Cluster with 1 Admon Node and 2 Container Node like follows.

                       +---------------------+
                       |  [  Master Node  ]  |
                       |      kbnode-01      |
                       +----------+----------+
                                  |
+----------------------+          |          +----------------------+
|  [  Slave Node01  ]  |          |          |  [  Slave Node02  ]  |
|      kbnode-02       +----------+----------+       kbnode-03      |
+----------------------+                     +----------------------+

Configure Container Node on this section.
[1] Install and Start Docker service on All Nodes, refer to here.

[2] Install Kubernetes and Flannel on All Nodes.

[root@kbnode-02 ~]# yum -y install kubernetes flannel

[3] Configure Kubernetes on all Nodes like follows.

[root@kbnode-02 ~]# vi /etc/kubernetes/config

# line 22: change to Admin Node's hostname or IP address
KUBE_MASTER="--master=http://kbnode-01
:8080"
[root@kbnode-02 ~]# vi /etc/kubernetes/kubelet
# line 5: change

KUBELET_ADDRESS="--address=0.0.0.0
"
# line 11: change to own hostname

KUBELET_HOSTNAME="--hostname-override=kbnode-02
"
# line 14: change to Admin Node's hostname or IP address

KUBELET_API_SERVER="--api-servers=http://kbnode-01
:8080"
[root@kbnode-02 ~]# vi /etc/sysconfig/flanneld
# line 4: change to Admin Node's hostname or IP address

FLANNEL_ETCD="http://kbnode-01
:2379"
# stop docker0 interface

[root@kbnode-02 ~]# /sbin/ifconfig docker0 down
[root@kbnode-02 ~]# brctl delbr docker0 

Connection 'docker0' successfully deactivated
(D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/1)
[root@kbnode-02 ~]# systemctl start flanneld kube-proxy kubelet

[root@kbnode-02 ~]# systemctl enable flanneld kube-proxy kubelet

[root@kbnode-02 ~]# systemctl restart docker

[4] Make sure th settings. It’s OK if the status of each node is Ready like follows.

[root@kbnode-01 ~]# kubectl get nodes

NAME        STATUS    AGE
kbnode-02   Ready     5d
kbnode-03   Ready     5d

Tips

Restart Master Node

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

Restart Slave Node

for SERVICES in kube-proxy kubelet flanneld; do 
    sudo systemctl stop $SERVICES
    sudo systemctl status $SERVICES 
done

sudo systemctl stop docker
sudo /sbin/ifconfig docker0 down
sudo brctl delbr docker0 
sudo systemctl start docker
sudo systemctl status docker 

Clean Kubenetes

for ITEM in rc services pods; do
    sudo kubectl --namespace=your-namespace delete $ITEM --all --cascade
    sudo kubectl --namespace=your-namespace get $ITEM
done

Check Pod IP

kubectl --namespace=your-namespace get pods -o yaml | grep podIP:

FAQ

[1] How to confirm if flannel network is available?

Check network configuration with ifconfig , if flannel network is avaiable, there should be 2 interfaces: doecer0 and flannel.1, and the most important is the IP of doecer0 should be in the same subnet with the IP of flannel.1, it usually looks as following:


Reference Doc: http://www.server-world.info/en/note?os=CentOS_7&p=kubernetes&f=1

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Laurence 

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值