Skip to content

Commit

Permalink
deploy: extend metadata deployment to preview & preprod & dev envs
Browse files Browse the repository at this point in the history
  • Loading branch information
blaggacao committed May 26, 2023
1 parent 2567eb5 commit b3a4ce3
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 27 deletions.
12 changes: 12 additions & 0 deletions nix/cardano-stack/deployments.nix
Expand Up @@ -31,6 +31,8 @@ in
namespace = "live-preview";
region = "eu-central-1";
postgresql = {};
tokenRegistry.sync.image = cell.oci-images.metadata-sync.imageRefUnsafe;
tokenRegistry.server.image = cell.oci-images.metadata-server.imageRefUnsafe;
};

"dev-preview@eu-central-1" = rec {
Expand All @@ -39,6 +41,8 @@ in
namespace = "dev-preview";
region = "eu-central-1";
postgresql = {};
tokenRegistry.sync.image = cell.oci-images.metadata-sync.imageRefUnsafe;
tokenRegistry.server.image = cell.oci-images.metadata-server.imageRefUnsafe;
};

# Preprod
Expand All @@ -48,6 +52,8 @@ in
namespace = "live-preprod";
region = "eu-central-1";
postgresql = {};
tokenRegistry.sync.image = cell.oci-images.metadata-sync.imageRefUnsafe;
tokenRegistry.server.image = cell.oci-images.metadata-server.imageRefUnsafe;
};

"live-preprod@us-east-1" = rec {
Expand All @@ -56,6 +62,8 @@ in
namespace = "live-preprod";
region = "us-east-1";
postgresql = {};
tokenRegistry.sync.image = cell.oci-images.metadata-sync.imageRefUnsafe;
tokenRegistry.server.image = cell.oci-images.metadata-server.imageRefUnsafe;
};

"dev-preprod@eu-central-1" = rec {
Expand All @@ -64,6 +72,8 @@ in
namespace = "dev-preprod";
region = "eu-central-1";
postgresql = {};
tokenRegistry.sync.image = cell.oci-images.metadata-sync.imageRefUnsafe;
tokenRegistry.server.image = cell.oci-images.metadata-server.imageRefUnsafe;
};

# Mainnet
Expand Down Expand Up @@ -103,5 +113,7 @@ in
namespace = "dev-perf-mainnet";
region = "us-west-2";
postgresql.parameters.max_connections = "300";
tokenRegistry.sync.image = cell.oci-images.metadata-sync.imageRefUnsafe;
tokenRegistry.server.image = cell.oci-images.metadata-server.imageRefUnsafe;
};
}
5 changes: 1 addition & 4 deletions nix/cardano-stack/deployments/chart/default.nix
Expand Up @@ -17,11 +17,10 @@
name = "${namespace}-cardano-stack";
postgresName = "${namespace}-dbsync-db";
releaseName = "${namespace}-lace-stack";
withMetadataDeployment = false;
withMetadataDeployment = true;
snapshotsEnabled = false;
tolerationKey = "cardano";
volumesId = namespace;
withMetadataDeployment = false;

metadata = {
sync = {
Expand All @@ -40,7 +39,6 @@
};
};


postgresql = {
numberOfInstances = 2;
withTolerations = false;
Expand Down Expand Up @@ -93,7 +91,6 @@

mainnetDefaults = lib.recursiveUpdate defaultValues {
snapshotsEnabled = true;
withMetadataDeployment = true;

tolerationKey = "mainnet";

Expand Down
58 changes: 37 additions & 21 deletions nix/cardano-stack/deployments/chart/metadata-deployment.nix
Expand Up @@ -3,26 +3,31 @@
values,
}: let
port = 8765;
env =
{
DB_HOST = values.postgresName;
DB_PORT = "5432";
DB_NAME = "metadata";
DB_PASS = {
valueFrom.secretKeyRef = {
# owner role user, because dbsync manages its own schemata
name = "metadata-public-owner-user.${values.postgresName}.credentials.postgresql.acid.zalan.do";
key = "password";
};
};
DB_USER = {
valueFrom.secretKeyRef = {
# owner role user, because dbsync manages its own schemata
name = "metadata-public-owner-user.${values.postgresName}.credentials.postgresql.acid.zalan.do";
key = "username";
};
};
};
registry = {
mainnet.git = "https://github.com/cardano-foundation/cardano-token-registry.git";
mainnet.folder = "mappings";
testnets.git = "https://github.com/input-output-hk/metadata-registry-testnet.git";
testnets.folder = "registry";
};
env = {
DB_HOST = values.postgresName;
DB_PORT = "5432";
DB_NAME = "metadata";
DB_PASS = {
valueFrom.secretKeyRef = {
# owner role user, because dbsync manages its own schemata
name = "metadata-public-owner-user.${values.postgresName}.credentials.postgresql.acid.zalan.do";
key = "password";
};
};
DB_USER = {
valueFrom.secretKeyRef = {
# owner role user, because dbsync manages its own schemata
name = "metadata-public-owner-user.${values.postgresName}.credentials.postgresql.acid.zalan.do";
key = "username";
};
};
};
in {
apiVersion = "apps/v1";
kind = "Deployment";
Expand Down Expand Up @@ -55,7 +60,18 @@ in {
{
inherit (values.metadata.sync) image resources;
name = "metadata-sync";
env = lib.mkPodEnv env;
env = lib.mkPodEnv (env
// (
if values.network == "mainnet"
then {
GIT_URL = registry.mainnet.git;
GIT_METADATA_FOLDER = registry.mainnet.folder;
}
else {
GIT_URL = registry.testnets.git;
GIT_METADATA_FOLDER = registry.testnets.folder;
}
));
}
];
};
Expand Down
14 changes: 12 additions & 2 deletions nix/cardano-stack/entrypoints.nix
Expand Up @@ -50,14 +50,24 @@ in {
runtimeInputs = [nixpkgs.gitMinimal];
runtimeScript = ''
${dbConnectionEnv}
if [[ -z "''${GIT_URL:-}" ]]; then
echo GIT_URL must be explicitly set
exit 1
fi
echo "Metadata will be sync from ''${GIT_URL}..."
if [[ -z "''${GIT_METADATA_FOLDER:-}" ]]; then
echo GIT_METADATA_FOLDER must be explicitly set
exit 1
fi
echo "Metadata will be sync from the folder ''${GIT_METADATA_FOLDER}..."
exec ${cell.packages.metadata-sync}/bin/metadata-sync \
--db "$DB_NAME" \
--db-user "$DB_USER" \
--db-pass "$DB_PASS" \
--db-host "$DB_HOST" \
--db-port "$DB_PORT" \
--git-url "https://github.com/cardano-foundation/cardano-token-registry.git" \
--git-metadata-folder "mappings"
--git-url "$GIT_URL" \
--git-metadata-folder "$GIT_METADATA_FOLDER"
'';
};
}
2 changes: 2 additions & 0 deletions nix/cardano-stack/testbed.nix
Expand Up @@ -28,6 +28,8 @@ in {
DB_PASS = pass;
DB_HOST = "postgres";
DB_PORT = "5432";
GIT_URL = "https://github.com/cardano-foundation/cardano-token-registry.git";
GIT_METADATA_FOLDER = "mappings";
};
};
};
Expand Down

0 comments on commit b3a4ce3

Please sign in to comment.