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..193a90af --- /dev/null +++ b/stack_orchestrator/data/compose/docker-compose-mars.yml @@ -0,0 +1,20 @@ +version: "3.2" + +services: + mars: + image: cerc/mars:local + 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 + 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/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/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/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/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 +``` 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 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 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/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: 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 = {} 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