From de762400ad5328a817a3d66f23f0bfbb24dfa55a Mon Sep 17 00:00:00 2001
From: Chad Swenson <chadswen@gmail.com>
Date: Tue, 30 Aug 2022 00:41:00 -0500
Subject: [PATCH] Fixes for calico_datastore: etcd (#9228)

It seems that PR #8839 broke `calico_datastore: etcd` when it removed ipamconfig support for etcd mode.

This PR fixes some failing tasks when `calico_datastore == etcd`, but it does not restore ipamconfig support for calico in etcd mode. If someone wants to restore ipamconfig support for `calico_datastore: etcd` please submit a follow up PR for that.
---
 roles/network_plugin/calico/tasks/install.yml          | 2 ++
 roles/network_plugin/calico/templates/calico-cr.yml.j2 | 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/roles/network_plugin/calico/tasks/install.yml b/roles/network_plugin/calico/tasks/install.yml
index 54c3deba4..11d5d2f09 100644
--- a/roles/network_plugin/calico/tasks/install.yml
+++ b/roles/network_plugin/calico/tasks/install.yml
@@ -451,6 +451,7 @@
     - {name: calico, file: calico-ipamconfig.yml, type: ipam}
   when:
     - inventory_hostname in groups['kube_control_plane']
+    - calico_datastore == "kdd"
 
 - name: Calico | Create ipamconfig resources
   kube:
@@ -459,6 +460,7 @@
     state: "latest"
   when:
     - inventory_hostname == groups['kube_control_plane'][0]
+    - calico_datastore == "kdd"
 
 - include_tasks: peer_with_calico_rr.yml
   when:
diff --git a/roles/network_plugin/calico/templates/calico-cr.yml.j2 b/roles/network_plugin/calico/templates/calico-cr.yml.j2
index e309c0418..b911b8737 100644
--- a/roles/network_plugin/calico/templates/calico-cr.yml.j2
+++ b/roles/network_plugin/calico/templates/calico-cr.yml.j2
@@ -157,6 +157,7 @@ rules:
       - daemonsets
     verbs:
       - get
+{% endif %}
   # Used for creating service account tokens to be used by the CNI plugin
   - apiGroups: [""]
     resources:
@@ -165,4 +166,3 @@ rules:
       - calico-node
     verbs:
       - create
-{% endif %}
-- 
GitLab