chore(server): downscale non-prod env (#8493)

This commit is contained in:
darkskygit
2024-10-15 01:31:29 +00:00
parent abc18eb7f9
commit 49478638bc

View File

@@ -40,6 +40,37 @@ const isProduction = buildType === 'stable';
const isBeta = buildType === 'beta'; const isBeta = buildType === 'beta';
const isInternal = buildType === 'internal'; const isInternal = buildType === 'internal';
const replicaConfig = {
production: {
web: 3,
graphql: Number(process.env.PRODUCTION_GRAPHQL_REPLICA) || 3,
sync: Number(process.env.PRODUCTION_SYNC_REPLICA) || 3,
},
beta: {
web: 2,
graphql: Number(process.env.BETA_GRAPHQL_REPLICA) || 2,
sync: Number(process.env.BETA_SYNC_REPLICA) || 2,
},
canary: {
web: 2,
graphql: 2,
sync: 2,
},
};
const cpuConfig = {
beta: {
web: '500m',
graphql: '1',
sync: '1',
},
canary: {
web: '500m',
graphql: '1',
sync: '1',
},
};
const createHelmCommand = ({ isDryRun }) => { const createHelmCommand = ({ isDryRun }) => {
const flag = isDryRun ? '--dry-run' : '--atomic'; const flag = isDryRun ? '--dry-run' : '--atomic';
const imageTag = `${buildType}-${GIT_SHORT_HASH}`; const imageTag = `${buildType}-${GIT_SHORT_HASH}`;
@@ -67,17 +98,18 @@ const createHelmCommand = ({ isDryRun }) => {
`--set-json cloud-sql-proxy.nodeSelector=\"{ \\"iam.gke.io/gke-metadata-server-enabled\\": \\"true\\" }\"`, `--set-json cloud-sql-proxy.nodeSelector=\"{ \\"iam.gke.io/gke-metadata-server-enabled\\": \\"true\\" }\"`,
] ]
: []; : [];
const webReplicaCount = isProduction ? 3 : isBeta ? 2 : 2;
const graphqlReplicaCount = isProduction const cpu = cpuConfig[buildType];
? Number(process.env.PRODUCTION_GRAPHQL_REPLICA) || 3 const resources = cpu
: isBeta ? [
? Number(process.env.isBeta_GRAPHQL_REPLICA) || 2 `--set web.resources.requests.cpu="${cpu.web}"`,
: 2; `--set graphql.resources.requests.cpu="${cpu.graphql}"`,
const syncReplicaCount = isProduction `--set sync.resources.requests.cpu="${cpu.sync}"`,
? Number(process.env.PRODUCTION_SYNC_REPLICA) || 3 ]
: isBeta : [];
? Number(process.env.BETA_SYNC_REPLICA) || 2
: 2; const replica = replicaConfig[buildType] || replicaConfig.canary;
const namespace = isProduction const namespace = isProduction
? 'production' ? 'production'
: isBeta : isBeta
@@ -100,9 +132,9 @@ const createHelmCommand = ({ isDryRun }) => {
`--set-string global.objectStorage.r2.secretAccessKey="${R2_SECRET_ACCESS_KEY}"`, `--set-string global.objectStorage.r2.secretAccessKey="${R2_SECRET_ACCESS_KEY}"`,
`--set-string global.version="${APP_VERSION}"`, `--set-string global.version="${APP_VERSION}"`,
...redisAndPostgres, ...redisAndPostgres,
`--set web.replicaCount=${webReplicaCount}`, `--set web.replicaCount=${replica.web}`,
`--set-string web.image.tag="${imageTag}"`, `--set-string web.image.tag="${imageTag}"`,
`--set graphql.replicaCount=${graphqlReplicaCount}`, `--set graphql.replicaCount=${replica.graphql}`,
`--set-string graphql.image.tag="${imageTag}"`, `--set-string graphql.image.tag="${imageTag}"`,
`--set graphql.app.host=${host}`, `--set graphql.app.host=${host}`,
`--set graphql.app.captcha.enabled=true`, `--set graphql.app.captcha.enabled=true`,
@@ -124,11 +156,12 @@ const createHelmCommand = ({ isDryRun }) => {
`--set graphql.app.experimental.enableJwstCodec=${namespace === 'dev'}`, `--set graphql.app.experimental.enableJwstCodec=${namespace === 'dev'}`,
`--set graphql.app.features.earlyAccessPreview=false`, `--set graphql.app.features.earlyAccessPreview=false`,
`--set graphql.app.features.syncClientVersionCheck=true`, `--set graphql.app.features.syncClientVersionCheck=true`,
`--set sync.replicaCount=${syncReplicaCount}`, `--set sync.replicaCount=${replica.sync}`,
`--set-string sync.image.tag="${imageTag}"`, `--set-string sync.image.tag="${imageTag}"`,
`--set-string renderer.image.tag="${imageTag}"`, `--set-string renderer.image.tag="${imageTag}"`,
`--set renderer.app.host=${host}`, `--set renderer.app.host=${host}`,
...serviceAnnotations, ...serviceAnnotations,
...resources,
`--timeout 10m`, `--timeout 10m`,
flag, flag,
].join(' '); ].join(' ');