From a4d81f3c19cc4156a3d2b7d11cdb8a2e91f30107 Mon Sep 17 00:00:00 2001 From: Renuka Manavalan <47282725+renukamanavalan@users.noreply.github.com> Date: Tue, 9 Mar 2021 19:49:54 -0800 Subject: [PATCH] Copy dummy flannel.conf to get around absence of CNI Network (#6985) Why I did it We skip install of CNI plugin, as we don't need. But this leaves node in "not ready" state, upon joining master. To fix, we copy this dummy .conf file in /etc/cni/net.d How I did it Keep this file in /usr/share/sonic/templates and copy to /etc/cni/net.d upon joining k8s master. How to verify it Upon configuring master-IP and enable join, watch node join and move to ready state. You may verify using kubectl get nodes command --- .../build_templates/sonic_debian_extension.j2 | 4 +++ src/sonic-ctrmgrd/ctrmgr/ctrmgrd.py | 6 ++-- src/sonic-ctrmgrd/ctrmgr/kube_commands.py | 19 ++++++++----- src/sonic-ctrmgrd/tests/kube_commands_test.py | 28 ++++++++++++++----- 4 files changed, 40 insertions(+), 17 deletions(-) diff --git a/files/build_templates/sonic_debian_extension.j2 b/files/build_templates/sonic_debian_extension.j2 index 8edd9af847..9d2556edb5 100644 --- a/files/build_templates/sonic_debian_extension.j2 +++ b/files/build_templates/sonic_debian_extension.j2 @@ -403,6 +403,10 @@ sudo https_proxy=$https_proxy LANG=C chroot $FILESYSTEM_ROOT pip3 install azure- sudo https_proxy=$https_proxy LANG=C chroot $FILESYSTEM_ROOT pip3 install watchdog==0.10.3 {% if include_kubernetes == "y" %} +# Copy Flannel conf file into sonic-templates +# +sudo cp $BUILD_TEMPLATES/kube_cni.10-flannel.conflist $FILESYSTEM_ROOT_USR_SHARE_SONIC_TEMPLATES/ + # Install remote Container mgmt package # Required even if include_kubernetes != y, as it contains the # the container wrapper for docker start/stop/wait commands. diff --git a/src/sonic-ctrmgrd/ctrmgr/ctrmgrd.py b/src/sonic-ctrmgrd/ctrmgr/ctrmgrd.py index ba4f0057bd..49c11d2781 100755 --- a/src/sonic-ctrmgrd/ctrmgr/ctrmgrd.py +++ b/src/sonic-ctrmgrd/ctrmgr/ctrmgrd.py @@ -201,7 +201,7 @@ class MainServer: """ Modify entry for given table|key with given dict type data """ conn = self.db_connectors[db_name] tbl = swsscommon.Table(conn, table_name) - print("mod_db_entry: db={} tbl={} key={} data={}".format(db_name, table_name, key, str(data))) + log_debug("mod_db_entry: db={} tbl={} key={} data={}".format(db_name, table_name, key, str(data))) tbl.set(key, list(data.items())) @@ -242,7 +242,7 @@ class MainServer: if not UNIT_TESTING: raise Exception("Received error from select") else: - print("Skipped Exception; Received error from select") + log_debug("Skipped Exception; Received error from select") return for subscriber in self.subscribers: @@ -588,7 +588,7 @@ def main(): FeatureTransitionHandler(server) LabelsPendingHandler(server) server.run() - print("ctrmgrd.py main called") + log_debug("ctrmgrd.py main called") return 0 diff --git a/src/sonic-ctrmgrd/ctrmgr/kube_commands.py b/src/sonic-ctrmgrd/ctrmgr/kube_commands.py index 1ebfa606f0..db8cb348fc 100755 --- a/src/sonic-ctrmgrd/ctrmgr/kube_commands.py +++ b/src/sonic-ctrmgrd/ctrmgr/kube_commands.py @@ -22,6 +22,8 @@ KUBE_ADMIN_CONF = "/etc/sonic/kube_admin.conf" KUBELET_YAML = "/var/lib/kubelet/config.yaml" SERVER_ADMIN_URL = "https://{}/admin.conf" LOCK_FILE = "/var/lock/kube_join.lock" +FLANNEL_CONF_FILE = "/usr/share/sonic/templates/kube_cni.10-flannel.conflist" +CNI_DIR = "/etc/cni/net.d" # kubectl --kubeconfig label nodes #