Skip to content

Commit

Permalink
CH-110 small changes to docker compose generation
Browse files Browse the repository at this point in the history
  • Loading branch information
filippomc committed Sep 17, 2024
1 parent 0eae79b commit 3529200
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 79 deletions.
14 changes: 6 additions & 8 deletions deployment-configuration/compose/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
apiVersion: v1
appVersion: "0.0.1"
description: CloudHarness Docker Compose
name: cloudharness
version: 0.0.1
appVersion: 2.4.0-compose
description: CloudHarness Docker compose Helm Chart
maintainers:
- name: Filippo Ledda
email: filippo@metacell.us
- name: Zoran Sinnema
email: [email protected]
- {email: [email protected], name: Filippo Ledda}
- {email: vincent@metacell.us, name: Vincent Aranega}
name: cloudharness
version: 0.0.1
2 changes: 1 addition & 1 deletion deployment-configuration/compose/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# CloudHarness Docker Compose: deploy CloudHarness to Docker Compose

Helm is used to define templates about how the CloudHarness deployment on Docker Compose. For further information about Helm, see https://helm.sh.
Helm is used to define templates about how the CloudHarness deployment on Docker Compose. For further information about Helm, see https://helm.sh.
47 changes: 1 addition & 46 deletions deployment-configuration/compose/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,52 +21,7 @@ apps: {}
env:
# -- Cloud Harness version
- name: CH_VERSION
value: 0.0.1
# -- Cloud harness chart version
- name: CH_CHART_VERSION
value: 0.0.1
privenv:
# -- Defines a secret as private environment variable that is injected in containers.
- name: CH_SECRET
value: In God we trust; all others must bring data. ― W. Edwards Deming
ingress:
# -- Flag to enable/disalbe ingress controller.
enabled: true
# -- K8s Name of ingress.
name: cloudharness-ingress
# -- Enables/disables SSL redirect.
ssl_redirect: true
letsencrypt:
# -- Email for letsencrypt.
email: [email protected]
backup:
# -- Flag to enable/disable backups.
active: false
# -- Number of days to keep backups.
keep_days: "7"
# -- Number of weeks to keep backups.
keep_weeks: "4"
# -- Number of months to keep backups.
keep_months: "6"
# -- Schedule as cronjob expression.
schedule: "*/5 * * * *"
# -- The file suffix added to backup files.
suffix: ".gz"
# -- The volume size for backups (all backups share the same volume)
volumesize: "2Gi"
# -- Target directory of backups, the mount point of the persistent volume.
dir: "/backups"
resources:
requests:
# -- K8s memory resource definition.
memory: "32Mi"
# -- K8s cpu resource definition.
cpu: "25m"
limits:
# -- K8s memory resource definition.
memory: "64Mi"
# -- K8s cpu resource definition.
cpu: "50m"
value: 2.4.0
proxy:
timeout:
# -- Timeout for proxy connections in seconds.
Expand Down
12 changes: 5 additions & 7 deletions deployment-configuration/helm/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
apiVersion: v1
appVersion: "0.0.1"
appVersion: 2.4.0
description: CloudHarness Helm Chart
name: cloudharness
version: 0.0.1
maintainers:
- name: Filippo Ledda
email: filippo@metacell.us
- name: Zoran Sinnema
email: [email protected]
- {email: [email protected], name: Filippo Ledda}
- {email: zoran@metacell.us, name: Zoran Sinnema}
name: cloudharness
version: 0.0.1
7 changes: 2 additions & 5 deletions deployment-configuration/helm/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@ apps: {}
env:
# -- Cloud Harness version
- name: CH_VERSION
value: 0.0.1
# -- Cloud harness chart version
- name: CH_CHART_VERSION
value: 0.0.1
value: 2.4.0
privenv:
# -- Defines a secret as private environment variable that is injected in containers.
- name: CH_SECRET
Expand All @@ -38,7 +35,7 @@ ingress:
ssl_redirect: true
letsencrypt:
# -- Email for letsencrypt.
email: filippo@metacell.us
email: cloudharness@metacell.us
backup:
# -- Flag to enable/disable backups.
active: false
Expand Down
3 changes: 1 addition & 2 deletions deployment-configuration/skaffold-template.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
apiVersion: skaffold/v2beta28
kind: Config
build:
tagPolicy:
sha256: {}
tagPolicy: {}
local:
useBuildkit: true
concurrency: 4
Expand Down
4 changes: 3 additions & 1 deletion tools/deployment-cli-tools/ch_cli_tools/dockercompose.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@

from .models import HarnessMainConfig

from .configurationgenerator import ConfigurationGenerator, validate_helm_values, KEY_HARNESS, KEY_SERVICE, KEY_DATABASE, KEY_APPS, KEY_TASK_IMAGES, KEY_TEST_IMAGES, KEY_DEPLOYMENT, values_from_legacy, values_set_legacy, get_included_with_dependencies, create_env_variables, collect_apps_helm_templates
from .configurationgenerator import ConfigurationGenerator, \
validate_helm_values, values_from_legacy, values_set_legacy, get_included_with_dependencies, create_env_variables, collect_apps_helm_templates, \
KEY_HARNESS, KEY_SERVICE, KEY_DATABASE, KEY_APPS, KEY_TASK_IMAGES, KEY_TEST_IMAGES, KEY_DEPLOYMENT


def create_docker_compose_configuration(root_paths, tag: Union[str, int, None] = 'latest', registry='', local=True, domain=None, exclude=(), secured=True,
Expand Down
22 changes: 13 additions & 9 deletions tools/deployment-cli-tools/ch_cli_tools/skaffold.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
from cloudharness_utils.constants import APPS_PATH, DEPLOYMENT_CONFIGURATION_PATH, \
BASE_IMAGES_PATH, STATIC_IMAGES_PATH, HELM_ENGINE, COMPOSE_ENGINE
from .helm import KEY_APPS, KEY_HARNESS, KEY_DEPLOYMENT, KEY_TASK_IMAGES
from .utils import get_template, dict_merge, find_dockerfiles_paths, app_name_from_path, \
find_file_paths, guess_build_dependencies_from_dockerfile, merge_to_yaml_file, get_json_template, get_image_name
from .utils import get_template, dict_merge, find_dockerfiles_paths, app_name_from_path, yaml, \
find_file_paths, guess_build_dependencies_from_dockerfile, get_json_template, get_image_name

from . import HERE

Expand All @@ -22,12 +22,13 @@ def relpath_if(p1, p2):


def create_skaffold_configuration(root_paths, helm_values: HarnessMainConfig, output_path='.', manage_task_images=True, backend_deploy=HELM_ENGINE):
skaffold_conf = get_template('skaffold-template.yaml', True)
backend = backend_deploy or HELM_ENGINE
template_name = 'skaffold-template.yaml'
skaffold_conf = get_template(template_name, True)
apps = helm_values.apps
base_image_name = (helm_values.registry.name or "") + helm_values.name
artifacts = {}
overrides = {}
backend = backend_deploy or HELM_ENGINE

def remove_tag(image_name):
return image_name.split(":")[0]
Expand Down Expand Up @@ -101,7 +102,7 @@ def process_build_dockerfile(

for root_path in root_paths:
skaffold_conf = dict_merge(skaffold_conf, get_template(
join(root_path, DEPLOYMENT_CONFIGURATION_PATH, 'skaffold-template.yaml')))
join(root_path, DEPLOYMENT_CONFIGURATION_PATH, template_name)))

base_dockerfiles = find_dockerfiles_paths(
join(root_path, BASE_IMAGES_PATH))
Expand Down Expand Up @@ -219,15 +220,19 @@ def identify_unicorn_based_main(candidates):
'images': [artifact['image'] for artifact in artifacts.values() if artifact['image']]
}
}
if backend == COMPOSE_ENGINE or not helm_values.tag:
skaffold_conf['build']['tagPolicy'] = {
'envTemplate': {
'template': '"{{.TAG}}"'
}
}
else:
skaffold_conf['build']['tagPolicy'] = {"sha256": {}}

skaffold_conf['build']['artifacts'] = [v for v in artifacts.values()]
merge_to_yaml_file(skaffold_conf, os.path.join(
output_path, 'skaffold.yaml'))

with open('skaffold.yaml', "w") as f:
yaml.dump(skaffold_conf, f)
return skaffold_conf


Expand All @@ -244,8 +249,7 @@ def git_clone_hook(conf: GitDependencyConfig, context_path: str):


def create_vscode_debug_configuration(root_paths, helm_values):
logging.info(
"Creating VS code cloud build configuration.\nCloud build extension is needed to debug.")
logging.info("Creating VS code cloud build configuration.\nCloud build extension is needed to debug.")

vscode_launch_path = '.vscode/launch.json'

Expand Down

0 comments on commit 3529200

Please sign in to comment.