diff --git a/init-master.bash b/init-master.bash index 35eb553..8e6d8f7 100755 --- a/init-master.bash +++ b/init-master.bash @@ -1,6 +1,12 @@ #!/bin/bash +# +# Usage: sudo -E ./init-master.bash [pod_network_type] +# set -e +# Read Pod Network type from first arg (default to Flannel) +POD_NETWORK="${1:-flannel}" + kubeadm init --pod-network-cidr=10.244.0.0/16 # By now the master node should be ready! @@ -8,8 +14,20 @@ mkdir -p $HOME/.kube cp --remove-destination /etc/kubernetes/admin.conf $HOME/.kube/config chown ${SUDO_UID} $HOME/.kube/config -# Install flannel -kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/v0.9.1/Documentation/kube-flannel.yml +if [ "$POD_NETWORK" == "flannel" ]; then + # Install flannel + kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/v0.9.1/Documentation/kube-flannel.yml +elif [ "$POD_NETWORK" == "weave" ]; then + # Install weave + # From https://kubernetes.io/docs/setup/independent/create-cluster-kubeadm/ + sysctl net.bridge.bridge-nf-call-iptables=1 + kubectl apply -f "https://cloud.weave.works/k8s/net?k8s-version=$(kubectl version | base64 | tr -d '\n')" +else + echo "Unsupported pod network: $POD_NETWORK" + echo "Please choose a supported network type from one of the following: flannel weave" + exit 1 +fi + # Make master node a running worker node too! # FIXME: Use taint tolerations instead in the future