From 2d764fc7d0b15ffc3e3b78ae884c8f7825966703 Mon Sep 17 00:00:00 2001 From: zramsay Date: Mon, 29 Jan 2024 16:00:58 +0000 Subject: [PATCH 1/7] basic mars stack --- stack_orchestrator/data/compose/docker-compose-mars.yml | 8 ++++++++ .../data/container-build/cerc-mars/build.sh | 4 ++++ stack_orchestrator/data/stacks/mars/stack.yml | 8 ++++++++ 3 files changed, 20 insertions(+) create mode 100644 stack_orchestrator/data/compose/docker-compose-mars.yml create mode 100755 stack_orchestrator/data/container-build/cerc-mars/build.sh create mode 100644 stack_orchestrator/data/stacks/mars/stack.yml diff --git a/stack_orchestrator/data/compose/docker-compose-mars.yml b/stack_orchestrator/data/compose/docker-compose-mars.yml new file mode 100644 index 00000000..5b1a44e0 --- /dev/null +++ b/stack_orchestrator/data/compose/docker-compose-mars.yml @@ -0,0 +1,8 @@ +version: "3.2" + +services: + mars: + image: cerc/mars:local + restart: always + ports: + - "3000:3000" diff --git a/stack_orchestrator/data/container-build/cerc-mars/build.sh b/stack_orchestrator/data/container-build/cerc-mars/build.sh new file mode 100755 index 00000000..28ebf417 --- /dev/null +++ b/stack_orchestrator/data/container-build/cerc-mars/build.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash +# Build the mars image +source ${CERC_CONTAINER_BASE_DIR}/build-base.sh +docker build -t cerc/mars:local -f ${CERC_REPO_BASE_DIR}/mars-interface/Dockerfile ${build_command_args} ${CERC_REPO_BASE_DIR}/mars-interface diff --git a/stack_orchestrator/data/stacks/mars/stack.yml b/stack_orchestrator/data/stacks/mars/stack.yml new file mode 100644 index 00000000..314afa36 --- /dev/null +++ b/stack_orchestrator/data/stacks/mars/stack.yml @@ -0,0 +1,8 @@ +version: "0.1" +name: mars +repos: + - github.com/cerc-io/mars-interface +containers: + - cerc/mars +pods: + - mars From 23ee3e19b71e2cd51b50bf56e300478792fb2552 Mon Sep 17 00:00:00 2001 From: zramsay Date: Mon, 29 Jan 2024 22:44:55 +0000 Subject: [PATCH 2/7] mars: add env vars to docker-compose --- .../data/compose/docker-compose-mars.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/stack_orchestrator/data/compose/docker-compose-mars.yml b/stack_orchestrator/data/compose/docker-compose-mars.yml index 5b1a44e0..193a90af 100644 --- a/stack_orchestrator/data/compose/docker-compose-mars.yml +++ b/stack_orchestrator/data/compose/docker-compose-mars.yml @@ -6,3 +6,15 @@ services: restart: always ports: - "3000:3000" + environment: + - URL_OSMOSIS_GQL=https://osmosis-node.marsprotocol.io/GGSFGSFGFG34/osmosis-hive-front/graphql + - URL_OSMOSIS_REST=https://lcd-osmosis.blockapsis.com + - URL_OSMOSIS_RPC=https://rpc-osmosis.blockapsis.com + - URL_NEUTRON_GQL=https://neutron.rpc.p2p.world/qgrnU6PsQZA8F9S5Fb8Fn3tV3kXmMBl2M9bcc9jWLjQy8p/hive/graphql + - URL_NEUTRON_REST=https://rest-kralum.neutron-1.neutron.org + - URL_NEUTRON_RPC=https://rpc-kralum.neutron-1.neutron.org + - URL_NEUTRON_TEST_GQL=https://testnet-neutron-gql.marsprotocol.io/graphql + - URL_NEUTRON_TEST_REST=https://rest-palvus.pion-1.ntrn.tech + - URL_NEUTRON_TEST_RPC=https://rpc-palvus.pion-1.ntrn.tech + - WALLET_CONNECT_ID=0x0x0x0x0x0x0x0x0x0x0x0x0x0x0x0x0x0x0x0x + From 098567625a0591942b7d5226cd40c48d3f2df150 Mon Sep 17 00:00:00 2001 From: Zach Date: Tue, 30 Jan 2024 17:47:56 -0500 Subject: [PATCH 3/7] Create README.md --- stack_orchestrator/data/stacks/mars/README.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 stack_orchestrator/data/stacks/mars/README.md diff --git a/stack_orchestrator/data/stacks/mars/README.md b/stack_orchestrator/data/stacks/mars/README.md new file mode 100644 index 00000000..fb1eff41 --- /dev/null +++ b/stack_orchestrator/data/stacks/mars/README.md @@ -0,0 +1,16 @@ +# mars + +On a fresh Digital Ocean droplet with Ubuntu: + +``` +git clone https://github.com/cerc-io/stack-orchestrator +cd stack-orchestrator +./scripts/quick-install-linux.sh +``` +Read and follow the instructions output from the above output to complete installation, then: + +``` +laconic-so --stack mars setup-repositories +laconic-so --stack mars build-containers +laconic-so --stack mars deploy up +``` From afd6be3b138353e1c4a2f310d86bcaff428954e3 Mon Sep 17 00:00:00 2001 From: zramsay Date: Thu, 8 Feb 2024 20:13:12 +0000 Subject: [PATCH 4/7] Ping pub (#663) for #170, revives #190 uses https://github.com/LaconicNetwork/explorer/pull/1 Co-authored-by: zramsay Co-authored-by: David Boreham Reviewed-on: https://git.vdb.to/cerc-io/stack-orchestrator/pulls/663 Co-authored-by: zramsay Co-committed-by: zramsay --- .../data/compose/docker-compose-ping-pub.yml | 8 ++++++++ .../data/container-build/cerc-ping-pub/build.sh | 5 +++++ stack_orchestrator/data/stacks/ping-pub/README.md | 10 ++++++++++ stack_orchestrator/data/stacks/ping-pub/stack.yml | 9 +++++++++ 4 files changed, 32 insertions(+) create mode 100644 stack_orchestrator/data/compose/docker-compose-ping-pub.yml create mode 100755 stack_orchestrator/data/container-build/cerc-ping-pub/build.sh create mode 100644 stack_orchestrator/data/stacks/ping-pub/README.md create mode 100644 stack_orchestrator/data/stacks/ping-pub/stack.yml diff --git a/stack_orchestrator/data/compose/docker-compose-ping-pub.yml b/stack_orchestrator/data/compose/docker-compose-ping-pub.yml new file mode 100644 index 00000000..e2120bc2 --- /dev/null +++ b/stack_orchestrator/data/compose/docker-compose-ping-pub.yml @@ -0,0 +1,8 @@ +version: "3.2" + +services: + ping-pub: + image: cerc/ping-pub:local + restart: always + ports: + - "5173:5173" diff --git a/stack_orchestrator/data/container-build/cerc-ping-pub/build.sh b/stack_orchestrator/data/container-build/cerc-ping-pub/build.sh new file mode 100755 index 00000000..391525dd --- /dev/null +++ b/stack_orchestrator/data/container-build/cerc-ping-pub/build.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +# Build the ping pub image +source ${CERC_CONTAINER_BASE_DIR}/build-base.sh + +docker build -t cerc/ping-pub:local ${build_command_args} -f $CERC_REPO_BASE_DIR/explorer/Dockerfile $CERC_REPO_BASE_DIR/explorer diff --git a/stack_orchestrator/data/stacks/ping-pub/README.md b/stack_orchestrator/data/stacks/ping-pub/README.md new file mode 100644 index 00000000..32378b6f --- /dev/null +++ b/stack_orchestrator/data/stacks/ping-pub/README.md @@ -0,0 +1,10 @@ +# ping-pub +Experimental block explorer for laconic + +``` +laconic-so --stack ping-pub setup-repositories +laconic-so --stack ping-pub build-containers +laconic-so --stack ping-pub deploy init --output ping-pub-spec.yml --map-ports-to-host localhost-same +laconic-so --stack ping-pub deploy create --spec-file ping-pub-spec.yml --deployment-dir pp-deployment +laconic-so deployment --dir pp-deployment start +``` diff --git a/stack_orchestrator/data/stacks/ping-pub/stack.yml b/stack_orchestrator/data/stacks/ping-pub/stack.yml new file mode 100644 index 00000000..f2d86d59 --- /dev/null +++ b/stack_orchestrator/data/stacks/ping-pub/stack.yml @@ -0,0 +1,9 @@ +version: "0.1" +name: ping-pub +repos: + # fork, but only for config & Dockerfile reasonsb + - github.com/LaconicNetwork/explorer@laconic +containers: + - cerc/ping-pub +pods: + - ping-pub From 72ed2eb91abfc5db06a318013b0d3807a2604721 Mon Sep 17 00:00:00 2001 From: Thomas E Lackey Date: Thu, 8 Feb 2024 20:38:41 +0000 Subject: [PATCH 5/7] Fix bad test in tag check. (#738) Reviewed-on: https://git.vdb.to/cerc-io/stack-orchestrator/pulls/738 Co-authored-by: Thomas E Lackey Co-committed-by: Thomas E Lackey --- stack_orchestrator/deploy/webapp/util.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/stack_orchestrator/deploy/webapp/util.py b/stack_orchestrator/deploy/webapp/util.py index 6cdec448..80b477f9 100644 --- a/stack_orchestrator/deploy/webapp/util.py +++ b/stack_orchestrator/deploy/webapp/util.py @@ -355,11 +355,13 @@ def generate_hostname_for_app(app): def skip_by_tag(r, include_tags, exclude_tags): for tag in exclude_tags: - if tag and r.attributes.tags and tag in r.attributes.tags: + if r.attributes.tags and tag in r.attributes.tags: return True - for tag in include_tags: - if tag and (not r.attributes.tags or tag not in r.attributes.tags): - return True + if include_tags: + for tag in include_tags: + if r.attributes.tags and tag in r.attributes.tags: + return False + return True return False From 903f3b10e2771c5f28646b5d37741936b64e4678 Mon Sep 17 00:00:00 2001 From: Thomas E Lackey Date: Fri, 9 Feb 2024 00:11:07 +0000 Subject: [PATCH 6/7] Add support for annotations and labels in spec. (#739) ``` stack: webapp-deployer-backend deploy-to: k8s annotations: foo.bar.annot/{name}: baz labels: a.b.c/{name}.blah: "value" ``` Reviewed-on: https://git.vdb.to/cerc-io/stack-orchestrator/pulls/739 Co-authored-by: Thomas E Lackey Co-committed-by: Thomas E Lackey --- stack_orchestrator/deploy/k8s/cluster_info.py | 28 +++++++++++++++++-- stack_orchestrator/deploy/spec.py | 12 ++++++++ .../webapp/undeploy_webapp_from_registry.py | 1 + 3 files changed, 39 insertions(+), 2 deletions(-) diff --git a/stack_orchestrator/deploy/k8s/cluster_info.py b/stack_orchestrator/deploy/k8s/cluster_info.py index 17f75651..d4dfb718 100644 --- a/stack_orchestrator/deploy/k8s/cluster_info.py +++ b/stack_orchestrator/deploy/k8s/cluster_info.py @@ -266,7 +266,7 @@ class ClusterInfo: merged_envs = merge_envs( envs_from_compose_file( service_info["environment"]), self.environment_variables.map - ) if "environment" in service_info else self.environment_variables.map + ) if "environment" in service_info else self.environment_variables.map envs = envs_from_environment_variables_map(merged_envs) if opts.o.debug: print(f"Merged envs: {envs}") @@ -281,13 +281,37 @@ class ClusterInfo: env=envs, ports=[client.V1ContainerPort(container_port=port)], volume_mounts=volume_mounts, + security_context=client.V1SecurityContext( + privileged=self.spec.get_privileged(), + capabilities=client.V1Capabilities( + add=self.spec.get_capabilities() + ) if self.spec.get_capabilities() else None + ), resources=to_k8s_resource_requirements(resources), ) containers.append(container) volumes = volumes_for_pod_files(self.parsed_pod_yaml_map, self.spec, self.app_name) image_pull_secrets = [client.V1LocalObjectReference(name="laconic-registry")] + + annotations = None + labels = {"app": self.app_name} + + if self.spec.get_annotations(): + annotations = {} + for key, value in self.spec.get_annotations().items(): + for service_name in services: + annotations[key.replace("{name}", service_name)] = value + + if self.spec.get_labels(): + for key, value in self.spec.get_labels().items(): + for service_name in services: + labels[key.replace("{name}", service_name)] = value + template = client.V1PodTemplateSpec( - metadata=client.V1ObjectMeta(labels={"app": self.app_name}), + metadata=client.V1ObjectMeta( + annotations=annotations, + labels=labels + ), spec=client.V1PodSpec(containers=containers, image_pull_secrets=image_pull_secrets, volumes=volumes), ) spec = client.V1DeploymentSpec( diff --git a/stack_orchestrator/deploy/spec.py b/stack_orchestrator/deploy/spec.py index fa0489e7..7e5ad16b 100644 --- a/stack_orchestrator/deploy/spec.py +++ b/stack_orchestrator/deploy/spec.py @@ -106,3 +106,15 @@ class Spec: if self.obj and constants.network_key in self.obj and constants.http_proxy_key in self.obj[constants.network_key] else None) + + def get_annotations(self): + return self.obj.get("annotations", {}) + + def get_labels(self): + return self.obj.get("labels", {}) + + def get_privileged(self): + return "true" == str(self.obj.get("security", {}).get("privileged", "false")).lower() + + def get_capabilities(self): + return self.obj.get("security", {}).get("capabilities", []) diff --git a/stack_orchestrator/deploy/webapp/undeploy_webapp_from_registry.py b/stack_orchestrator/deploy/webapp/undeploy_webapp_from_registry.py index 4aa2307d..8585283e 100644 --- a/stack_orchestrator/deploy/webapp/undeploy_webapp_from_registry.py +++ b/stack_orchestrator/deploy/webapp/undeploy_webapp_from_registry.py @@ -147,6 +147,7 @@ def command(ctx, laconic_config, deployment_parent_dir, previous_requests = load_known_requests(state_file) requests.sort(key=lambda r: r.createTime) + requests.reverse() # Find deployments. deployments = {} From c9444591f5eb7e22049e30a3c7fad21c5550a9e9 Mon Sep 17 00:00:00 2001 From: Thomas E Lackey Date: Fri, 9 Feb 2024 01:20:41 +0000 Subject: [PATCH 7/7] Fix default webapp port number. (#740) Reviewed-on: https://git.vdb.to/cerc-io/stack-orchestrator/pulls/740 Co-authored-by: Thomas E Lackey Co-committed-by: Thomas E Lackey --- .../data/compose/docker-compose-webapp-template.yml | 2 +- stack_orchestrator/deploy/webapp/deploy_webapp.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/stack_orchestrator/data/compose/docker-compose-webapp-template.yml b/stack_orchestrator/data/compose/docker-compose-webapp-template.yml index b8697afa..255ebf40 100644 --- a/stack_orchestrator/data/compose/docker-compose-webapp-template.yml +++ b/stack_orchestrator/data/compose/docker-compose-webapp-template.yml @@ -5,4 +5,4 @@ services: environment: CERC_SCRIPT_DEBUG: ${CERC_SCRIPT_DEBUG} ports: - - "3000" + - "80" diff --git a/stack_orchestrator/deploy/webapp/deploy_webapp.py b/stack_orchestrator/deploy/webapp/deploy_webapp.py index aca2df35..4c91dec3 100644 --- a/stack_orchestrator/deploy/webapp/deploy_webapp.py +++ b/stack_orchestrator/deploy/webapp/deploy_webapp.py @@ -44,7 +44,7 @@ def _fixup_url_spec(spec_file_name: str, url: str): - host-name: {parsed_url.hostname} routes: - path: '{parsed_url.path if parsed_url.path else "/"}' - proxy-to: webapp:3000 + proxy-to: webapp:80 ''' spec_file_path = Path(spec_file_name) with open(spec_file_path) as rfile: