Skip to content

Commit af12043

Browse files
chore: cleanup pgboss-worker and ws-server deployments
1 parent e0a807b commit af12043

File tree

3 files changed

+132
-171
lines changed

3 files changed

+132
-171
lines changed

nix/cardano-services/deployments/ci.nix

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1-
{ lib, modules, config, ...}: {
2-
1+
{
2+
lib,
3+
modules,
4+
config,
5+
...
6+
}: {
37
imports = [
48
modules.githubAction
59
];

nix/cardano-services/deployments/pg-boss-worker-deployment.nix

Lines changed: 76 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@
55
config,
66
...
77
}: {
8-
templates.pgboss-deployment = lib.mkIf values.pg-boss-worker.enabled {
9-
apiVersion = "apps/v1";
10-
kind = "Deployment";
8+
resources.deployments.pgboss = lib.mkIf values.pg-boss-worker.enabled {
119
metadata = {
1210
name = "${config.name}-pg-boss-worker";
1311
labels = utils.appLabels "pg-boss-worker";
@@ -17,108 +15,91 @@
1715
template = {
1816
metadata.labels = utils.appLabels "pg-boss-worker";
1917
spec = {
20-
imagePullSecrets = [
21-
{
22-
name = "dockerconfigjson";
23-
}
24-
];
25-
containers = [
26-
{
27-
inherit (values.cardano-services) image;
28-
inherit (values.pg-boss-worker) resources;
29-
name = "pg-boss-worker";
30-
ports = [
31-
{
32-
containerPort = 3000;
33-
name = "http";
34-
}
35-
];
36-
startupProbe = {
37-
httpGet = {
38-
path = "${values.cardano-services.httpPrefix}/ready";
39-
port = 3000;
40-
};
41-
initialDelaySeconds = 80;
42-
periodSeconds = 5;
43-
};
44-
livenessProbe = {
45-
httpGet = {
46-
path = "${values.cardano-services.httpPrefix}/health";
47-
port = 3000;
48-
};
18+
imagePullSecrets.dockerconfigjson = {};
19+
containers.pg-boss-worker = {
20+
inherit (values.cardano-services) image;
21+
inherit (values.pg-boss-worker) resources;
22+
ports.http.containerPort = 3000;
23+
startupProbe = {
24+
httpGet = {
25+
path = "${values.cardano-services.httpPrefix}/ready";
26+
port = 3000;
4927
};
50-
securityContext = {
51-
runAsUser = 0;
52-
runAsGroup = 0;
28+
initialDelaySeconds = 80;
29+
periodSeconds = 5;
30+
};
31+
livenessProbe = {
32+
httpGet = {
33+
path = "${values.cardano-services.httpPrefix}/health";
34+
port = 3000;
5335
};
54-
args = ["start-pg-boss-worker"];
55-
env = utils.mkPodEnv ({
56-
NETWORK = config.network;
57-
LOGGER_MIN_SEVERITY = values.cardano-services.loggingLevel;
58-
QUEUES = values.pg-boss-worker.queues;
59-
NODE_ENV = values.cardano-services.nodeEnv;
36+
};
37+
securityContext = {
38+
runAsUser = 0;
39+
runAsGroup = 0;
40+
};
41+
args = ["start-pg-boss-worker"];
42+
env = utils.mkPodEnv ({
43+
NETWORK = config.network;
44+
LOGGER_MIN_SEVERITY = values.cardano-services.loggingLevel;
45+
QUEUES = values.pg-boss-worker.queues;
46+
NODE_ENV = values.cardano-services.nodeEnv;
6047

61-
METADATA_FETCH_MODE = values.pg-boss-worker.metadata-fetch-mode;
48+
METADATA_FETCH_MODE = values.pg-boss-worker.metadata-fetch-mode;
6249

63-
STAKE_POOL_PROVIDER_URL = "http://${config.name}-backend.${config.namespace}.svc.cluster.local";
64-
NETWORK_INFO_PROVIDER_URL = "http://${config.name}-backend.${config.namespace}.svc.cluster.local";
50+
STAKE_POOL_PROVIDER_URL = "http://${config.name}-backend.${config.namespace}.svc.cluster.local";
51+
NETWORK_INFO_PROVIDER_URL = "http://${config.name}-backend.${config.namespace}.svc.cluster.local";
6552

66-
POSTGRES_POOL_MAX_STAKE_POOL = "5";
67-
POSTGRES_HOST_STAKE_POOL = values.postgresName;
68-
POSTGRES_PORT_STAKE_POOL = "5432";
69-
POSTGRES_DB_STAKE_POOL = values.stakepool.databaseName;
70-
POSTGRES_PASSWORD_STAKE_POOL = {
71-
valueFrom.secretKeyRef = {
72-
name = "${values.stakepool.databaseName}-owner-user.${values.postgresName}.credentials.postgresql.acid.zalan.do";
73-
key = "password";
74-
};
53+
POSTGRES_POOL_MAX_STAKE_POOL = "5";
54+
POSTGRES_HOST_STAKE_POOL = values.postgresName;
55+
POSTGRES_PORT_STAKE_POOL = "5432";
56+
POSTGRES_DB_STAKE_POOL = values.stakepool.databaseName;
57+
POSTGRES_PASSWORD_STAKE_POOL = {
58+
valueFrom.secretKeyRef = {
59+
name = "${values.stakepool.databaseName}-owner-user.${values.postgresName}.credentials.postgresql.acid.zalan.do";
60+
key = "password";
7561
};
76-
POSTGRES_USER_STAKE_POOL = {
77-
valueFrom.secretKeyRef = {
78-
name = "${values.stakepool.databaseName}-owner-user.${values.postgresName}.credentials.postgresql.acid.zalan.do";
79-
key = "username";
80-
};
62+
};
63+
POSTGRES_USER_STAKE_POOL = {
64+
valueFrom.secretKeyRef = {
65+
name = "${values.stakepool.databaseName}-owner-user.${values.postgresName}.credentials.postgresql.acid.zalan.do";
66+
key = "username";
8167
};
82-
POSTGRES_SSL_STAKE_POOL = "true";
83-
POSTGRES_SSL_CA_FILE_STAKE_POOL = "/tls/ca.crt";
68+
};
69+
POSTGRES_SSL_STAKE_POOL = "true";
70+
POSTGRES_SSL_CA_FILE_STAKE_POOL = "/tls/ca.crt";
8471

85-
POSTGRES_POOL_MAX_DB_SYNC = "5";
86-
POSTGRES_HOST_DB_SYNC = values.postgresName;
87-
POSTGRES_PORT_DB_SYNC = "5432";
88-
POSTGRES_DB_DB_SYNC = "cardano";
89-
POSTGRES_PASSWORD_DB_SYNC = {
90-
valueFrom.secretKeyRef = {
91-
name = "cardano-owner-user.${values.postgresName}.credentials.postgresql.acid.zalan.do";
92-
key = "password";
93-
};
72+
POSTGRES_POOL_MAX_DB_SYNC = "5";
73+
POSTGRES_HOST_DB_SYNC = values.postgresName;
74+
POSTGRES_PORT_DB_SYNC = "5432";
75+
POSTGRES_DB_DB_SYNC = "cardano";
76+
POSTGRES_PASSWORD_DB_SYNC = {
77+
valueFrom.secretKeyRef = {
78+
name = "cardano-owner-user.${values.postgresName}.credentials.postgresql.acid.zalan.do";
79+
key = "password";
9480
};
95-
POSTGRES_USER_DB_SYNC = {
96-
valueFrom.secretKeyRef = {
97-
name = "cardano-owner-user.${values.postgresName}.credentials.postgresql.acid.zalan.do";
98-
key = "username";
99-
};
81+
};
82+
POSTGRES_USER_DB_SYNC = {
83+
valueFrom.secretKeyRef = {
84+
name = "cardano-owner-user.${values.postgresName}.credentials.postgresql.acid.zalan.do";
85+
key = "username";
10086
};
101-
POSTGRES_SSL_DB_SYNC = "true";
102-
POSTGRES_SSL_CA_FILE_DB_SYNC = "/tls/ca.crt";
103-
}
104-
// lib.optionalAttrs (values.pg-boss-worker ? env) values.pg-boss-worker.env
105-
// lib.optionalAttrs (values.pg-boss-worker.metadata-fetch-mode == "smash") {
106-
SMASH_URL = values.pg-boss-worker.smash-url;
107-
});
108-
volumeMounts = [
109-
{
110-
mountPath = "/tls";
111-
name = "tls";
112-
}
113-
];
114-
}
115-
];
116-
volumes = [
117-
{
118-
name = "tls";
119-
secret.secretName = "postgresql-server-cert";
120-
}
121-
];
87+
};
88+
POSTGRES_SSL_DB_SYNC = "true";
89+
POSTGRES_SSL_CA_FILE_DB_SYNC = "/tls/ca.crt";
90+
}
91+
// lib.optionalAttrs (values.pg-boss-worker ? env) values.pg-boss-worker.env
92+
// lib.optionalAttrs (values.pg-boss-worker.metadata-fetch-mode == "smash") {
93+
SMASH_URL = values.pg-boss-worker.smash-url;
94+
});
95+
volumeMounts = [
96+
{
97+
mountPath = "/tls";
98+
name = "tls";
99+
}
100+
];
101+
};
102+
volumes.tls.secret.secretName = "postgresql-server-cert";
122103
};
123104
};
124105
};

nix/cardano-services/deployments/ws-server.deployment.nix

Lines changed: 50 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -5,29 +5,22 @@
55
config,
66
...
77
}: {
8-
templates.ws-server-service = lib.mkIf values.ws-server.enabled {
9-
apiVersion = "v1";
10-
kind = "Service";
8+
resources.services.ws-server = lib.mkIf values.ws-server.enabled {
119
metadata = {
1210
name = "${config.name}-ws-server";
1311
labels = utils.appLabels "ws-server";
1412
};
1513
spec = {
16-
ports = [
17-
{
18-
name = "http";
19-
protocol = "TCP";
20-
port = 3000;
21-
targetPort = 3000;
22-
}
23-
];
14+
ports.http = {
15+
protocol = "TCP";
16+
port = 3000;
17+
targetPort = 3000;
18+
};
2419
selector = utils.appLabels "ws-server";
2520
};
2621
};
2722

28-
templates.ws-server-deployment = lib.mkIf values.ws-server.enabled {
29-
apiVersion = "apps/v1";
30-
kind = "Deployment";
23+
resources.deployments.ws-server = lib.mkIf values.ws-server.enabled {
3124
metadata = {
3225
name = "${config.name}-ws-server";
3326
labels = utils.appLabels "ws-server";
@@ -37,71 +30,54 @@
3730
template = {
3831
metadata.labels = utils.appLabels "ws-server";
3932
spec = {
40-
imagePullSecrets = [
41-
{
42-
name = "dockerconfigjson";
43-
}
44-
];
45-
containers = [
46-
{
47-
inherit (values.cardano-services) image;
48-
inherit (values.ws-server) resources;
49-
name = "ws-server";
50-
ports = [
51-
{
52-
containerPort = 3000;
53-
name = "http";
54-
}
55-
];
56-
livenessProbe = {
57-
httpGet = {
58-
path = "/health";
59-
port = 3000;
60-
};
33+
imagePullSecrets.dockerconfigjson = {};
34+
containers.ws-server = {
35+
inherit (values.cardano-services) image;
36+
inherit (values.ws-server) resources;
37+
ports.http.containerPort = 3000;
38+
livenessProbe = {
39+
httpGet = {
40+
path = "/health";
41+
port = 3000;
6142
};
62-
securityContext = {
63-
runAsUser = 0;
64-
runAsGroup = 0;
65-
};
66-
args = ["start-ws-server"];
67-
env = utils.mkPodEnv {
68-
NETWORK = config.network;
69-
DB_CACHE_TTL = "7200";
70-
OGMIOS_URL = "ws://${config.namespace}-cardano-core.${config.namespace}.svc.cluster.local:1337";
43+
};
44+
securityContext = {
45+
runAsUser = 0;
46+
runAsGroup = 0;
47+
};
48+
args = ["start-ws-server"];
49+
env = utils.mkPodEnv {
50+
NETWORK = config.network;
51+
DB_CACHE_TTL = "7200";
52+
OGMIOS_URL = "ws://${config.namespace}-cardano-core.${config.namespace}.svc.cluster.local:1337";
7153

72-
POSTGRES_POOL_MAX_DB_SYNC = "2";
73-
POSTGRES_HOST_DB_SYNC = values.postgresName;
74-
POSTGRES_PORT_DB_SYNC = "5432";
75-
POSTGRES_DB_DB_SYNC = "cardano";
76-
POSTGRES_PASSWORD_DB_SYNC = {
77-
valueFrom.secretKeyRef = {
78-
name = "cardano-owner-user.${values.postgresName}.credentials.postgresql.acid.zalan.do";
79-
key = "password";
80-
};
54+
POSTGRES_POOL_MAX_DB_SYNC = "2";
55+
POSTGRES_HOST_DB_SYNC = values.postgresName;
56+
POSTGRES_PORT_DB_SYNC = "5432";
57+
POSTGRES_DB_DB_SYNC = "cardano";
58+
POSTGRES_PASSWORD_DB_SYNC = {
59+
valueFrom.secretKeyRef = {
60+
name = "cardano-owner-user.${values.postgresName}.credentials.postgresql.acid.zalan.do";
61+
key = "password";
8162
};
82-
POSTGRES_USER_DB_SYNC = {
83-
valueFrom.secretKeyRef = {
84-
name = "cardano-owner-user.${values.postgresName}.credentials.postgresql.acid.zalan.do";
85-
key = "username";
86-
};
63+
};
64+
POSTGRES_USER_DB_SYNC = {
65+
valueFrom.secretKeyRef = {
66+
name = "cardano-owner-user.${values.postgresName}.credentials.postgresql.acid.zalan.do";
67+
key = "username";
8768
};
88-
POSTGRES_SSL_DB_SYNC = "true";
89-
POSTGRES_SSL_CA_FILE_DB_SYNC = "/tls/ca.crt";
9069
};
91-
volumeMounts = [
92-
{
93-
mountPath = "/tls";
94-
name = "tls";
95-
}
96-
];
97-
}
98-
];
99-
volumes = [
100-
{
101-
name = "tls";
102-
secret.secretName = "postgresql-server-cert";
103-
}
104-
];
70+
POSTGRES_SSL_DB_SYNC = "true";
71+
POSTGRES_SSL_CA_FILE_DB_SYNC = "/tls/ca.crt";
72+
};
73+
volumeMounts = [
74+
{
75+
mountPath = "/tls";
76+
name = "tls";
77+
}
78+
];
79+
};
80+
volumes.tls.secret.secretName = "postgresql-server-cert";
10581
};
10682
};
10783
};

0 commit comments

Comments
 (0)