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

ovn-kubernetes安装指南

时间:2017-09-12 17:42:50      阅读:527      评论:0      收藏:0      [点我收藏+]

标签:子网   dev   默认   update   plugin   ddr   scripts   download   补充   

Master节点的安装

1、首先在master节点安装ovs和ovn:

#!/bin/bash

sudo apt-get install openvswitch-common openvswitch-switch

sudo apt-get install ovn-common ovn-central ovn-host

  

源文件参见我的github(下文同理):https://github.com/YaoZengzeng/scripts/blob/master/ovn-central.sh

 

2、下载并安装ovn-kubernetes:

git clone https://github.com/openvswitch/ovn-kubernetes
cd ovn-kubernetes
pip install .

  

3、对ovn master节点进行初始化:

#!/bin/bash

NODE_NAME=

CENTRAL_IP=
LOCAL_IP=

CLUSTER_IP_SUBNET=
MASTER_SWITCH_SUBNET=

ovs-vsctl set Open_vSwitch . external_ids:ovn-remote="tcp:$CENTRAL_IP:6642"   external_ids:ovn-nb="tcp:$CENTRAL_IP:6641"   external_ids:ovn-encap-ip="$LOCAL_IP"   external_ids:ovn-encap-type="geneve"

ovs-vsctl set Open_vSwitch . external_ids:k8s-api-server="127.0.0.1:8080"

ovn-k8s-overlay master-init   --cluster-ip-subnet=$CLUSTER_IP_SUBNET   --master-switch-subnet="$MASTER_SWITCH_SUBNET"   --node-name="$NODE_NAME"

  

其中NODE_NAME为master节点的hostname,CENTRAL_IP和LOCAL_IP对于master节点是一样的,都是master节点自身的IP地址,CLUSTER_IP_SUBNET为整个集群的子网范围,例如192.168.0.0/16,而MASTER_SWITCH_SUBNET则为master节点上的pod能够分配的子网范围,例如192.168.1.0/24

源码链接:https://github.com/YaoZengzeng/scripts/blob/master/ovn-k8s-master.sh

 

4、最开始我是使用kubeadm搭建k8s集群的,但是当通过http://127.0.0.1:8080访问api server时会发现该端口并未打开,可能是kubeadm默认是不打开该端口的,因此只能使用手动方式搭建kubernetes。首先下载并安装kubernetes:

#!/bin/bash

# Install docker
apt-get update
apt-get install -y docker.io

mkdir k8s
cd k8s

wget https://github.com/kubernetes/kubernetes/releases/download/v1.5.3/kubernetes.tar.gz

tar xvzf kubernetes.tar.gz

./kubernetes/cluster/get-kube-binaries.sh

mkdir server

cd server

tar xvzf ../kubernetes/server/kubernetes-server-linux-amd64.tar.gz

cd kubernetes/server/bin

cp kube-apiserver kube-controller-manager kube-scheduler kubelet kubectl /usr/bin

# Install cni
mkdir -p /opt/cni/bin && cd /opt/cni/bin

wget https://github.com/containernetworking/cni/releases/download/v0.5.2/cni-amd64-v0.5.2.tgz

tar xvzf cni-amd64-v0.5.2.tgz

 

源码连接:https://github.com/YaoZengzeng/scripts/blob/master/k8s-download.sh

 

5、接着运行kubernetes的各个组件:

#!/bin/bash

# On the master node, start etcd
docker run   --net=host   --detach   gcr.io/google_containers/etcd:2.0.12   /usr/local/bin/etcd     --addr=127.0.0.1:4001     --bind-addr=0.0.0.0:4001     --data-dir=/var/etcd/data

# install kube-apiserver
nohup kube-apiserver   --service-cluster-ip-range=192.168.200.0/24   --address=0.0.0.0   --etcd-servers=http://127.0.0.1:4001   --v=2   2>&1 > /dev/null &


# install kube-controller-manager
nohup kube-controller-manager   --master=127.0.0.1:8080   --v=2   2>&1 > /dev/null &

# install kube-scheduler
nohup kube-scheduler   --master=127.0.0.1:8080   --v=2   2>&1 > /dev/null &

 

源码链接:https://github.com/YaoZengzeng/scripts/blob/master/k8s-master.sh

  

6、最后,启动ovn-k8s-watcher对k8s apiserver进行同步:

#!/bin/bash

ovn-k8s-watcher   --overlay   --pidfile   --log-file   -vfile:info   -vconsole:emer   --detach

  

源码链接:https://github.com/YaoZengzeng/scripts/blob/master/ovn-k8s-watcher.sh

 

到此为止,master节点配置完成

 

Minion节点的安装

1、首先在minion节点安装ovs和ovn:

#!/bin/bash

sudo apt-get install openvswitch-common openvswitch-switch

sudo apt-get install ovn-common ovn-host

 

源码链接:https://github.com/YaoZengzeng/scripts/blob/master/ovn-host.sh

 

2、下载并安装ovn-kubernetes:

git clone https://github.com/openvswitch/ovn-kubernetes
cd ovn-kubernetes
pip install .

  

3、对ovn minion节点进行初始化:

#!/bin/bash

NODE_NAME=

CENTRAL_IP=
LOCAL_IP=

K8S_API_SERVER_IP=

CLUSTER_IP_SUBNET=
MINION_SWITCH_SUBNET=

ovs-vsctl set Open_vSwitch . external_ids:ovn-remote="tcp:$CENTRAL_IP:6642"   external_ids:ovn-nb="tcp:$CENTRAL_IP:6641"   external_ids:ovn-encap-ip="$LOCAL_IP"   external_ids:ovn-encap-type="geneve"

ovs-vsctl set Open_vSwitch .   external_ids:k8s-api-server="$K8S_API_SERVER_IP:8080"

ovn-k8s-overlay minion-init   --cluster-ip-subnet="$CLUSTER_IP_SUBNET"   --minion-switch-subnet="$MINION_SWITCH_SUBNET"   --node-name="$NODE_NAME"

  

NODE_NAME等变量和上文基本相同,其中LOCAL_IP是minion的IP地址,而CENTRAL_IP和K8S_API_SERVER_IP为master的IP地址

源码链接:https://github.com/YaoZengzeng/scripts/blob/master/ovn-k8s-minion.sh

 

4、和Master部分的步骤4相同,下载并安装kubernetes

 

5、运行kubernetes minion节点的组件,其实就是kubelet:

#!/bin/bash

K8S_API_SERVER_IP=

# Start kubelet
nohup kubelet   --api-servers=http://$K8S_API_SERVER_IP:8080   --v=2   --address=0.0.0.0   --enable-server=true   --network-plugin=cni   --network-plugin-dir=/etc/cni/net.d   2>&1 > /dev/null &

  

其中K8S_API_SERVER_IP变量为master节点的IP地址

源码链接:https://github.com/YaoZengzeng/scripts/blob/master/k8s-minion.sh

 

到此为止,完成了ovn-kubernetes的安装。不过我并没有对gateway节点进行初始化,因为搭建的集群并不需要和外界进行通信。当然这部分内容也比较复杂,等我认真学习之后,再来继续补充吧。

 

ovn-kubernetes安装指南

标签:子网   dev   默认   update   plugin   ddr   scripts   download   补充   

原文地址:http://www.cnblogs.com/YaoDD/p/7511002.html

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