Skip to content

Commit

Permalink
chore: add ws-server deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
iccicci committed Jul 15, 2024
1 parent 6616043 commit 66ad858
Show file tree
Hide file tree
Showing 3 changed files with 131 additions and 11 deletions.
20 changes: 10 additions & 10 deletions nix/cardano-services/deployments/backend-ingress.nix
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,6 @@
};
}
])
++ [
{
pathType = "Prefix";
path = "/";
backend.service = {
name = "ssl-redirect";
port.name = "use-annotation";
};
}
]
++ (map (
it: {
pathType = "Prefix";
Expand Down Expand Up @@ -104,6 +94,16 @@
};
}
]
++ lib.optionals values.ws-server.enabled [
{
pathType = "Exact";
path = "/ws";
backend.service = {
name = "${chart.name}-ws-server";
port.name = "http";
};
}
]
++ values.cardano-services.additionalRoutes;
})
values.backend.hostnames;
Expand Down
12 changes: 11 additions & 1 deletion nix/cardano-services/deployments/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,12 @@ in
resources.requests = mkPodResources "150Mi" "200m";
};

ws-server = {
enabled = false;
resources.limits = mkPodResources "300Mi" "300m";
resources.requests = mkPodResources "150Mi" "200m";
};

backend = {
allowedOrigins = lib.concatStringsSep "," allowedOrigins;
passHandleDBArgs = true;
Expand Down Expand Up @@ -169,6 +175,7 @@ in
};
imports = [
./options.nix
./ws-server.deployment.nix
./provider.resource.nix
./projector.resource.nix
./backend.provider.nix
Expand Down Expand Up @@ -210,6 +217,7 @@ in
};

values = {
ws-server.enabled = true;
stakepool.databaseName = "stakepoolv2";
cardano-services = {
ingresOrder = 99;
Expand Down Expand Up @@ -403,6 +411,7 @@ in
};

values = {
ws-server.enabled = true;
stakepool.databaseName = "stakepoolv2";
backend.allowedOrigins = lib.concatStringsSep "," allowedOriginsDev;

Expand Down Expand Up @@ -478,7 +487,7 @@ in
stake-pool.enabled = true;
# asset.enabled = true;
};



values = {
Expand Down Expand Up @@ -900,6 +909,7 @@ in
};

values = {
ws-server.enabled = true;
cardano-services = {
ingresOrder = 99;
};
Expand Down
110 changes: 110 additions & 0 deletions nix/cardano-services/deployments/ws-server.deployment.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
{
lib,
utils,
values,
chart,
config,
...
}: {
templates.ws-server-service = lib.mkIf values.ws-server.enabled {
apiVersion = "v1";
kind = "Service";
metadata = {
name = "${chart.name}-ws-server";
labels = utils.appLabels "ws-server";
};
spec = {
ports = [
{
name = "http";
protocol = "TCP";
port = 3000;
targetPort = 3000;
}
];
selector = utils.appLabels "ws-server";
};
};

templates.ws-server-deployment = lib.mkIf values.ws-server.enabled {
apiVersion = "apps/v1";
kind = "Deployment";
metadata = {
name = "${chart.name}-ws-server";
labels = utils.appLabels "ws-server";
};
spec = {
selector.matchLabels = utils.appLabels "ws-server";
template = {
metadata.labels = utils.appLabels "ws-server";
spec = {
imagePullSecrets = [
{
name = "dockerconfigjson";
}
];
containers = [
{
inherit (values.cardano-services) image;
inherit (values.ws-server) resources;
name = "ws-server";
ports = [
{
containerPort = 3000;
name = "http";
}
];
livenessProbe = {
httpGet = {
path = "/health";
port = 3000;
};
};
securityContext = {
runAsUser = 0;
runAsGroup = 0;
};
args = ["start-ws-server"];
env = utils.mkPodEnv ({
NETWORK = config.network;
DB_CACHE_TTL = "7200";
OGMIOS_URL = "ws://${config.namespace}-cardano-core.${config.namespace}.svc.cluster.local:1337";

POSTGRES_POOL_MAX_DB_SYNC = "2";
POSTGRES_HOST_DB_SYNC = values.postgresName;
POSTGRES_PORT_DB_SYNC = "5432";
POSTGRES_DB_DB_SYNC = "cardano";
POSTGRES_PASSWORD_DB_SYNC = {
valueFrom.secretKeyRef = {
name = "cardano-owner-user.${values.postgresName}.credentials.postgresql.acid.zalan.do";
key = "password";
};
};
POSTGRES_USER_DB_SYNC = {
valueFrom.secretKeyRef = {
name = "cardano-owner-user.${values.postgresName}.credentials.postgresql.acid.zalan.do";
key = "username";
};
};
POSTGRES_SSL_DB_SYNC = "true";
POSTGRES_SSL_CA_FILE_DB_SYNC = "/tls/ca.crt";
});
volumeMounts = [
{
mountPath = "/tls";
name = "tls";
}
];
}
];
volumes = [
{
name = "tls";
secret.secretName = "postgresql-server-cert";
}
];
};
};
};
};
}

0 comments on commit 66ad858

Please sign in to comment.