summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuo Ruijing <ruijing.guo@intel.com>2017-11-16 12:23:16 -0500
committerGuo Ruijing <ruijing.guo@intel.com>2017-11-20 18:43:47 -0500
commit57c01199d342c5051fef2bb94f463f21749089bb (patch)
treec2e6c28b3bd1fed53b92038bf1286e82f4661606
parentb2da960212571fc3e287eedcdc4c8c92fed9bf83 (diff)
add examples for container4nfv
1. add example for kubeadm with weave 2. add example for kubeadm with multus 3. add example for kubeadm with ovsdpdk 4. add example for kubeadm with virtlet Change-Id: I138e71e45f0aba8389dca0e1a826f4662572af29 Signed-off-by: Guo Ruijing <ruijing.guo@intel.com>
-rwxr-xr-xci/deploy.sh4
-rw-r--r--src/cni/ovsdpdk/kube_cniovsdpdk.yml2
-rwxr-xr-xsrc/vagrant/kubeadm_basic/deploy.sh1
-rwxr-xr-xsrc/vagrant/kubeadm_basic/examples/nginx-app.sh12
-rw-r--r--src/vagrant/kubeadm_basic/examples/nginx-app.yaml2
-rw-r--r--src/vagrant/kubeadm_basic/master_setup.sh2
-rwxr-xr-xsrc/vagrant/kubeadm_multus/deploy.sh2
-rw-r--r--src/vagrant/kubeadm_multus/examples/busybox.yaml17
-rwxr-xr-xsrc/vagrant/kubeadm_multus/examples/multus.sh39
-rw-r--r--src/vagrant/kubeadm_multus/examples/ubuntu.yaml32
-rw-r--r--src/vagrant/kubeadm_multus/master_setup.sh3
-rw-r--r--src/vagrant/kubeadm_ovsdpdk/Vagrantfile2
-rwxr-xr-xsrc/vagrant/kubeadm_ovsdpdk/deploy.sh3
-rwxr-xr-xsrc/vagrant/kubeadm_ovsdpdk/examples/virtio-user.sh39
-rw-r--r--src/vagrant/kubeadm_ovsdpdk/master_setup.sh2
-rw-r--r--src/vagrant/kubeadm_ovsdpdk/ovsdpdk/start.sh6
-rwxr-xr-xsrc/vagrant/kubeadm_virtlet/deploy.sh2
-rwxr-xr-xsrc/vagrant/kubeadm_virtlet/examples/virtlet.sh20
-rw-r--r--src/vagrant/kubeadm_virtlet/master_setup.sh2
19 files changed, 143 insertions, 49 deletions
diff --git a/ci/deploy.sh b/ci/deploy.sh
index 29871e9..26da62e 100755
--- a/ci/deploy.sh
+++ b/ci/deploy.sh
@@ -17,8 +17,8 @@
set -ex
-./setup_vagrant.sh
./cleanup.sh
-../src/vagrant/kubeadm_ovsdpdk/deploy.sh
+../src/vagrant/kubeadm_basic/deploy.sh
../src/vagrant/kubeadm_multus/deploy.sh
../src/vagrant/kubeadm_virtlet/deploy.sh
+../src/vagrant/kubeadm_ovsdpdk/deploy.sh
diff --git a/src/cni/ovsdpdk/kube_cniovsdpdk.yml b/src/cni/ovsdpdk/kube_cniovsdpdk.yml
index 1699f61..3684719 100644
--- a/src/cni/ovsdpdk/kube_cniovsdpdk.yml
+++ b/src/cni/ovsdpdk/kube_cniovsdpdk.yml
@@ -21,7 +21,7 @@ data:
"bridge": "br-dpdk",
"ipam": {
"type": "host-local",
- "subnet": "10.244.0.0/16",
+ "subnet": "10.244.0.0/24",
"rangeStart": "10.244.0.100",
"gateway": "10.244.0.1",
"dataDir": "/vagrant/container-ipam-state"
diff --git a/src/vagrant/kubeadm_basic/deploy.sh b/src/vagrant/kubeadm_basic/deploy.sh
index f5b810e..4e12e91 100755
--- a/src/vagrant/kubeadm_basic/deploy.sh
+++ b/src/vagrant/kubeadm_basic/deploy.sh
@@ -5,4 +5,5 @@ DIR="$(dirname `readlink -f $0`)"
cd $DIR
vagrant up
+vagrant ssh master -c "/vagrant/examples/nginx-app.sh" || (vagrant destroy -f; exit 1)
vagrant destroy -f
diff --git a/src/vagrant/kubeadm_basic/examples/nginx-app.sh b/src/vagrant/kubeadm_basic/examples/nginx-app.sh
index bfd0613..07b9c22 100755
--- a/src/vagrant/kubeadm_basic/examples/nginx-app.sh
+++ b/src/vagrant/kubeadm_basic/examples/nginx-app.sh
@@ -5,6 +5,16 @@ kubectl get nodes
kubectl get services
kubectl get pods
kubectl get rc
-sleep 120
+
+r="0"
+while [ $r -ne "2" ]
+do
+ r=$(kubectl get pods | grep Running | wc -l)
+ sleep 20
+done
+
svcip=$(kubectl get services nginx -o json | grep clusterIP | cut -f4 -d'"')
wget http://$svcip
+kubectl delete rc --all
+kubectl delete services --all
+kubectl delete pod --all
diff --git a/src/vagrant/kubeadm_basic/examples/nginx-app.yaml b/src/vagrant/kubeadm_basic/examples/nginx-app.yaml
index f80881a..7bb5e9b 100644
--- a/src/vagrant/kubeadm_basic/examples/nginx-app.yaml
+++ b/src/vagrant/kubeadm_basic/examples/nginx-app.yaml
@@ -26,6 +26,6 @@ spec:
spec:
containers:
- name: nginx
- image: nginx
+ image: nginx:1.13.6
ports:
- containerPort: 80
diff --git a/src/vagrant/kubeadm_basic/master_setup.sh b/src/vagrant/kubeadm_basic/master_setup.sh
index 0e33177..1d204c2 100644
--- a/src/vagrant/kubeadm_basic/master_setup.sh
+++ b/src/vagrant/kubeadm_basic/master_setup.sh
@@ -2,7 +2,7 @@
set -ex
-sudo timeout 600 kubeadm init --apiserver-advertise-address=192.168.1.10 --service-cidr=192.168.1.0/24 --pod-network-cidr=10.244.0.0/16 --token 8c5adc.1cec8dbf339093f0
+sudo timeout 600 kubeadm init --apiserver-advertise-address=192.168.1.10 --service-cidr=10.96.0.0/16 --pod-network-cidr=10.32.0.0/12 --token 8c5adc.1cec8dbf339093f0
sudo cp /etc/kubernetes/admin.conf $HOME/
sudo chown $(id -u):$(id -g) $HOME/admin.conf
export KUBECONFIG=$HOME/admin.conf
diff --git a/src/vagrant/kubeadm_multus/deploy.sh b/src/vagrant/kubeadm_multus/deploy.sh
index f5b810e..a0e7843 100755
--- a/src/vagrant/kubeadm_multus/deploy.sh
+++ b/src/vagrant/kubeadm_multus/deploy.sh
@@ -4,5 +4,7 @@ set -ex
DIR="$(dirname `readlink -f $0`)"
cd $DIR
+vagrant destroy -f
vagrant up
+vagrant ssh master -c "/vagrant/examples/multus.sh" || (vagrant destroy -f; exit 1)
vagrant destroy -f
diff --git a/src/vagrant/kubeadm_multus/examples/busybox.yaml b/src/vagrant/kubeadm_multus/examples/busybox.yaml
new file mode 100644
index 0000000..7fd1b8d
--- /dev/null
+++ b/src/vagrant/kubeadm_multus/examples/busybox.yaml
@@ -0,0 +1,17 @@
+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
new file mode 100755
index 0000000..d4b9a88
--- /dev/null
+++ b/src/vagrant/kubeadm_multus/examples/multus.sh
@@ -0,0 +1,39 @@
+#!/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
+
+#workaroud to fix dns pod issue
+times=0
+
+while [ $times -lt "3" ]
+do
+ kubectl get pods -n kube-system | grep kube-dns | grep -v Run | sed "s/ .*//" | \
+ xargs -I {} kubectl delete pod -n kube-system {}
+ sleep 20
+ times+=1
+done
+
+kubectl apply -f /vagrant/examples/busybox.yaml
+r="0"
+while [ $r -ne "2" ]
+do
+ r=$(kubectl get pods | grep Running | wc -l)
+ sleep 20
+done
+kubectl get pods --all-namespaces
+kubectl get pods | grep Run | sed "s/ .*//" | xargs -I {} kubectl exec -i {} ip a
diff --git a/src/vagrant/kubeadm_multus/examples/ubuntu.yaml b/src/vagrant/kubeadm_multus/examples/ubuntu.yaml
deleted file mode 100644
index b01f903..0000000
--- a/src/vagrant/kubeadm_multus/examples/ubuntu.yaml
+++ /dev/null
@@ -1,32 +0,0 @@
-apiVersion: v1
-kind: Service
-metadata:
- name: ubuntu
- labels:
- app: ubuntu
-spec:
- type: NodePort
- ports:
- - port: 80
- protocol: TCP
- name: http
- selector:
- app: ubuntu
----
-apiVersion: v1
-kind: ReplicationController
-metadata:
- name: ubuntu
-spec:
- replicas: 2
- template:
- metadata:
- labels:
- app: ubuntu
- spec:
- containers:
- - name: ubuntu
- image: openretriever/ubuntu1604-ping
- command: [ "/bin/bash", "-c", "sleep 30000" ]
- ports:
- - containerPort: 80
diff --git a/src/vagrant/kubeadm_multus/master_setup.sh b/src/vagrant/kubeadm_multus/master_setup.sh
index eaf308a..c452ac8 100644
--- a/src/vagrant/kubeadm_multus/master_setup.sh
+++ b/src/vagrant/kubeadm_multus/master_setup.sh
@@ -2,12 +2,11 @@
set -ex
-sudo timeout 600 kubeadm init --apiserver-advertise-address=192.168.1.10 --service-cidr=10.96.0.0/24 --pod-network-cidr=10.244.0.0/16 --token 8c5adc.1cec8dbf339093f0
+sudo timeout 600 kubeadm init --apiserver-advertise-address=192.168.1.10 --service-cidr=10.96.0.0/16 --pod-network-cidr=10.32.0.0/12 --token 8c5adc.1cec8dbf339093f0
sudo cp /etc/kubernetes/admin.conf $HOME/
sudo chown $(id -u):$(id -g) $HOME/admin.conf
export KUBECONFIG=$HOME/admin.conf
echo "export KUBECONFIG=$HOME/admin.conf" >> $HOME/.bash_profile
kubectl apply -f http://git.io/weave-kube-1.6
-kubectl apply -f http://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml
kubectl apply -f /vagrant/multus/kube_cni_multus.yml
diff --git a/src/vagrant/kubeadm_ovsdpdk/Vagrantfile b/src/vagrant/kubeadm_ovsdpdk/Vagrantfile
index b4f3b0f..2d69109 100644
--- a/src/vagrant/kubeadm_ovsdpdk/Vagrantfile
+++ b/src/vagrant/kubeadm_ovsdpdk/Vagrantfile
@@ -20,6 +20,7 @@ Vagrant.configure("2") 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"
+ config.vm.network :private_network, ip: "10.244.0.10"
end
(1 .. $num_workers).each do |i|
@@ -27,6 +28,7 @@ Vagrant.configure("2") 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}"
+ config.vm.network :private_network, ip: "10.244.0.#{i+20}"
end
end
diff --git a/src/vagrant/kubeadm_ovsdpdk/deploy.sh b/src/vagrant/kubeadm_ovsdpdk/deploy.sh
index f5b810e..2cf96b9 100755
--- a/src/vagrant/kubeadm_ovsdpdk/deploy.sh
+++ b/src/vagrant/kubeadm_ovsdpdk/deploy.sh
@@ -4,5 +4,8 @@ set -ex
DIR="$(dirname `readlink -f $0`)"
cd $DIR
+vagrant destroy -f
+rm -rf container-ipam-state
vagrant up
+vagrant ssh master -c "/vagrant/examples/virtio-user.sh" || (vagrant destroy -f; exit 1)
vagrant destroy -f
diff --git a/src/vagrant/kubeadm_ovsdpdk/examples/virtio-user.sh b/src/vagrant/kubeadm_ovsdpdk/examples/virtio-user.sh
new file mode 100755
index 0000000..dd918de
--- /dev/null
+++ b/src/vagrant/kubeadm_ovsdpdk/examples/virtio-user.sh
@@ -0,0 +1,39 @@
+#!/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
+
+kubectl delete rc --all
+kubectl apply -f /vagrant/examples/virtio-user.yaml
+r="0"
+while [ $r -ne "4" ]
+do
+ r=$(kubectl get pods --all-namespaces | grep ovsdpdk | grep Run | wc -l)
+ sleep 20
+done
+
+kubectl delete rc --all
+kubectl apply -f /vagrant/examples/virtio-user.yaml
+r="0"
+while [ $r -ne "2" ]
+do
+ r=$(kubectl get pods | grep Running | wc -l)
+ sleep 20
+done
+kubectl get pods --all-namespaces
+sleep 20
+ping -c4 10.244.0.103 || ping -c4 10.244.0.104
diff --git a/src/vagrant/kubeadm_ovsdpdk/master_setup.sh b/src/vagrant/kubeadm_ovsdpdk/master_setup.sh
index 28a4c4a..b9cd5db 100644
--- a/src/vagrant/kubeadm_ovsdpdk/master_setup.sh
+++ b/src/vagrant/kubeadm_ovsdpdk/master_setup.sh
@@ -2,7 +2,7 @@
set -ex
-sudo timeout 600 kubeadm init --apiserver-advertise-address=192.168.1.10 --service-cidr=192.168.1.0/24 --pod-network-cidr=10.244.0.0/16 --token 8c5adc.1cec8dbf339093f0
+sudo timeout 600 kubeadm init --apiserver-advertise-address=192.168.1.10 --service-cidr=192.168.1.0/24 --pod-network-cidr=10.244.0.0/24 --token 8c5adc.1cec8dbf339093f0
sudo cp /etc/kubernetes/admin.conf $HOME/
sudo chown $(id -u):$(id -g) $HOME/admin.conf
export KUBECONFIG=$HOME/admin.conf
diff --git a/src/vagrant/kubeadm_ovsdpdk/ovsdpdk/start.sh b/src/vagrant/kubeadm_ovsdpdk/ovsdpdk/start.sh
index fed7985..4fc3d17 100644
--- a/src/vagrant/kubeadm_ovsdpdk/ovsdpdk/start.sh
+++ b/src/vagrant/kubeadm_ovsdpdk/ovsdpdk/start.sh
@@ -7,9 +7,9 @@ do
sudo sysctl -w vm.nr_hugepages=2048; sleep 1
done
sudo modprobe uio_pci_generic
-ip=$(ip a s enp0s9 | grep inet | grep -v inet6 | sed "s/.*inet//" | cut -f2 -d' ')
-sudo ip address flush enp0s9
-sudo /usr/share/dpdk/tools/dpdk_nic_bind.py --bind=uio_pci_generic enp0s9
+ip=$(ip a s eth2 | grep inet | grep -v inet6 | sed "s/.*inet//" | cut -f2 -d' ')
+sudo ip address flush eth2
+sudo /usr/share/dpdk/tools/dpdk_nic_bind.py --bind=uio_pci_generic eth2
sudo sysctl -w vm.nr_hugepages=1024
sudo mount -t hugetlbfs -o pagesize=2M none /dev/hugepages
sudo cp /usr/bin/ovs-vsctl /usr/local/bin
diff --git a/src/vagrant/kubeadm_virtlet/deploy.sh b/src/vagrant/kubeadm_virtlet/deploy.sh
index f5b810e..758abb5 100755
--- a/src/vagrant/kubeadm_virtlet/deploy.sh
+++ b/src/vagrant/kubeadm_virtlet/deploy.sh
@@ -4,5 +4,7 @@ set -ex
DIR="$(dirname `readlink -f $0`)"
cd $DIR
+vagrant destroy -f
vagrant up
+vagrant ssh master -c "/vagrant/examples/virtlet.sh" || (vagrant destroy -f; exit 1)
vagrant destroy -f
diff --git a/src/vagrant/kubeadm_virtlet/examples/virtlet.sh b/src/vagrant/kubeadm_virtlet/examples/virtlet.sh
index 68d738d..70bb606 100755
--- a/src/vagrant/kubeadm_virtlet/examples/virtlet.sh
+++ b/src/vagrant/kubeadm_virtlet/examples/virtlet.sh
@@ -1,9 +1,21 @@
#!/bin/bash
+set -ex
+
kubectl label node worker1 extraRuntime=virtlet
kubectl label node worker2 extraRuntime=virtlet
-kubectl label node worker3 extraRuntime=virtlet
kubectl create configmap -n kube-system virtlet-config --from-literal=download_protocol=http --from-literal=image_regexp_translation=1 --from-literal=disable_kvm=y
-kubectl create configmap -n kube-system virtlet-image-translations --from-file images.yaml
-kubectl create -f virtlet-ds.yaml
-kubectl create -f cirros-vm.yaml
+kubectl create configmap -n kube-system virtlet-image-translations --from-file /vagrant/examples/images.yaml
+kubectl create -f /vagrant/examples/virtlet-ds.yaml
+
+kubectl delete pod --all
+kubectl create -f /vagrant/examples/cirros-vm.yaml
+r="0"
+while [ $r -ne "1" ]
+do
+ r=$(kubectl get pods | grep Running | wc -l)
+ sleep 20
+done
+sleep 60
+kubectl get pods -o json | grep podIP | cut -f4 -d'"' | xargs ping -c 4
+echo 'login by user:cirros & password:gocubsgo'
diff --git a/src/vagrant/kubeadm_virtlet/master_setup.sh b/src/vagrant/kubeadm_virtlet/master_setup.sh
index ba650ff..84185e0 100644
--- a/src/vagrant/kubeadm_virtlet/master_setup.sh
+++ b/src/vagrant/kubeadm_virtlet/master_setup.sh
@@ -2,7 +2,7 @@
set -ex
-sudo timeout 600 kubeadm init --apiserver-advertise-address=192.168.1.10 --service-cidr=10.96.0.0/24 --pod-network-cidr=10.244.0.0/16 --token 8c5adc.1cec8dbf339093f0
+sudo timeout 600 kubeadm init --apiserver-advertise-address=192.168.1.10 --service-cidr=10.96.0.0/24 --pod-network-cidr=10.32.0.0/16 --token 8c5adc.1cec8dbf339093f0
sudo cp /etc/kubernetes/admin.conf $HOME/
sudo chown $(id -u):$(id -g) $HOME/admin.conf
export KUBECONFIG=$HOME/admin.conf