From fb35011023eead6fdfd73129c83ad3ad68f2117c Mon Sep 17 00:00:00 2001 From: Konstantinos Tsakalozos Date: Mon, 10 Aug 2020 14:47:52 +0300 Subject: [PATCH] Fix cilium in an ha cluster (#1453) --- microk8s-resources/actions/disable.cilium.sh | 16 +++++++++++----- microk8s-resources/actions/enable.cilium.sh | 6 ++++++ 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/microk8s-resources/actions/disable.cilium.sh b/microk8s-resources/actions/disable.cilium.sh index 02aef83762..3fc70dda98 100755 --- a/microk8s-resources/actions/disable.cilium.sh +++ b/microk8s-resources/actions/disable.cilium.sh @@ -35,9 +35,15 @@ then run_with_sudo $SNAP/sbin/ip link delete "cilium_vxlan" fi -set_service_expected_to_start flanneld - -echo "Restarting flanneld" -run_with_sudo preserve_env snapctl stop "${SNAP_NAME}.daemon-flanneld" - +if [ -e "$SNAP_DATA/var/lock/ha-cluster" ] && [ -e "$SNAP_DATA/args/cni-network/cni.yaml.disabled" ] +then + echo "Restarting default cni" + run_with_sudo mv "$SNAP_DATA/args/cni-network/cni.yaml.disabled" "$SNAP_DATA/args/cni-network/cni.yaml" + "$SNAP/kubectl" "--kubeconfig=$SNAP_DATA/credentials/client.config" apply -f "$SNAP_DATA/args/cni-network/cni.yaml" +else + echo "Restarting flanneld" + set_service_expected_to_start flanneld + + run_with_sudo preserve_env snapctl start "${SNAP_NAME}.daemon-flanneld" +fi echo "Cilium is terminating" diff --git a/microk8s-resources/actions/enable.cilium.sh b/microk8s-resources/actions/enable.cilium.sh index 4db3164c4f..02312b4b5c 100755 --- a/microk8s-resources/actions/enable.cilium.sh +++ b/microk8s-resources/actions/enable.cilium.sh @@ -73,6 +73,12 @@ else "$SNAP/kubectl" "--kubeconfig=$SNAP_DATA/credentials/client.config" apply -f "$SNAP_DATA/actions/cilium.yaml" "$SNAP/kubectl" "--kubeconfig=$SNAP_DATA/credentials/client.config" -n $NAMESPACE rollout status ds/cilium + if [ -e "$SNAP_DATA/args/cni-network/cni.yaml" ] + then + "$SNAP/kubectl" "--kubeconfig=$SNAP_DATA/credentials/client.config" delete -f "$SNAP_DATA/args/cni-network/cni.yaml" + run_with_sudo mv "$SNAP_DATA/args/cni-network/cni.yaml" "$SNAP_DATA/args/cni-network/cni.yaml.disabled" + fi + # Fetch the Cilium CLI binary and install CILIUM_POD=$("$SNAP/kubectl" "--kubeconfig=$SNAP_DATA/credentials/client.config" -n $NAMESPACE get pod -l $CILIUM_LABELS -o jsonpath="{.items[0].metadata.name}") CILIUM_BIN=$(mktemp)