Installation of master node
1. First install OvS and OVN on the master node:
#!/bin/bashsudo apt-get Install Openvswitch-common openvswitch-switchsudo apt-get install Ovn-common ovn-central Ovn-host
source file See my GitHub (same as below): https://github.com/YaoZengzeng/scripts/blob/master/ovn-central.sh
2. Download and install Ovn-kubernetes:
git clone https://github.com/openvswitch/ovn-kubernetes
CD Ovn-kubernetes
Pip install.
3. Initialize the OVN master node:
#!/bin/bashnode_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"
Where the node_name is the master node Hostname,central_ip and local_ip for the master node is the same, are the master node's own IP address, cluster_ip_subnet for the entire cluster subnet range, For example, 192.168.0.0/16, while Master_switch_subnet is the subnet range that the pod on the master node can allocate, such as 192.168.1.0/24
SOURCE Link: https://github.com/YaoZengzeng/scripts/blob/master/ovn-k8s-master.sh
4, at first I was using KUBEADM to build k8s cluster, but when the API server through http://127.0.0.1:8080 to find that the port is not open, it may be kubeadm by default is not open the port, Therefore, the kubernetes can only be built by manual means. First download and install Kubernetes:
#!/bin/bash# Install dockerapt-get updateapt-get install-y docker.iomkdir k8scd k8swget https://github.com/kubernetes/ Kubernetes/releases/download/v1.5.3/kubernetes.tar.gztar Xvzf kubernetes.tar.gz./kubernetes/cluster/ Get-kube-binaries.shmkdir servercd Servertar Xvzf. /KUBERNETES/SERVER/KUBERNETES-SERVER-LINUX-AMD64.TAR.GZCD KUBERNETES/SERVER/BINCP Kube-apiserver Kube-controller-manager kube-scheduler kubelet kubectl/usr/bin# Install cnimkdir-p/opt/cni/bin && cd/opt/cni/ Binwget Https://github.com/containernetworking/cni/releases/download/v0.5.2/cni-amd64-v0.5.2.tgztar Xvzf Cni-amd64-v0.5.2.tgz
Source Connection: https://github.com/YaoZengzeng/scripts/blob/master/k8s-download.sh
5. Then run the various components of kubernetes:
#!/bin/bash# on the master node, start Etcddocker 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-apiservernohup 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-managernohup kube-controller-manager --master=127.0.0.1:8080 --v=2 2>&1 >/dev/null Install kube-schedulernohup kube-scheduler --master=127.0.0.1:8080 --v=2 2> &1 >/dev/null &
SOURCE Link: https://github.com/YaoZengzeng/scripts/blob/master/k8s-master.sh
6. Finally, start Ovn-k8s-watcher to synchronize the k8s Apiserver:
#!/bin/bashovn-k8s-watcher --overlay --pidfile --log-file -vfile:info -vconsole:emer - -detach
SOURCE Link: https://github.com/YaoZengzeng/scripts/blob/master/ovn-k8s-watcher.sh
So far, master node configuration is complete
Installation of the Minion node
1. First install the OvS and OVN on the Minion node:
#!/bin/bashsudo apt-get Install Openvswitch-common openvswitch-switchsudo apt-get install Ovn-common ovn-host
SOURCE Link: https://github.com/YaoZengzeng/scripts/blob/master/ovn-host.sh
2. Download and install Ovn-kubernetes:
git clone https://github.com/openvswitch/ovn-kubernetescd ovn-kubernetespip install.
3. Initialize the OVN Minion node:
#!/bin/bashnode_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= "$K 8s_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 variables are basically the same as above, where local_ip is the IP address of minion, and Central_ip and K8S_API_SERVER_IP are the master IP addresses
SOURCE Link: https://github.com/YaoZengzeng/scripts/blob/master/ovn-k8s-minion.sh
4, and the master part of the same step 4, download and install Kubernetes
5, running Kubernetes Minion node components, in fact, is Kubelet:
#!/bin/bashk8s_api_server_ip=# Start kubeletnohup kubelet --api-servers=http://$K 8s_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 &
Where the K8S_API_SERVER_IP variable is the IP address of the master node
SOURCE Link: https://github.com/YaoZengzeng/scripts/blob/master/k8s-minion.sh
This concludes the installation of the ovn-kubernetes. However, I did not initialize the gateway node because the cluster does not need to communicate with the outside world. Of course, this part of the content is more complex, and so after I seriously study, then continue to add it.
Ovn-kubernetes Installation Guide