Add generated kind config #623

Merged
telackey merged 7 commits from dboreham/kind-config into main 2023-11-06 06:21:54 +00:00
2 changed files with 7 additions and 7 deletions
Showing only changes of commit 17d63b4c9c - Show all commits

View File

@ -47,7 +47,7 @@ class K8sDeployer(Deployer):
def up(self, detach, services):
# Create the kind cluster
create_cluster(self.kind_cluster_name)
create_cluster(self.kind_cluster_name, )
self.connect_api()
# Ensure the referenced containers are copied into kind
load_images_into_kind(self.kind_cluster_name, self.cluster_info.image_set)
@ -120,7 +120,7 @@ class K8sDeployerConfigGenerator(DeployerConfigGenerator):
def generate(self, deployment_dir: Path):
# Check the file isn't already there
# Get the config file contents
content = generate_kind_config()
content = generate_kind_config(deployment_dir)
config_file = deployment_dir.joinpath(self.config_file_name)
# Write the file
with open(config_file, "w") as output_file:

View File

@ -130,10 +130,10 @@ def _generate_kind_mounts(parsed_pod_files):
for mount_string in volumes:
# Looks like: test-data:/data
(volume_name, mount_path) = mount_string.split(":")
volume_definitions.append(f"- hostPath: <where-is-this>\n containerPath:{mount_path}")
volume_definitions.append(f" - hostPath: <where-is-this>\n containerPath:{mount_path}")
return (
"" if len(volume_definitions) == 0 else (
"extraMounts:\n"
" extraMounts:\n"
f"{''.join(volume_definitions)}"
)
)
@ -152,10 +152,10 @@ def _generate_kind_port_mappings(parsed_pod_files):
for port_string in ports:
# TODO handle the complex cases
# Looks like: 80 or something more complicated
port_definitions.append(f"- containerPort: {port_string}\n hostPort:{port_string}")
port_definitions.append(f" - containerPort: {port_string}\n hostPort:{port_string}")
return (
"" if len(port_definitions) == 0 else (
"extraPortMappings:\n"
" extraPortMappings:\n"
f"{''.join(port_definitions)}"
)
)
@ -190,7 +190,7 @@ def generate_kind_config(deployment_dir: Path):
"kind: Cluster\n"
"apiVersion: kind.x-k8s.io/v1alpha4\n"
"nodes:\n"
" - role: control-plane\n"
"- role: control-plane\n"
f"{port_mappings_yml}\n"
f"{mounts_yml}\n"
)