Add option to recreate deployments rather than update them. (#920)
All checks were successful
Lint Checks / Run linter (push) Successful in 48s
Publish / Build and publish (push) Successful in 1m21s
Smoke Test / Run basic test suite (push) Successful in 4m46s
Webapp Test / Run webapp test suite (push) Successful in 5m16s
Deploy Test / Run deploy test suite (push) Successful in 5m41s
All checks were successful
Lint Checks / Run linter (push) Successful in 48s
Publish / Build and publish (push) Successful in 1m21s
Smoke Test / Run basic test suite (push) Successful in 4m46s
Webapp Test / Run webapp test suite (push) Successful in 5m16s
Deploy Test / Run deploy test suite (push) Successful in 5m41s
cherry-pick from #912 Reviewed-on: #920 Reviewed-by: David Boreham <dboreham@noreply.git.vdb.to>
This commit is contained in:
parent
5c275aa622
commit
952389abb0
@ -45,6 +45,7 @@ def process_app_deployment_request(
|
|||||||
image_registry,
|
image_registry,
|
||||||
force_rebuild,
|
force_rebuild,
|
||||||
fqdn_policy,
|
fqdn_policy,
|
||||||
|
recreate_on_deploy,
|
||||||
logger
|
logger
|
||||||
):
|
):
|
||||||
logger.log("BEGIN - process_app_deployment_request")
|
logger.log("BEGIN - process_app_deployment_request")
|
||||||
@ -165,6 +166,7 @@ def process_app_deployment_request(
|
|||||||
deploy_to_k8s(
|
deploy_to_k8s(
|
||||||
deployment_record,
|
deployment_record,
|
||||||
deployment_dir,
|
deployment_dir,
|
||||||
|
recreate_on_deploy,
|
||||||
logger
|
logger
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -220,12 +222,13 @@ def dump_known_requests(filename, requests, status="SEEN"):
|
|||||||
@click.option("--include-tags", help="Only include requests with matching tags (comma-separated).", default="")
|
@click.option("--include-tags", help="Only include requests with matching tags (comma-separated).", default="")
|
||||||
@click.option("--exclude-tags", help="Exclude requests with matching tags (comma-separated).", default="")
|
@click.option("--exclude-tags", help="Exclude requests with matching tags (comma-separated).", default="")
|
||||||
@click.option("--force-rebuild", help="Rebuild even if the image already exists.", is_flag=True)
|
@click.option("--force-rebuild", help="Rebuild even if the image already exists.", is_flag=True)
|
||||||
|
@click.option("--recreate-on-deploy", help="Remove and recreate deployments instead of updating them.", is_flag=True)
|
||||||
@click.option("--log-dir", help="Output build/deployment logs to directory.", default=None)
|
@click.option("--log-dir", help="Output build/deployment logs to directory.", default=None)
|
||||||
@click.pass_context
|
@click.pass_context
|
||||||
def command(ctx, kube_config, laconic_config, image_registry, deployment_parent_dir, # noqa: C901
|
def command(ctx, kube_config, laconic_config, image_registry, deployment_parent_dir, # noqa: C901
|
||||||
request_id, discover, state_file, only_update_state,
|
request_id, discover, state_file, only_update_state,
|
||||||
dns_suffix, fqdn_policy, record_namespace_dns, record_namespace_deployments, dry_run,
|
dns_suffix, fqdn_policy, record_namespace_dns, record_namespace_deployments, dry_run,
|
||||||
include_tags, exclude_tags, force_rebuild, log_dir):
|
include_tags, exclude_tags, force_rebuild, recreate_on_deploy, log_dir):
|
||||||
if request_id and discover:
|
if request_id and discover:
|
||||||
print("Cannot specify both --request-id and --discover", file=sys.stderr)
|
print("Cannot specify both --request-id and --discover", file=sys.stderr)
|
||||||
sys.exit(2)
|
sys.exit(2)
|
||||||
@ -374,6 +377,7 @@ def command(ctx, kube_config, laconic_config, image_registry, deployment_parent_
|
|||||||
image_registry,
|
image_registry,
|
||||||
force_rebuild,
|
force_rebuild,
|
||||||
fqdn_policy,
|
fqdn_policy,
|
||||||
|
recreate_on_deploy,
|
||||||
logger
|
logger
|
||||||
)
|
)
|
||||||
status = "DEPLOYED"
|
status = "DEPLOYED"
|
||||||
|
@ -318,17 +318,24 @@ def push_container_image(deployment_dir, logger):
|
|||||||
logger.log("Finished pushing images.")
|
logger.log("Finished pushing images.")
|
||||||
|
|
||||||
|
|
||||||
def deploy_to_k8s(deploy_record, deployment_dir, logger):
|
def deploy_to_k8s(deploy_record, deployment_dir, recreate, logger):
|
||||||
if not deploy_record:
|
|
||||||
command = "start"
|
|
||||||
else:
|
|
||||||
command = "update"
|
|
||||||
|
|
||||||
logger.log("Deploying to k8s ...")
|
logger.log("Deploying to k8s ...")
|
||||||
logger.log(f"Running {command} command on deployment dir: {deployment_dir}")
|
|
||||||
result = subprocess.run([sys.argv[0], "deployment", "--dir", deployment_dir, command],
|
if recreate:
|
||||||
stdout=logger.file, stderr=logger.file)
|
commands_to_run = ["stop", "start"]
|
||||||
result.check_returncode()
|
else:
|
||||||
|
if not deploy_record:
|
||||||
|
commands_to_run = ["start"]
|
||||||
|
else:
|
||||||
|
commands_to_run = ["update"]
|
||||||
|
|
||||||
|
for command in commands_to_run:
|
||||||
|
logger.log(f"Running {command} command on deployment dir: {deployment_dir}")
|
||||||
|
result = subprocess.run([sys.argv[0], "deployment", "--dir", deployment_dir, command],
|
||||||
|
stdout=logger.file, stderr=logger.file)
|
||||||
|
result.check_returncode()
|
||||||
|
logger.log(f"Finished {command} command on deployment dir: {deployment_dir}")
|
||||||
|
|
||||||
logger.log("Finished deploying to k8s.")
|
logger.log("Finished deploying to k8s.")
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user