Unchanged.
Some checks failed
Lint Checks / Run linter (pull_request) Failing after 57s
Deploy Test / Run deploy test suite (pull_request) Successful in 5m36s
K8s Deployment Control Test / Run deployment control suite on kind/k8s (pull_request) Successful in 6m47s
Smoke Test / Run basic test suite (pull_request) Successful in 4m49s
Webapp Test / Run webapp test suite (pull_request) Successful in 5m45s
K8s Deploy Test / Run deploy test suite on kind/k8s (pull_request) Successful in 12m13s
Some checks failed
Lint Checks / Run linter (pull_request) Failing after 57s
Deploy Test / Run deploy test suite (pull_request) Successful in 5m36s
K8s Deployment Control Test / Run deployment control suite on kind/k8s (pull_request) Successful in 6m47s
Smoke Test / Run basic test suite (pull_request) Successful in 4m49s
Webapp Test / Run webapp test suite (pull_request) Successful in 5m45s
K8s Deploy Test / Run deploy test suite on kind/k8s (pull_request) Successful in 12m13s
This commit is contained in:
parent
004b5ab8fe
commit
f90e0e2969
@ -27,9 +27,7 @@ from stack_orchestrator.deploy.deploy_types import DeployCommandContext
|
|||||||
|
|
||||||
def _fixup_container_tag(deployment_dir: str, image: str):
|
def _fixup_container_tag(deployment_dir: str, image: str):
|
||||||
deployment_dir_path = Path(deployment_dir)
|
deployment_dir_path = Path(deployment_dir)
|
||||||
compose_file = deployment_dir_path.joinpath(
|
compose_file = deployment_dir_path.joinpath("compose", "docker-compose-webapp-template.yml")
|
||||||
"compose", "docker-compose-webapp-template.yml"
|
|
||||||
)
|
|
||||||
# replace "cerc/webapp-container:local" in the file with our image tag
|
# replace "cerc/webapp-container:local" in the file with our image tag
|
||||||
with open(compose_file) as rfile:
|
with open(compose_file) as rfile:
|
||||||
contents = rfile.read()
|
contents = rfile.read()
|
||||||
@ -41,13 +39,13 @@ def _fixup_container_tag(deployment_dir: str, image: str):
|
|||||||
def _fixup_url_spec(spec_file_name: str, url: str):
|
def _fixup_url_spec(spec_file_name: str, url: str):
|
||||||
# url is like: https://example.com/path
|
# url is like: https://example.com/path
|
||||||
parsed_url = urlparse(url)
|
parsed_url = urlparse(url)
|
||||||
http_proxy_spec = f"""
|
http_proxy_spec = f'''
|
||||||
http-proxy:
|
http-proxy:
|
||||||
- host-name: {parsed_url.hostname}
|
- host-name: {parsed_url.hostname}
|
||||||
routes:
|
routes:
|
||||||
- path: '{parsed_url.path if parsed_url.path else "/"}'
|
- path: '{parsed_url.path if parsed_url.path else "/"}'
|
||||||
proxy-to: webapp:80
|
proxy-to: webapp:80
|
||||||
"""
|
'''
|
||||||
spec_file_path = Path(spec_file_name)
|
spec_file_path = Path(spec_file_name)
|
||||||
with open(spec_file_path) as rfile:
|
with open(spec_file_path) as rfile:
|
||||||
contents = rfile.read()
|
contents = rfile.read()
|
||||||
@ -56,9 +54,7 @@ def _fixup_url_spec(spec_file_name: str, url: str):
|
|||||||
wfile.write(contents)
|
wfile.write(contents)
|
||||||
|
|
||||||
|
|
||||||
def create_deployment(
|
def create_deployment(ctx, deployment_dir, image, url, kube_config, image_registry, env_file):
|
||||||
ctx, deployment_dir, image, url, kube_config, image_registry, env_file
|
|
||||||
):
|
|
||||||
# Do the equivalent of:
|
# Do the equivalent of:
|
||||||
# 1. laconic-so --stack webapp-template deploy --deploy-to k8s init --output webapp-spec.yml
|
# 1. laconic-so --stack webapp-template deploy --deploy-to k8s init --output webapp-spec.yml
|
||||||
# --config (eqivalent of the contents of my-config.env)
|
# --config (eqivalent of the contents of my-config.env)
|
||||||
@ -87,11 +83,17 @@ def create_deployment(
|
|||||||
kube_config,
|
kube_config,
|
||||||
image_registry,
|
image_registry,
|
||||||
spec_file_name,
|
spec_file_name,
|
||||||
None,
|
None
|
||||||
)
|
)
|
||||||
# Add the TLS and DNS spec
|
# Add the TLS and DNS spec
|
||||||
_fixup_url_spec(spec_file_name, url)
|
_fixup_url_spec(spec_file_name, url)
|
||||||
create_operation(deploy_command_context, spec_file_name, deployment_dir, None, None)
|
create_operation(
|
||||||
|
deploy_command_context,
|
||||||
|
spec_file_name,
|
||||||
|
deployment_dir,
|
||||||
|
None,
|
||||||
|
None
|
||||||
|
)
|
||||||
# Fix up the container tag inside the deployment compose file
|
# Fix up the container tag inside the deployment compose file
|
||||||
_fixup_container_tag(deployment_dir, image)
|
_fixup_container_tag(deployment_dir, image)
|
||||||
os.remove(spec_file_name)
|
os.remove(spec_file_name)
|
||||||
@ -100,7 +102,7 @@ def create_deployment(
|
|||||||
@click.group()
|
@click.group()
|
||||||
@click.pass_context
|
@click.pass_context
|
||||||
def command(ctx):
|
def command(ctx):
|
||||||
"""manage a webapp deployment"""
|
'''manage a webapp deployment'''
|
||||||
|
|
||||||
# Check that --stack wasn't supplied
|
# Check that --stack wasn't supplied
|
||||||
if ctx.parent.obj.stack:
|
if ctx.parent.obj.stack:
|
||||||
@ -109,20 +111,13 @@ def command(ctx):
|
|||||||
|
|
||||||
@command.command()
|
@command.command()
|
||||||
@click.option("--kube-config", help="Provide a config file for a k8s deployment")
|
@click.option("--kube-config", help="Provide a config file for a k8s deployment")
|
||||||
@click.option(
|
@click.option("--image-registry", help="Provide a container image registry url for this k8s cluster")
|
||||||
"--image-registry",
|
@click.option("--deployment-dir", help="Create deployment files in this directory", required=True)
|
||||||
help="Provide a container image registry url for this k8s cluster",
|
|
||||||
)
|
|
||||||
@click.option(
|
|
||||||
"--deployment-dir", help="Create deployment files in this directory", required=True
|
|
||||||
)
|
|
||||||
@click.option("--image", help="image to deploy", required=True)
|
@click.option("--image", help="image to deploy", required=True)
|
||||||
@click.option("--url", help="url to serve", required=True)
|
@click.option("--url", help="url to serve", required=True)
|
||||||
@click.option("--env-file", help="environment file for webapp")
|
@click.option("--env-file", help="environment file for webapp")
|
||||||
@click.pass_context
|
@click.pass_context
|
||||||
def create(ctx, deployment_dir, image, url, kube_config, image_registry, env_file):
|
def create(ctx, deployment_dir, image, url, kube_config, image_registry, env_file):
|
||||||
"""create a deployment for the specified webapp container"""
|
'''create a deployment for the specified webapp container'''
|
||||||
|
|
||||||
return create_deployment(
|
return create_deployment(ctx, deployment_dir, image, url, kube_config, image_registry, env_file)
|
||||||
ctx, deployment_dir, image, url, kube_config, image_registry, env_file
|
|
||||||
)
|
|
||||||
|
Loading…
Reference in New Issue
Block a user