#!/bin/bash
+# shellcheck disable=SC1073,SC1072,SC1039,SC2059,SC2046
set -o xtrace
set -e
fi
-CLUSTER_IP=${1:-172.16.1.136} # Align with the value in our K8s setup script
+CNI_TYPE=${1:-calico}
POD_NETWORK_CIDR=${2:-192.168.0.0/16}
-CNI_TYPE=${3:-calico}
-K8S_MASTER_IP=${4:-10.169.41.173}
-SERVICE_CIDR=${5:-172.16.1.0/24}
+K8S_MASTER_IP=${3:-10.169.41.173}
+SERVICE_CIDR=${4:-172.16.1.0/24}
+CLUSTER_IP=${5:-172.16.1.136} # Align with the value in our K8s setup script
DEV_NAME=${6:-}
SCRIPTS_DIR=$(dirname "${BASH_SOURCE[0]}")
install_ovn_kubernetes(){
# Update the ovn-kubernetes yaml files
- net_cidr_repl="{{ net_cidr | default('10.128.0.0/14/23') }}"
- svc_cidr_repl="{{ svc_cidr | default('172.30.0.0/16') }}"
- k8s_apiserver_repl="{{ k8s_apiserver.stdout }}"
+ net_cidr_repl="{{ net_cidr }}"
+ svc_cidr_repl="{{ svc_cidr }}"
+ k8s_apiserver_repl="{{ k8s_apiserver }}"
+ mtu_repl="{{ mtu_value }}"
k8s_apiserver="https://${K8S_MASTER_IP}:6443"
net_cidr="${POD_NETWORK_CIDR}"
svc_cidr="${SERVICE_CIDR}"
+ mtu_def_value=1400
echo "net_cidr: ${net_cidr}"
echo "svc_cidr: ${svc_cidr}"
echo "k8s_apiserver: ${k8s_apiserver}"
+ echo "mtu: ${mtu_def_value}"
sed "s,${net_cidr_repl},${net_cidr},
s,${svc_cidr_repl},${svc_cidr},
- s,${k8s_apiserver_repl},${k8s_apiserver}," \
+ s,${k8s_apiserver_repl},${k8s_apiserver},
+ s,${mtu_repl},${mtu_def_value}," \
${SCRIPTS_DIR}/cni/ovn-kubernetes/templates/ovn-setup.yaml.j2 > \
${SCRIPTS_DIR}/cni/ovn-kubernetes/yaml/ovn-setup.yaml
}
+install_multus_sriov_flannel(){
+
+ sed -i "s@10.244.0.0/16@${POD_NETWORK_CIDR}@" "${SCRIPTS_DIR}/cni/multus/multus-sriov-flannel/flannel-daemonset.yml"
+ # Install Multus Flannel+SRIOV by yaml files
+ # shellcheck source=/dev/null
+ source ${SCRIPTS_DIR}/cni/multus/multus-sriov-flannel/install.sh
+
+}
+
+install_multus_sriov_calico(){
+
+ sed -i "s@10.244.0.0/16@${POD_NETWORK_CIDR}@" \
+ "${SCRIPTS_DIR}/cni/multus/multus-sriov-calico/calico-daemonset.yaml"
+ # Install Multus Calico+SRIOV by yaml files
+ # shellcheck source=/dev/null
+ source ${SCRIPTS_DIR}/cni/multus/multus-sriov-calico/install.sh
+
+}
+
+install_danm(){
+ ${SCRIPTS_DIR}/cni/danm/danm_install.sh
+
+ # Deploying DANM suite into K8s cluster
+ kubectl create -f ${SCRIPTS_DIR}/cni/danm/integration/crds/lightweight/
+
+ # Create the netwatcher DaemonSet
+ kubectl create -f ${SCRIPTS_DIR}/cni/danm/integration/manifests/netwatcher/
+
+ #flannel as bootstrap networking solution
+ install_flannel
+}
+
+
+install_cilium(){
+ ${SCRIPTS_DIR}/cni/cilium/cilium_install.sh
+
+ # Deploying cilium CNI
+ kubectl create -f ${SCRIPTS_DIR}/cni/cilium/quick-install.yaml
+}
+
+# Remove the taints on master node
+# Taint master before installing the CNI for the case that there is
+# only one master node
+kubectl taint nodes --all node-role.kubernetes.io/master- || true
case ${CNI_TYPE} in
'calico')
echo "Install Ovn-Kubernetes ..."
install_ovn_kubernetes
;;
+ 'multus-flannel-sriov')
+ echo "Install Flannel with SRIOV CNI by Multus-CNI ..."
+ install_multus_sriov_flannel
+ ;;
+ 'multus-calico-sriov')
+ echo "Install Calico with SRIOV CNI by Multus-CNI ..."
+ install_multus_sriov_calico
+ ;;
+ 'danm')
+ echo "Install danm ..."
+ install_danm
+ ;;
+ 'cilium')
+ echo "Install cilium ..."
+ install_cilium
+ ;;
*)
echo "${CNI_TYPE} is not supported"
exit 1
;;
esac
-# Remove the taints on master node
-kubectl taint nodes --all node-role.kubernetes.io/master- || true