Update cluster configuration to support feature 11055
Change-Id: I350be30250ac87aebe83f3284e2dab859df254f8
Signed-off-by: rshri <shrinithi.r@tataelxsi.co.in>
diff --git a/osm_lcm/odu_libs/cluster_mgmt.py b/osm_lcm/odu_libs/cluster_mgmt.py
index c5ea6c0..60c0378 100644
--- a/osm_lcm/odu_libs/cluster_mgmt.py
+++ b/osm_lcm/odu_libs/cluster_mgmt.py
@@ -18,6 +18,7 @@
import yaml
import base64
+import json
def gather_age_key(cluster):
@@ -93,6 +94,33 @@
else:
raise Exception("Not suitable VIM account to register cluster")
+ # Create configmap for subnet
+ configmap_name = None
+ data = {}
+ private_subnets = op_params.get("private_subnet")
+ public_subnets = op_params.get("public_subnet")
+ if private_subnets or public_subnets:
+ configmap_name = f"{cluster_name}-parameters"
+ configmap_namespace = "managed-resources"
+ data["private_subnets"] = f"{json.dumps(private_subnets)}"
+ data["public_subnets"] = f"{json.dumps(public_subnets)}"
+ try:
+ self.logger.debug(f"Testing kubectl: {self._kubectl}")
+ self.logger.debug(
+ f"Testing kubectl configuration: {self._kubectl.configuration}"
+ )
+ self.logger.debug(
+ f"Testing kubectl configuration Host: {self._kubectl.configuration.host}"
+ )
+ await self.create_configmap(
+ configmap_name,
+ configmap_namespace,
+ data,
+ )
+ except Exception as e:
+ self.logger.info(f"Cannot create configmap {configmap_name}: {e}")
+ return False, f"Cannot create configmap {configmap_name}: {e}"
+
# Render workflow
# workflow_kwargs = {
# "git_fleet_url": self._repo_fleet_url,
@@ -116,10 +144,14 @@
public_key_mgmt=self._pubkey,
public_key_new_cluster=public_key_new_cluster,
secret_name_private_key_new_cluster=secret_name,
- vm_size=db_cluster["node_size"],
- node_count=db_cluster["node_count"],
+ vm_size=db_cluster.get("node_size", "default"),
+ node_count=db_cluster.get("node_count", "default"),
k8s_version=db_cluster["k8s_version"],
cluster_location=db_cluster["region_name"],
+ configmap_name=configmap_name if configmap_name else "default",
+ cluster_iam_role=db_cluster.get("iam_role", "default"),
+ cluster_private_subnets_id=db_cluster.get("private_subnet", "default"),
+ cluster_public_subnets_id=db_cluster.get("public_subnet", "default"),
osm_project_name=osm_project_name,
rg_name=db_cluster.get("resource_group", "''"),
preemptible_nodes=db_cluster.get("preemptible_nodes", "false"),
@@ -484,7 +516,13 @@
"name": f"secret-age-{content['cluster']['git_name'].lower()}",
"namespace": "osm-workflows",
}
- ]
+ ],
+ "configmaps": [
+ {
+ "name": f"{content['cluster']['name']}-parameters",
+ "namespace": "managed-resources",
+ }
+ ],
}
try:
await self.clean_items(items)