cluster-builder 0.1.0__py3-none-any.whl → 0.1.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of cluster-builder might be problematic. Click here for more details.
- cluster_builder/swarmchestrate.py +42 -24
- {cluster_builder-0.1.0.dist-info → cluster_builder-0.1.2.dist-info}/METADATA +1 -1
- cluster_builder-0.1.2.dist-info/RECORD +7 -0
- cluster_builder-0.1.0.dist-info/RECORD +0 -7
- {cluster_builder-0.1.0.dist-info → cluster_builder-0.1.2.dist-info}/WHEEL +0 -0
- {cluster_builder-0.1.0.dist-info → cluster_builder-0.1.2.dist-info}/licenses/LICENSE +0 -0
- {cluster_builder-0.1.0.dist-info → cluster_builder-0.1.2.dist-info}/top_level.txt +0 -0
|
@@ -50,9 +50,7 @@ class Swarmchestrate:
|
|
|
50
50
|
|
|
51
51
|
# Initialise components
|
|
52
52
|
self.template_manager = TemplateManager()
|
|
53
|
-
self.cluster_config = ClusterConfig(
|
|
54
|
-
self.template_manager, output_dir, self.pg_config
|
|
55
|
-
)
|
|
53
|
+
self.cluster_config = ClusterConfig(self.template_manager, output_dir)
|
|
56
54
|
|
|
57
55
|
logger.info(
|
|
58
56
|
f"Initialised with template_dir={template_dir}, output_dir={output_dir}"
|
|
@@ -79,23 +77,17 @@ class Swarmchestrate:
|
|
|
79
77
|
"""
|
|
80
78
|
return self.cluster_config.generate_random_name()
|
|
81
79
|
|
|
82
|
-
def
|
|
80
|
+
def validate_configuration(self, cloud: str, config: dict) -> list:
|
|
83
81
|
"""
|
|
84
|
-
Validate
|
|
82
|
+
Validate a configuration against the required variables for a cloud provider.
|
|
85
83
|
|
|
86
84
|
Args:
|
|
87
|
-
|
|
85
|
+
cloud: Cloud provider name
|
|
86
|
+
config: Configuration dictionary provided by the user
|
|
88
87
|
|
|
89
|
-
|
|
90
|
-
|
|
88
|
+
Returns:
|
|
89
|
+
List of missing required variables (empty if all required variables are present)
|
|
91
90
|
"""
|
|
92
|
-
# Check required fields
|
|
93
|
-
if "cloud" not in config:
|
|
94
|
-
raise ValueError("Cloud provider must be specified in configuration")
|
|
95
|
-
|
|
96
|
-
if "k3s_role" not in config:
|
|
97
|
-
raise ValueError("K3s role must be specified in configuration")
|
|
98
|
-
|
|
99
91
|
# Master IP validation
|
|
100
92
|
has_master_ip = "master_ip" in config and config["master_ip"]
|
|
101
93
|
role = config["k3s_role"]
|
|
@@ -103,13 +95,24 @@ class Swarmchestrate:
|
|
|
103
95
|
# Cannot add a master node to an existing cluster
|
|
104
96
|
if has_master_ip and role == "master":
|
|
105
97
|
raise ValueError(
|
|
106
|
-
"Cannot add
|
|
98
|
+
"Cannot add master to existing cluster (master_ip specified with master role)"
|
|
107
99
|
)
|
|
108
100
|
|
|
109
101
|
# Worker/HA nodes require a master IP
|
|
110
102
|
if not has_master_ip and role in ["worker", "ha"]:
|
|
111
103
|
raise ValueError(f"Role '{role}' requires master_ip to be specified")
|
|
112
104
|
|
|
105
|
+
required_vars = self.template_manager.get_required_variables(cloud)
|
|
106
|
+
|
|
107
|
+
# Find missing required variables
|
|
108
|
+
missing_vars = []
|
|
109
|
+
for var_name, var_config in required_vars.items():
|
|
110
|
+
# If variable has no default and is not in config, it's required but missing
|
|
111
|
+
if "default" not in var_config and var_name not in config:
|
|
112
|
+
missing_vars.append(var_name)
|
|
113
|
+
|
|
114
|
+
return missing_vars
|
|
115
|
+
|
|
113
116
|
def prepare_infrastructure(
|
|
114
117
|
self, config: dict[str, any]
|
|
115
118
|
) -> tuple[str, dict[str, any]]:
|
|
@@ -131,14 +134,18 @@ class Swarmchestrate:
|
|
|
131
134
|
RuntimeError: If file operations fail
|
|
132
135
|
"""
|
|
133
136
|
try:
|
|
134
|
-
#
|
|
135
|
-
self._validate_node_config(config)
|
|
136
|
-
|
|
137
|
-
# Prepare the configuration and files
|
|
137
|
+
# Prepare the configuration
|
|
138
138
|
cluster_dir, prepared_config = self.cluster_config.prepare(config)
|
|
139
139
|
|
|
140
|
+
# Validate the configuration
|
|
141
|
+
cloud = prepared_config["cloud"]
|
|
142
|
+
missing_vars = self.validate_configuration(cloud, prepared_config)
|
|
143
|
+
if missing_vars:
|
|
144
|
+
raise ValueError(
|
|
145
|
+
f"Missing required variables for cloud provider '{cloud}': {', '.join(missing_vars)}"
|
|
146
|
+
)
|
|
147
|
+
|
|
140
148
|
# Create provider configuration
|
|
141
|
-
cloud = config["cloud"]
|
|
142
149
|
self.template_manager.create_provider_config(cluster_dir, cloud)
|
|
143
150
|
logger.info(f"Created provider configuration for {cloud}")
|
|
144
151
|
|
|
@@ -147,9 +154,12 @@ class Swarmchestrate:
|
|
|
147
154
|
backend_tf_path = os.path.join(cluster_dir, "backend.tf")
|
|
148
155
|
|
|
149
156
|
# Add backend configuration
|
|
157
|
+
|
|
158
|
+
# Add PostgreSQL connection string to config
|
|
159
|
+
conn_str = self.pg_config.get_connection_string()
|
|
150
160
|
hcl.add_backend_config(
|
|
151
161
|
backend_tf_path,
|
|
152
|
-
|
|
162
|
+
conn_str,
|
|
153
163
|
prepared_config["cluster_name"],
|
|
154
164
|
)
|
|
155
165
|
logger.info(f"Added backend configuration to {backend_tf_path}")
|
|
@@ -294,7 +304,12 @@ class Swarmchestrate:
|
|
|
294
304
|
return
|
|
295
305
|
|
|
296
306
|
# Plan the deployment
|
|
297
|
-
CommandExecutor.run_command(
|
|
307
|
+
CommandExecutor.run_command(
|
|
308
|
+
["tofu", "plan", "-input=false"],
|
|
309
|
+
cluster_dir,
|
|
310
|
+
"OpenTofu plan",
|
|
311
|
+
timeout=30,
|
|
312
|
+
)
|
|
298
313
|
|
|
299
314
|
# Apply the deployment
|
|
300
315
|
CommandExecutor.run_command(
|
|
@@ -335,7 +350,10 @@ class Swarmchestrate:
|
|
|
335
350
|
try:
|
|
336
351
|
# Plan destruction
|
|
337
352
|
CommandExecutor.run_command(
|
|
338
|
-
["tofu", "plan", "-destroy"
|
|
353
|
+
["tofu", "plan", "-destroy", "-input=false"],
|
|
354
|
+
cluster_dir,
|
|
355
|
+
"OpenTofu plan destruction",
|
|
356
|
+
timeout=30,
|
|
339
357
|
)
|
|
340
358
|
|
|
341
359
|
# Execute destruction
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
cluster_builder/__init__.py,sha256=p2Rb2BTVm-ScqCKE38436WsItY1BjVAnvx7zwmneSLs,256
|
|
2
|
+
cluster_builder/swarmchestrate.py,sha256=JZakXW_uEtp1AmsQj5gEHXPtqgaTZZCMeQ73eojA-Sw,13254
|
|
3
|
+
cluster_builder-0.1.2.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
4
|
+
cluster_builder-0.1.2.dist-info/METADATA,sha256=DDatkIcPaDuYQQq0usOgytZ5lognhp8-yn8XWr3P9SQ,7563
|
|
5
|
+
cluster_builder-0.1.2.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
|
|
6
|
+
cluster_builder-0.1.2.dist-info/top_level.txt,sha256=fTW8EW1mcWoeWprjwxSHRWpqfXYX8iN-ByEt8HPXIcs,16
|
|
7
|
+
cluster_builder-0.1.2.dist-info/RECORD,,
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
cluster_builder/__init__.py,sha256=p2Rb2BTVm-ScqCKE38436WsItY1BjVAnvx7zwmneSLs,256
|
|
2
|
-
cluster_builder/swarmchestrate.py,sha256=K3zWA4Ob6XVH0GDlDQW13Q3IHd1gEjHRvBfgtBLi-Wo,12471
|
|
3
|
-
cluster_builder-0.1.0.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
4
|
-
cluster_builder-0.1.0.dist-info/METADATA,sha256=TLtMwDzzR5Rt79rie7_wkpKClfEbMzkNvljELcot-WM,7563
|
|
5
|
-
cluster_builder-0.1.0.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
|
|
6
|
-
cluster_builder-0.1.0.dist-info/top_level.txt,sha256=fTW8EW1mcWoeWprjwxSHRWpqfXYX8iN-ByEt8HPXIcs,16
|
|
7
|
-
cluster_builder-0.1.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|