mirror of
https://github.com/graphql-hive/console
synced 2026-04-21 14:37:17 +00:00
fix(deployment): adjust cpu limit/requests config for pods (#7931)
This commit is contained in:
parent
574a5d823e
commit
fd0b8251c5
8 changed files with 70 additions and 34 deletions
|
|
@ -50,8 +50,8 @@ export function prepareEnvironment(input: {
|
|||
},
|
||||
envoy: {
|
||||
replicas: isProduction || isStaging ? 3 : 1,
|
||||
cpuLimit: isProduction ? '1500m' : '120m',
|
||||
memoryLimit: isProduction ? '2Gi' : '200Mi',
|
||||
cpuLimit: isProduction || isStaging ? '1500m' : '120m',
|
||||
memoryLimit: isProduction || isStaging ? '2Gi' : '200Mi',
|
||||
timeouts: {
|
||||
idleTimeout: 905,
|
||||
},
|
||||
|
|
@ -61,26 +61,30 @@ export function prepareEnvironment(input: {
|
|||
},
|
||||
usageService: {
|
||||
replicas: isProduction || isStaging ? 6 : 1,
|
||||
cpuLimit: isProduction ? '1000m' : '100m',
|
||||
cpuMin: isProduction || isStaging ? '200m' : '100m',
|
||||
cpuMax: isProduction || isStaging ? '1000m' : '100m',
|
||||
maxReplicas: isProduction || isStaging ? 6 : 1,
|
||||
cpuAverageToScale: 60,
|
||||
},
|
||||
usageIngestorService: {
|
||||
replicas: isProduction || isStaging ? 6 : 1,
|
||||
cpuLimit: isProduction ? '1000m' : '100m',
|
||||
cpuMax: isProduction || isStaging ? '1000m' : '100m',
|
||||
cpuMin: isProduction || isStaging ? '300m' : '100m',
|
||||
maxReplicas: isProduction || isStaging ? /* numberOfPartitions */ 16 : 2,
|
||||
cpuAverageToScale: 60,
|
||||
},
|
||||
redis: {
|
||||
memoryLimit: isProduction ? '4Gi' : '100Mi',
|
||||
cpuLimit: isProduction ? '1000m' : '50m',
|
||||
memoryLimit: isProduction || isStaging ? '4Gi' : '100Mi',
|
||||
cpuMax: isProduction || isStaging ? '1000m' : '100m',
|
||||
cpuMin: isProduction || isStaging ? '100m' : '50m',
|
||||
},
|
||||
internalObservability: {
|
||||
cpuLimit: isProduction ? '512m' : '150m',
|
||||
memoryLimit: isProduction ? '1000Mi' : '300Mi',
|
||||
},
|
||||
tracingCollector: {
|
||||
cpuLimit: isProduction || isStaging ? '1000m' : '100m',
|
||||
cpuMax: isProduction || isStaging ? '1000m' : '300m',
|
||||
cpuMin: '100m',
|
||||
memoryLimit: isProduction || isStaging ? '1000Mi' : '512Mi',
|
||||
maxReplicas: isProduction || isStaging ? 3 : 1,
|
||||
replicas: 1,
|
||||
|
|
|
|||
|
|
@ -40,13 +40,16 @@ export function deployOTELCollector(args: {
|
|||
pdb: true,
|
||||
availabilityOnEveryNode: true,
|
||||
port: 4318,
|
||||
memoryLimit: args.environment.podsConfig.tracingCollector.memoryLimit,
|
||||
memory: {
|
||||
limit: args.environment.podsConfig.tracingCollector.memoryLimit,
|
||||
},
|
||||
cpu: {
|
||||
limit: args.environment.podsConfig.tracingCollector.cpuMax,
|
||||
requests: args.environment.podsConfig.tracingCollector.cpuMin,
|
||||
},
|
||||
autoScaling: {
|
||||
maxReplicas: args.environment.podsConfig.tracingCollector.maxReplicas,
|
||||
cpu: {
|
||||
limit: args.environment.podsConfig.tracingCollector.cpuLimit,
|
||||
cpuAverageToScale: 80,
|
||||
},
|
||||
cpuAverageToScale: 80,
|
||||
},
|
||||
},
|
||||
[args.clickhouse.deployment, args.clickhouse.service, args.dbMigrations],
|
||||
|
|
|
|||
|
|
@ -21,7 +21,10 @@ export function deployRedis(input: { environment: Environment }) {
|
|||
}).deploy({
|
||||
limits: {
|
||||
memory: input.environment.podsConfig.redis.memoryLimit,
|
||||
cpu: input.environment.podsConfig.redis.cpuLimit,
|
||||
cpu: input.environment.podsConfig.redis.cpuMax,
|
||||
},
|
||||
requests: {
|
||||
cpu: input.environment.podsConfig.redis.cpuMin,
|
||||
},
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -53,7 +53,9 @@ export function deploySchema({
|
|||
startupProbe: '/_health',
|
||||
exposesMetrics: true,
|
||||
replicas: environment.podsConfig.general.replicas,
|
||||
memoryLimit: environment.podsConfig.schemaService.memoryLimit,
|
||||
memory: {
|
||||
limit: environment.podsConfig.schemaService.memoryLimit,
|
||||
},
|
||||
pdb: true,
|
||||
},
|
||||
[redis.deployment, redis.service],
|
||||
|
|
|
|||
|
|
@ -61,11 +61,12 @@ export function deployUsageIngestor({
|
|||
exposesMetrics: true,
|
||||
port: 4000,
|
||||
pdb: true,
|
||||
cpu: {
|
||||
limit: environment.podsConfig.usageIngestorService.cpuMax,
|
||||
requests: environment.podsConfig.usageIngestorService.cpuMin,
|
||||
},
|
||||
autoScaling: {
|
||||
cpu: {
|
||||
cpuAverageToScale: environment.podsConfig.usageIngestorService.cpuAverageToScale,
|
||||
limit: environment.podsConfig.usageIngestorService.cpuLimit,
|
||||
},
|
||||
cpuAverageToScale: environment.podsConfig.usageIngestorService.cpuAverageToScale,
|
||||
maxReplicas: environment.podsConfig.usageIngestorService.maxReplicas,
|
||||
},
|
||||
},
|
||||
|
|
|
|||
|
|
@ -81,11 +81,12 @@ export function deployUsage({
|
|||
exposesMetrics: true,
|
||||
port: 4000,
|
||||
pdb: true,
|
||||
cpu: {
|
||||
limit: environment.podsConfig.usageService.cpuMax,
|
||||
requests: environment.podsConfig.usageService.cpuMin,
|
||||
},
|
||||
autoScaling: {
|
||||
cpu: {
|
||||
cpuAverageToScale: environment.podsConfig.usageService.cpuAverageToScale,
|
||||
limit: environment.podsConfig.usageService.cpuLimit,
|
||||
},
|
||||
cpuAverageToScale: environment.podsConfig.usageService.cpuAverageToScale,
|
||||
maxReplicas: environment.podsConfig.usageService.maxReplicas,
|
||||
},
|
||||
},
|
||||
|
|
|
|||
|
|
@ -18,13 +18,16 @@ export class Redis {
|
|||
},
|
||||
) {}
|
||||
|
||||
deploy(input: { limits: { memory: string; cpu: string } }) {
|
||||
deploy(input: { limits: { memory: string; cpu: string }; requests: { cpu: string } }) {
|
||||
const redisService = getLocalComposeConfig().service('redis');
|
||||
const name = 'redis-store';
|
||||
const limits: k8s.types.input.core.v1.ResourceRequirements['limits'] = {
|
||||
memory: input.limits.memory,
|
||||
cpu: input.limits.cpu,
|
||||
};
|
||||
const requests: k8s.types.input.core.v1.ResourceRequirements['requests'] = {
|
||||
cpu: input.requests.cpu,
|
||||
};
|
||||
|
||||
const env: k8s.types.input.core.v1.EnvVar[] = normalizeEnv(this.options.env ?? {}).concat([
|
||||
{
|
||||
|
|
@ -100,6 +103,7 @@ export class Redis {
|
|||
ports: [{ containerPort: REDIS_PORT, protocol: 'TCP' }],
|
||||
resources: {
|
||||
limits,
|
||||
requests,
|
||||
},
|
||||
livenessProbe: {
|
||||
initialDelaySeconds: 3,
|
||||
|
|
@ -139,6 +143,10 @@ export class Redis {
|
|||
cpu: '200m',
|
||||
memory: '200Mi',
|
||||
},
|
||||
requests: {
|
||||
cpu: '100m',
|
||||
memory: '100Mi',
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
|
|
|
|||
|
|
@ -46,7 +46,14 @@ export class ServiceDeployment {
|
|||
livenessProbe?: string | ProbeConfig;
|
||||
readinessProbe?: string | ProbeConfig;
|
||||
startupProbe?: string | ProbeConfig;
|
||||
memoryLimit?: string;
|
||||
memory?: {
|
||||
limit?: string;
|
||||
requests?: string;
|
||||
};
|
||||
cpu?: {
|
||||
limit?: string;
|
||||
requests?: string;
|
||||
};
|
||||
volumes?: k8s.types.input.core.v1.Volume[];
|
||||
volumeMounts?: k8s.types.input.core.v1.VolumeMount[];
|
||||
/**
|
||||
|
|
@ -58,10 +65,7 @@ export class ServiceDeployment {
|
|||
autoScaling?: {
|
||||
minReplicas?: number;
|
||||
maxReplicas: number;
|
||||
cpu: {
|
||||
limit: string;
|
||||
cpuAverageToScale: number;
|
||||
};
|
||||
cpuAverageToScale: number;
|
||||
};
|
||||
availabilityOnEveryNode?: boolean;
|
||||
command?: pulumi.Input<pulumi.Input<string>[]>;
|
||||
|
|
@ -205,14 +209,23 @@ export class ServiceDeployment {
|
|||
});
|
||||
}
|
||||
|
||||
const resourcesLimits: Record<string, string> = {};
|
||||
const resourcesLimits: { cpu?: string; memory?: string } = {};
|
||||
const resourcesRequests: { cpu?: string; memory?: string } = {};
|
||||
|
||||
if (this.options?.autoScaling?.cpu.limit) {
|
||||
resourcesLimits.cpu = this.options.autoScaling.cpu.limit;
|
||||
if (this.options?.cpu?.limit) {
|
||||
resourcesLimits.cpu = this.options?.cpu?.limit;
|
||||
}
|
||||
|
||||
if (this.options.memoryLimit) {
|
||||
resourcesLimits.memory = this.options.memoryLimit;
|
||||
if (this.options?.cpu?.requests) {
|
||||
resourcesRequests.cpu = this.options?.cpu?.requests;
|
||||
}
|
||||
|
||||
if (this.options?.memory?.limit) {
|
||||
resourcesLimits.memory = this.options?.memory?.limit;
|
||||
}
|
||||
|
||||
if (this.options?.memory?.requests) {
|
||||
resourcesRequests.memory = this.options?.memory?.requests;
|
||||
}
|
||||
|
||||
const pb = new PodBuilder({
|
||||
|
|
@ -248,6 +261,7 @@ export class ServiceDeployment {
|
|||
image: this.options.image,
|
||||
resources: {
|
||||
limits: resourcesLimits,
|
||||
requests: resourcesRequests,
|
||||
},
|
||||
args: this.options.args,
|
||||
ports: {
|
||||
|
|
@ -342,7 +356,7 @@ export class ServiceDeployment {
|
|||
name: 'cpu',
|
||||
target: {
|
||||
type: 'Utilization',
|
||||
averageUtilization: this.options.autoScaling.cpu.cpuAverageToScale,
|
||||
averageUtilization: this.options.autoScaling.cpuAverageToScale,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in a new issue