From 305eefa0439bef9f0edac786160ca8ed00e1942c Mon Sep 17 00:00:00 2001 From: Guo Ruijing Date: Tue, 13 Nov 2018 04:13:50 +0800 Subject: rebase multus Change-Id: Ia82ed5f71ad7fdd49bfc71614ebf0d52920de610 Signed-off-by: Guo Ruijing --- src/cni/multus/install_cni.sh | 12 --- src/cni/multus/kube_cni_multus.yml | 95 ------------------------ src/vagrant/kubeadm/Vagrantfile | 34 +++++++++ src/vagrant/kubeadm/deploy.sh | 9 +++ src/vagrant/kubeadm/host_setup.sh | 50 +++++++++++++ src/vagrant/kubeadm/master_setup.sh | 11 +++ src/vagrant/kubeadm/multus/Dockerfile | 10 +++ src/vagrant/kubeadm/multus/busybox.yaml | 17 +++++ src/vagrant/kubeadm/multus/cni_multus.yml | 88 ++++++++++++++++++++++ src/vagrant/kubeadm/multus/multus.sh | 36 +++++++++ src/vagrant/kubeadm/registry_setup.sh | 35 +++++++++ src/vagrant/kubeadm/worker_setup.sh | 6 ++ src/vagrant/kubeadm_multus/Vagrantfile | 29 -------- src/vagrant/kubeadm_multus/deploy.sh | 9 --- src/vagrant/kubeadm_multus/examples/busybox.yaml | 17 ----- src/vagrant/kubeadm_multus/examples/multus.sh | 36 --------- src/vagrant/kubeadm_multus/host_setup.sh | 29 -------- src/vagrant/kubeadm_multus/master_setup.sh | 12 --- src/vagrant/kubeadm_multus/worker_setup.sh | 4 - 19 files changed, 296 insertions(+), 243 deletions(-) delete mode 100644 src/cni/multus/install_cni.sh delete mode 100644 src/cni/multus/kube_cni_multus.yml create mode 100644 src/vagrant/kubeadm/Vagrantfile create mode 100755 src/vagrant/kubeadm/deploy.sh create mode 100644 src/vagrant/kubeadm/host_setup.sh create mode 100644 src/vagrant/kubeadm/master_setup.sh create mode 100644 src/vagrant/kubeadm/multus/Dockerfile create mode 100644 src/vagrant/kubeadm/multus/busybox.yaml create mode 100644 src/vagrant/kubeadm/multus/cni_multus.yml create mode 100755 src/vagrant/kubeadm/multus/multus.sh create mode 100644 src/vagrant/kubeadm/registry_setup.sh create mode 100644 src/vagrant/kubeadm/worker_setup.sh delete mode 100644 src/vagrant/kubeadm_multus/Vagrantfile delete mode 100755 src/vagrant/kubeadm_multus/deploy.sh delete mode 100644 src/vagrant/kubeadm_multus/examples/busybox.yaml delete mode 100755 src/vagrant/kubeadm_multus/examples/multus.sh delete mode 100644 src/vagrant/kubeadm_multus/host_setup.sh delete mode 100644 src/vagrant/kubeadm_multus/master_setup.sh delete mode 100644 src/vagrant/kubeadm_multus/worker_setup.sh diff --git a/src/cni/multus/install_cni.sh b/src/cni/multus/install_cni.sh deleted file mode 100644 index 0d1ee6b..0000000 --- a/src/cni/multus/install_cni.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash - -set -ex - -export PATH=/usr/local/go/bin:$PATH -apt-get update && apt-get install -y wget -rm -rf multus-cni -wget -qO- https://storage.googleapis.com/golang/go1.8.3.linux-amd64.tar.gz | tar -C /usr/local/ -xz -git clone https://github.com/Intel-Corp/multus-cni -cd multus-cni; bash ./build -cp bin/multus /opt/cni/bin -cp /etc/kube-cnimultus/cni-conf.json /etc/cni/net.d/05-multus.conf diff --git a/src/cni/multus/kube_cni_multus.yml b/src/cni/multus/kube_cni_multus.yml deleted file mode 100644 index cd91737..0000000 --- a/src/cni/multus/kube_cni_multus.yml +++ /dev/null @@ -1,95 +0,0 @@ ---- -apiVersion: v1 -kind: ServiceAccount -metadata: - name: cnimultus - namespace: kube-system ---- -kind: ConfigMap -apiVersion: v1 -metadata: - name: kube-cnimultus-cfg - namespace: kube-system - labels: - tier: node - app: cnimultus -data: - cni-conf.json: | - { - "name": "multus", - "type": "multus", - "delegates": [ - { - "name": "weave", - "type": "weave-net", - "hairpinMode": true, - "masterplugin": true - }, - { - "name": "mynet", - "type": "bridge", - "bridge": "cni0", - "isGateway": true, - "ipMasq": true, - "ipam": { - "type": "host-local", - "subnet": "10.22.0.0/16", - "routes": [ - { "dst": "0.0.0.0/0" } - ] - } - } - ] - } ---- -apiVersion: extensions/v1beta1 -kind: DaemonSet -metadata: - name: kube-cnimultus-ds - namespace: kube-system - labels: - tier: node - app: cnimultus -spec: - template: - metadata: - labels: - tier: node - app: cnimultus - spec: - hostNetwork: true - nodeSelector: - beta.kubernetes.io/arch: amd64 - tolerations: - - key: node-role.kubernetes.io/master - operator: Exists - effect: NoSchedule - serviceAccountName: cnimultus - initContainers: - - name: install-cni - image: ubuntu:16.04 - command: - - bash - - "-c" - - "apt-get update && apt-get install -y git && git clone http://github.com/opnfv/container4nfv && cd container4nfv && git fetch https://gerrit.opnfv.org/gerrit/container4nfv refs/changes/81/47681/5 && git checkout FETCH_HEAD && bash ./src/cni/multus/install_cni.sh" - volumeMounts: - - name: cni-bin - mountPath: /opt/cni/bin - - name: cni-cfg - mountPath: /etc/cni/net.d - - name: cnimultus-cfg - mountPath: /etc/kube-cnimultus - containers: - - name: run-cni - image: busybox:1.27.2 - command: ['sh', '-c', 'while true; do sleep 10000; done' ] - volumes: - - name: cni-bin - hostPath: - path: /opt/cni/bin - - name: cni-cfg - hostPath: - path: /etc/cni/net.d - - name: cnimultus-cfg - configMap: - name: kube-cnimultus-cfg diff --git a/src/vagrant/kubeadm/Vagrantfile b/src/vagrant/kubeadm/Vagrantfile new file mode 100644 index 0000000..e861859 --- /dev/null +++ b/src/vagrant/kubeadm/Vagrantfile @@ -0,0 +1,34 @@ +$num_workers=2 + +Vagrant.require_version ">= 1.8.6" +Vagrant.configure("2") do |config| + + config.vm.box = "ceph/ubuntu-xenial" + config.vm.provider :libvirt do |libvirt| + libvirt.memory = 4096 + libvirt.cpus = 4 + end + + config.vm.define "registry" do |config| + config.vm.hostname = "registry" + config.vm.provision "shell", path: "registry_setup.sh", privileged: false + config.vm.network :private_network, ip: "192.168.1.5" + end + + config.vm.define "master" do |config| + config.vm.hostname = "master" + config.vm.provision "shell", path: "host_setup.sh", privileged: false + config.vm.provision "shell", path: "master_setup.sh", privileged: false + config.vm.network :private_network, ip: "192.168.1.10" + end + + (1 .. $num_workers).each do |i| + config.vm.define vm_name = "worker%d" % [i] do |config| + config.vm.hostname = vm_name + config.vm.provision "shell", path: "host_setup.sh", privileged: false + config.vm.provision "shell", path: "worker_setup.sh", privileged: false + config.vm.network :private_network, ip: "192.168.1.#{i+20}" + end + end + +end diff --git a/src/vagrant/kubeadm/deploy.sh b/src/vagrant/kubeadm/deploy.sh new file mode 100755 index 0000000..c727483 --- /dev/null +++ b/src/vagrant/kubeadm/deploy.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +set -ex +DIR="$(dirname `readlink -f $0`)" + +cd $DIR +../cleanup.sh +vagrant up +vagrant ssh master -c "/vagrant/multus/multus.sh" diff --git a/src/vagrant/kubeadm/host_setup.sh b/src/vagrant/kubeadm/host_setup.sh new file mode 100644 index 0000000..d792119 --- /dev/null +++ b/src/vagrant/kubeadm/host_setup.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +set -ex + +cat << EOF | sudo tee /etc/hosts +127.0.0.1 localhost +192.168.1.05 registry +192.168.1.10 master +192.168.1.21 worker1 +192.168.1.22 worker2 +192.168.1.23 worker3 +EOF + +sudo apt-get update +sudo apt-get install -y \ + apt-transport-https \ + ca-certificates \ + curl \ + software-properties-common + +curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - +sudo add-apt-repository \ + "deb [arch=amd64] https://download.docker.com/linux/ubuntu \ + $(lsb_release -cs) \ + stable" +sudo apt-get update +sudo apt-get install -y docker-ce=18.03.1~ce-0~ubuntu +cat << EOF | sudo tee /etc/docker/daemon.json +{ + "insecure-registries": ["registry:5000"] +} +EOF +sudo service docker restart + +curl -s http://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add - +cat <= 1.8.6" -Vagrant.configure("2") do |config| - - config.vm.box = "ceph/ubuntu-xenial" - config.vm.provider :libvirt do |libvirt| - libvirt.memory = 4096 - libvirt.cpus = 4 - end - - config.vm.synced_folder "../..", "/src" - config.vm.provision "shell", path: "host_setup.sh", privileged: false - - config.vm.define "master" do |config| - config.vm.hostname = "master" - config.vm.provision "shell", path: "master_setup.sh", privileged: false - config.vm.network :private_network, ip: "192.168.1.10" - end - - (1 .. $num_workers).each do |i| - config.vm.define vm_name = "worker%d" % [i] do |config| - config.vm.hostname = vm_name - config.vm.provision "shell", path: "worker_setup.sh", privileged: false - config.vm.network :private_network, ip: "192.168.1.#{i+20}" - end - end - -end diff --git a/src/vagrant/kubeadm_multus/deploy.sh b/src/vagrant/kubeadm_multus/deploy.sh deleted file mode 100755 index 9c9e51e..0000000 --- a/src/vagrant/kubeadm_multus/deploy.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash - -set -ex -DIR="$(dirname `readlink -f $0`)" - -cd $DIR -../cleanup.sh -vagrant up -vagrant ssh master -c "/vagrant/examples/multus.sh" diff --git a/src/vagrant/kubeadm_multus/examples/busybox.yaml b/src/vagrant/kubeadm_multus/examples/busybox.yaml deleted file mode 100644 index 7fd1b8d..0000000 --- a/src/vagrant/kubeadm_multus/examples/busybox.yaml +++ /dev/null @@ -1,17 +0,0 @@ -apiVersion: v1 -kind: ReplicationController -metadata: - name: busybox -spec: - replicas: 2 - template: - metadata: - labels: - app: busybox - spec: - containers: - - name: busybox - image: busybox:1.27.2 - command: - - sleep - - "36000" diff --git a/src/vagrant/kubeadm_multus/examples/multus.sh b/src/vagrant/kubeadm_multus/examples/multus.sh deleted file mode 100755 index d7b39a0..0000000 --- a/src/vagrant/kubeadm_multus/examples/multus.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/bash -# -# Copyright (c) 2017 Intel Corporation -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -set -ex - -while true -do - kubectl get pods -n kube-system | grep kube-cnimultus-ds | grep -v Run | wc -l | grep "^0$" && break - sleep 60 -done - -kubectl delete rc --all -kubectl apply -f /vagrant/examples/busybox.yaml -r="0" -while [ $r -ne "2" ] -do - r=$(kubectl get pods | grep Running | wc -l) - sleep 60 -done - -kubectl get pods --all-namespaces -kubectl get pods | grep Run | sed "s/ .*//" | xargs -I {} kubectl exec -i {} ip a | grep mtu | wc -l | grep "^6$" || exit 1 diff --git a/src/vagrant/kubeadm_multus/host_setup.sh b/src/vagrant/kubeadm_multus/host_setup.sh deleted file mode 100644 index 524a967..0000000 --- a/src/vagrant/kubeadm_multus/host_setup.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/bash - -set -ex - -cat << EOF | sudo tee /etc/hosts -127.0.0.1 localhost -192.168.1.10 master -192.168.1.21 worker1 -192.168.1.22 worker2 -192.168.1.23 worker3 -EOF - -sudo apt-key adv --keyserver hkp://ha.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D -sudo apt-key adv -k 58118E89F3A912897C070ADBF76221572C52609D -cat << EOF | sudo tee /etc/apt/sources.list.d/docker.list -deb [arch=amd64] https://apt.dockerproject.org/repo ubuntu-xenial main -EOF - -curl -s http://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add - -cat <