Basic webapp deployer stack. (#722)

This commit is contained in:
Thomas E Lackey 2024-02-02 20:05:15 -06:00 committed by GitHub
parent 6629017d6a
commit 2fcd416e29
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 32 additions and 13 deletions

View File

@ -0,0 +1,9 @@
#!/usr/bin/env bash
# Build cerc/webapp-deployer-backend
source ${CERC_CONTAINER_BASE_DIR}/build-base.sh
# See: https://stackoverflow.com/a/246128/1701505
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
docker build -t cerc/webapp-deployer-backend:local ${build_command_args} ${CERC_REPO_BASE_DIR}/webapp-deployment-status-api

View File

@ -0,0 +1,11 @@
version: "1.0"
name: webapp-deployer-backend
description: "Deployer for webapps"
repos:
- git.vdb.to:telackey/webapp-deployment-status-api
containers:
- cerc/webapp-deployer-backend
pods:
- name: webapp-deployer-backend
repository: git.vdb.to:telackey/webapp-deployment-status-api
path: ./

View File

@ -347,8 +347,8 @@ def _make_cluster_context(ctx, stack, include, exclude, cluster, env_file):
else: else:
if deployment: if deployment:
compose_file_name = os.path.join(compose_dir, f"docker-compose-{pod_name}.yml") compose_file_name = os.path.join(compose_dir, f"docker-compose-{pod_name}.yml")
pod_pre_start_command = pod["pre_start_command"] pod_pre_start_command = pod.get("pre_start_command")
pod_post_start_command = pod["post_start_command"] pod_post_start_command = pod.get("post_start_command")
script_dir = compose_dir.parent.joinpath("pods", pod_name, "scripts") script_dir = compose_dir.parent.joinpath("pods", pod_name, "scripts")
if pod_pre_start_command is not None: if pod_pre_start_command is not None:
pre_start_commands.append(os.path.join(script_dir, pod_pre_start_command)) pre_start_commands.append(os.path.join(script_dir, pod_pre_start_command))
@ -357,8 +357,8 @@ def _make_cluster_context(ctx, stack, include, exclude, cluster, env_file):
else: else:
pod_root_dir = os.path.join(dev_root_path, pod_repository.split("/")[-1], pod["path"]) pod_root_dir = os.path.join(dev_root_path, pod_repository.split("/")[-1], pod["path"])
compose_file_name = os.path.join(pod_root_dir, f"docker-compose-{pod_name}.yml") compose_file_name = os.path.join(pod_root_dir, f"docker-compose-{pod_name}.yml")
pod_pre_start_command = pod["pre_start_command"] pod_pre_start_command = pod.get("pre_start_command")
pod_post_start_command = pod["post_start_command"] pod_post_start_command = pod.get("post_start_command")
if pod_pre_start_command is not None: if pod_pre_start_command is not None:
pre_start_commands.append(os.path.join(pod_root_dir, pod_pre_start_command)) pre_start_commands.append(os.path.join(pod_root_dir, pod_pre_start_command))
if pod_post_start_command is not None: if pod_post_start_command is not None:

View File

@ -360,11 +360,10 @@ def init_operation(deploy_command_context, stack, deployer_type, config,
for named_volume in named_volumes["rw"]: for named_volume in named_volumes["rw"]:
volume_descriptors[named_volume] = f"./data/{named_volume}" volume_descriptors[named_volume] = f"./data/{named_volume}"
for named_volume in named_volumes["ro"]: for named_volume in named_volumes["ro"]:
if "k8s" in deployer_type: if "k8s" in deployer_type and "config" in named_volume:
if "config" in named_volume: configmap_descriptors[named_volume] = f"./data/{named_volume}"
configmap_descriptors[named_volume] = f"./data/{named_volume}" else:
else: volume_descriptors[named_volume] = f"./data/{named_volume}"
volume_descriptors[named_volume] = f"./data/{named_volume}"
if volume_descriptors: if volume_descriptors:
spec_file_content["volumes"] = volume_descriptors spec_file_content["volumes"] = volume_descriptors
if configmap_descriptors: if configmap_descriptors:

View File

@ -243,7 +243,7 @@ class ClusterInfo:
), ),
) )
containers.append(container) containers.append(container)
volumes = volumes_for_pod_files(self.parsed_pod_yaml_map, self.spec) volumes = volumes_for_pod_files(self.parsed_pod_yaml_map, self.spec, self.app_name)
image_pull_secrets = [client.V1LocalObjectReference(name="laconic-registry")] image_pull_secrets = [client.V1LocalObjectReference(name="laconic-registry")]
template = client.V1PodTemplateSpec( template = client.V1PodTemplateSpec(
metadata=client.V1ObjectMeta(labels={"app": self.app_name}), metadata=client.V1ObjectMeta(labels={"app": self.app_name}),

View File

@ -108,7 +108,7 @@ def volume_mounts_for_service(parsed_pod_files, service):
return result return result
def volumes_for_pod_files(parsed_pod_files, spec): def volumes_for_pod_files(parsed_pod_files, spec, app_name):
result = [] result = []
for pod in parsed_pod_files: for pod in parsed_pod_files:
parsed_pod_file = parsed_pod_files[pod] parsed_pod_file = parsed_pod_files[pod]
@ -116,11 +116,11 @@ def volumes_for_pod_files(parsed_pod_files, spec):
volumes = parsed_pod_file["volumes"] volumes = parsed_pod_file["volumes"]
for volume_name in volumes.keys(): for volume_name in volumes.keys():
if volume_name in spec.get_configmaps(): if volume_name in spec.get_configmaps():
config_map = client.V1ConfigMapVolumeSource(name=volume_name) config_map = client.V1ConfigMapVolumeSource(name=f"{app_name}-{volume_name}")
volume = client.V1Volume(name=volume_name, config_map=config_map) volume = client.V1Volume(name=volume_name, config_map=config_map)
result.append(volume) result.append(volume)
else: else:
claim = client.V1PersistentVolumeClaimVolumeSource(claim_name=volume_name) claim = client.V1PersistentVolumeClaimVolumeSource(claim_name=f"{app_name}-{volume_name}")
volume = client.V1Volume(name=volume_name, persistent_volume_claim=claim) volume = client.V1Volume(name=volume_name, persistent_volume_claim=claim)
result.append(volume) result.append(volume)
return result return result