Skip to content

Commit

Permalink
Deploy Calico pod network plugin on k8s-1.17
Browse files Browse the repository at this point in the history
Flannel has compatability issues with k8s-1.17 flannel-io/flannel#1245.
deploy calico plugin instead also for better proformance.

Signed-off-by: Or Mergi <[email protected]>
  • Loading branch information
Or Mergi committed Jan 29, 2020
1 parent db3913a commit 73fdc31
Show file tree
Hide file tree
Showing 3 changed files with 817 additions and 11 deletions.
16 changes: 11 additions & 5 deletions cluster-provision/k8s/scripts/node01.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,20 @@ done

kubeadm init --config /etc/kubernetes/kubeadm.conf

default_cidr="192.168.0.0/16"
pod_cidr="10.244.0.0/16"
version=`kubectl version --short --client | cut -d":" -f2 |sed 's/ //g' | cut -c2- | cut -d"." -f2`
flannel_manifest="/tmp/flannel.yaml"
if [[ $version -ge "16" ]]; then
flannel_manifest="/tmp/flannel-ge-16.yaml"

network_plugin_manifest="/tmp/flannel.yaml"
if [[ $version -ge "17" ]]; then
network_plugin_manifest="/tmp/calico.yaml"
sed -i -e "s?$default_cidr?$pod_cidr?g" "$network_plugin_manifest"
elif [[ $version -ge "16" ]]; then
network_plugin_manifest="/tmp/flannel-ge-16.yaml"
elif [[ $version -ge "12" ]]; then
flannel_manifest="/tmp/flannel-ge-12.yaml"
network_plugin_manifest="/tmp/flannel-ge-12.yaml"
fi
kubectl --kubeconfig=/etc/kubernetes/admin.conf create -f "$flannel_manifest"
kubectl --kubeconfig=/etc/kubernetes/admin.conf create -f "$network_plugin_manifest"

kubectl --kubeconfig=/etc/kubernetes/admin.conf taint nodes node01 node-role.kubernetes.io/master:NoSchedule-

Expand Down
19 changes: 13 additions & 6 deletions cluster-provision/k8s/scripts/provision.sh
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,21 @@ sysctl --system
echo bridge >> /etc/modules
echo br_netfilter >> /etc/modules

kubeadm init --pod-network-cidr=10.244.0.0/16 --kubernetes-version v${version} --token abcdef.1234567890123456
flannel_manifest="/tmp/flannel.yaml"
if [[ $minor_version -ge "16" ]]; then
flannel_manifest="/tmp/flannel-ge-16.yaml"
default_cidr="192.168.0.0/16"
pod_cidr="10.244.0.0/16"
kubeadm init --pod-network-cidr=$pod_cidr --kubernetes-version v${version} --token abcdef.1234567890123456

network_plugin_manifest="/tmp/flannel.yaml"
if [[ $minor_version -ge "17" ]]; then
network_plugin_manifest="/tmp/calico.yaml"
sed -i -e "s?$default_cidr?$pod_cidr?g" "$network_plugin_manifest"
elif [[ $minor_version -ge "16" ]]; then
network_plugin_manifest="/tmp/flannel-ge-16.yaml"
elif [[ $minor_version -ge "12" ]]; then
flannel_manifest="/tmp/flannel-ge-12.yaml"
network_plugin_manifest="/tmp/flannel-ge-12.yaml"
fi
kubectl --kubeconfig=/etc/kubernetes/admin.conf create -f "$flannel_manifest"

kubectl --kubeconfig=/etc/kubernetes/admin.conf create -f "$network_plugin_manifest"

# Wait at least for 7 pods
while [[ "$(kubectl --kubeconfig=/etc/kubernetes/admin.conf get pods -n kube-system --no-headers | wc -l)" -lt 7 ]]; do
Expand Down
Loading

0 comments on commit 73fdc31

Please sign in to comment.