Skip to content

Commit 7c063ca

Browse files
authored
fix(deployment): use hostname for topologyKey instead of region, update resources settings and staging configs (#7005)
1 parent e3ee466 commit 7c063ca

17 files changed

+71
-44
lines changed

deployment/services/app.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export function deployApp({
4646
'app',
4747
{
4848
image,
49-
replicas: environment.isProduction ? 3 : 1,
49+
replicas: environment.podsConfig.general.replicas,
5050
imagePullSecret: docker.secret,
5151
readinessProbe: '/api/health',
5252
livenessProbe: '/api/health',

deployment/services/commerce.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export function deployCommerce({
4949
{
5050
image,
5151
imagePullSecret: docker.secret,
52-
replicas: environment.isProduction ? 3 : 1,
52+
replicas: environment.podsConfig.general.replicas,
5353
readinessProbe: '/_readiness',
5454
livenessProbe: '/_health',
5555
startupProbe: '/_health',

deployment/services/emails.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export function deployEmails({
5959
startupProbe: '/_health',
6060
exposesMetrics: true,
6161
image,
62-
replicas: environment.isProduction ? 3 : 1,
62+
replicas: environment.podsConfig.general.replicas,
6363
},
6464
[redis.deployment, redis.service],
6565
)

deployment/services/environment.ts

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ export function prepareEnvironment(input: {
2323

2424
const appDns = `app.${input.rootDns}`;
2525
const apiDns = `api.${input.rootDns}`;
26+
const isProduction = env === 'production';
27+
const isStaging = env === 'staging';
28+
const isDev = env === 'dev';
2629

2730
return {
2831
envVars: {
@@ -33,14 +36,50 @@ export function prepareEnvironment(input: {
3336
RELEASE: input.release,
3437
},
3538
envName: env,
36-
isProduction: env === 'production',
37-
isStaging: env === 'staging',
38-
isDev: env === 'dev',
39+
isProduction,
40+
isStaging,
41+
isDev,
3942
encryptionSecret,
4043
release: input.release,
4144
appDns,
4245
apiDns,
4346
rootDns: input.rootDns,
47+
podsConfig: {
48+
general: {
49+
replicas: isProduction ? 3 : isStaging ? 2 : 1,
50+
},
51+
supertokens: {
52+
replicas: isProduction ? 3 : 1,
53+
},
54+
envoy: {
55+
replicas: isProduction ? 3 : 1,
56+
cpuLimit: isProduction ? '800m' : '150m',
57+
memoryLimit: isProduction ? '1Gi' : '200Mi',
58+
},
59+
schemaService: {
60+
memoryLimit: isProduction ? '2Gi' : '1Gi',
61+
},
62+
usageService: {
63+
replicas: isProduction ? 3 : isStaging ? 2 : 1,
64+
cpuLimit: isProduction ? '900m' : '300m',
65+
maxReplicas: isProduction ? 6 : isStaging ? 3 : 1,
66+
cpuAverageToScale: 60,
67+
},
68+
usageIngestorService: {
69+
replicas: isProduction ? 6 : isStaging ? 2 : 1,
70+
cpuLimit: isProduction ? '900m' : '300m',
71+
maxReplicas: isProduction ? /* numberOfPartitions */ 16 : 2,
72+
cpuAverageToScale: 60,
73+
},
74+
redis: {
75+
memoryLimit: isProduction ? '4Gi' : '100Mi',
76+
cpuLimit: isProduction ? '1000m' : '50m',
77+
},
78+
internalObservability: {
79+
cpuLimit: isProduction ? '512m' : '150m',
80+
memoryLimit: isProduction ? '1000Mi' : '300Mi',
81+
},
82+
},
4483
};
4584
}
4685

deployment/services/graphql.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ export function deployGraphQL({
107107
{
108108
imagePullSecret: docker.secret,
109109
image,
110-
replicas: environment.isProduction ? 3 : 1,
110+
replicas: environment.podsConfig.general.replicas,
111111
pdb: true,
112112
readinessProbe: '/_readiness',
113113
livenessProbe: '/_health',

deployment/services/policy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export function deploySchemaPolicy({
3232
livenessProbe: '/_health',
3333
startupProbe: '/_health',
3434
exposesMetrics: true,
35-
replicas: environment.isProduction ? 3 : 1,
35+
replicas: environment.podsConfig.general.replicas,
3636
pdb: true,
3737
})
3838
.withConditionalSecret(sentry.enabled, 'SENTRY_DSN', sentry.secret, 'dsn')

deployment/services/proxy.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ export function deployProxy({
3232
})
3333
.deployProxy({
3434
envoy: {
35-
replicas: environment.isProduction ? 3 : 1,
36-
cpu: environment.isProduction ? '800m' : '150m',
37-
memory: environment.isProduction ? '800Mi' : '192Mi',
35+
replicas: environment.podsConfig.envoy.replicas,
36+
cpu: environment.podsConfig.envoy.cpuLimit,
37+
memory: environment.podsConfig.envoy.memoryLimit,
3838
},
3939
tracing: observability.enabled
4040
? { collectorService: observability.observability!.otlpCollectorService }

deployment/services/public-graphql-api-gateway.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export function deployPublicGraphQLAPIGateway(args: {
6060
{
6161
imagePullSecret: args.docker.secret,
6262
image: dockerImage,
63-
replicas: args.environment.isProduction ? 3 : 1,
63+
replicas: args.environment.podsConfig.general.replicas,
6464
availabilityOnEveryNode: true,
6565
env: {
6666
GRAPHQL_SERVICE_ENDPOINT: serviceLocalEndpoint(args.graphql.service).apply(

deployment/services/redis.ts

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,10 @@ export function deployRedis(input: { environment: Environment }) {
1919
const redisApi = new RedisStore({
2020
password: redisPassword,
2121
}).deploy({
22-
limits: input.environment.isProduction
23-
? {
24-
memory: '6Gi',
25-
cpu: '1000m',
26-
}
27-
: {
28-
memory: '100Mi',
29-
cpu: '50m',
30-
},
22+
limits: {
23+
memory: input.environment.podsConfig.redis.memoryLimit,
24+
cpu: input.environment.podsConfig.redis.cpuLimit,
25+
},
3126
});
3227

3328
const host = serviceLocalHost(redisApi.service);

deployment/services/schema.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ export function deploySchema({
5151
livenessProbe: '/_health',
5252
startupProbe: '/_health',
5353
exposesMetrics: true,
54-
replicas: environment.isProduction ? 3 : 1,
55-
memoryLimit: '2Gi',
54+
replicas: environment.podsConfig.general.replicas,
55+
memoryLimit: environment.podsConfig.schemaService.memoryLimit,
5656
pdb: true,
5757
},
5858
[redis.deployment, redis.service],

0 commit comments

Comments
 (0)