Add the flannel driver in test case

Add the flannel network driver in test case when
the Kolla-kubernetes test is not running on amd64
platform. Also delete part of the code that works around
the issue of lacking net-conf.json, since the current version
of canal.yml and kube-flannel.yml all have net-conf.json
now.

Closes-Bug: #1738317

Jira: ENTWLS-516

Change-Id: I0f7a90c26bdce7096f1501d48927d7c8a49886b5
Signed-off-by: Kevin Zhao <kevin.zhao@arm.com>
This commit is contained in:
Kevin Zhao 2018-01-15 18:25:06 +08:00
parent bb9bcf25d1
commit 484071e003
5 changed files with 46 additions and 50 deletions

View File

@ -1,45 +0,0 @@
#!/bin/bash -xe
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )/../.." && pwd )"
url="https://raw.githubusercontent.com/projectcalico/canal/master"
url="$url/k8s-install/1.7/canal.yaml"
curl "$url" -o /tmp/canal.yaml
url="https://raw.githubusercontent.com/projectcalico/canal/master"
url="$url/k8s-install/1.7/rbac.yaml"
curl "$url" -o /tmp/rbac.yaml
kubectl create -f /tmp/rbac.yaml
#
# Instead of hardcoding cluster cidr, let's get it from
# controller manager manifest.
#
cluster_cidr=$(sudo grep cluster-cidr /etc/kubernetes/manifests/kube-controller-manager.yaml || true)
cluster_cidr=${cluster_cidr##*=}
#
# NOTE(sbezverk) Temporary workaround to canal.yaml bug. It is
# missing net-conf.json file. The code will add it if it does not exist.
#
network_conf=$(grep net-conf.json /tmp/canal.yaml || true)
if [ "x$network_conf" == "x" ]; then
sed -i '/masquerade:/a\
net-conf.json: |\
{\
"Network": "'$cluster_cidr'",\
"Backend": {\
"Type": "vxlan"\
}\
}' /tmp/canal.yaml
else
sed -i 's@"Network":.*"@"Network": "'$cluster_cidr'"@' /tmp/canal.yaml
fi
kubectl create -f /tmp/canal.yaml
$DIR/tools/pull_containers.sh kube-system
$DIR/tools/wait_for_pods.sh kube-system 240

41
tests/bin/setup_sdn.sh Executable file
View File

@ -0,0 +1,41 @@
#!/bin/bash -xe
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )/../.." && pwd )"
url_canal="https://raw.githubusercontent.com/projectcalico/canal/master"
url_canal="$url_canal/k8s-install/1.7/canal.yaml"
url_canal_rbac="https://raw.githubusercontent.com/projectcalico/canal/master"
url_canal_rbac="$url_canal_rbac/k8s-install/1.7/rbac.yaml"
url_flannel="https://raw.githubusercontent.com/coreos/flannel"
url_flannel="$url_flannel/v0.9.1/Documentation/kube-flannel.yml"
url_flannel_rbac="https://raw.githubusercontent.com/coreos/flannel/master"
url_flannel_rbac="$url_flannel_rbac/Documentation/k8s-manifests/kube-flannel-rbac.yml"
if [[ "$(uname -m)" == "x86_64" ]]; then
url=$url_canal
url_rbac=$url_canal_rbac
else
url=$url_flannel
url_rbac=$url_flannel_rbac
fi
curl "$url" -o /tmp/sdn.yaml
curl "$url_rbac" -o /tmp/rbac.yaml
kubectl create -f /tmp/rbac.yaml
#
# Instead of hardcoding cluster cidr, let's get it from
# controller manager manifest.
#
cluster_cidr=$(sudo grep cluster-cidr /etc/kubernetes/manifests/kube-controller-manager.yaml || true)
cluster_cidr=${cluster_cidr##*=}
sed -i 's@"Network":.*"@"Network": "'$cluster_cidr'"@' /tmp/sdn.yaml
kubectl create -f /tmp/sdn.yaml
$DIR/tools/pull_containers.sh kube-system
$DIR/tools/wait_for_pods.sh kube-system 240

View File

@ -41,7 +41,7 @@ kubectl taint nodes --all=true node-role.kubernetes.io/master:NoSchedule-
#
# Setting up networking on master, before slave nodes in multinode
# scenario will attempt to join the cluster
tests/bin/setup_canal.sh
tests/bin/setup_sdn.sh
# Turn up kube-proxy logging enable only for debug
# kubectl -n kube-system get ds -l 'component=kube-proxy-amd64' -o json \

View File

@ -30,7 +30,7 @@ tools/setup_kubernetes.sh master
kubectl taint nodes --all=true node-role.kubernetes.io/master:NoSchedule-
tests/bin/setup_canal.sh
tests/bin/setup_sdn.sh
NODE=$(hostname -s)
kubectl label node $NODE kolla_controller=true kolla_compute=true \

View File

@ -100,9 +100,9 @@ sudo systemctl enable docker
sudo systemctl enable kubelet
## Setup Canal
echo "Setup Canal"
cd /opt/kolla-kubernetes && tests/bin/setup_canal.sh
## Setup Sdn
echo "Setup Sdn. For x86_64 will setup Canal, for non-x86, will setup Flannel"
cd /opt/kolla-kubernetes && tests/bin/setup_sdn.sh
## Setup Helm