Add optional service pricing matrix and fix admin catalog save.
Users pick per-service CPU/memory/storage at deploy; admins manage unit rates and deploy defaults. PATCH sends only fields accepted by the pricing-catalog DTO. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -104,6 +104,36 @@ export class KubernetesService implements OnModuleInit {
|
||||
/**
|
||||
* Build Helm values object from an Application entity and image URI.
|
||||
*/
|
||||
private buildRedisHelmBlock(app: Application) {
|
||||
const res = app.optionalServiceResources?.redis;
|
||||
const storageGi = res?.storageGi ?? 1;
|
||||
return {
|
||||
enabled: app.enableRedis || false,
|
||||
storageSize: `${storageGi}Gi`,
|
||||
resources: {
|
||||
cpuRequest: res?.cpuRequest || '50m',
|
||||
cpuLimit: res?.cpuLimit || '200m',
|
||||
memoryRequest: res?.memoryRequest || '64Mi',
|
||||
memoryLimit: res?.memoryLimit || '256Mi',
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
private buildRabbitmqHelmBlock(app: Application) {
|
||||
const res = app.optionalServiceResources?.rabbitmq;
|
||||
const storageGi = res?.storageGi ?? 2;
|
||||
return {
|
||||
enabled: app.enableRabbitmq || false,
|
||||
storageSize: `${storageGi}Gi`,
|
||||
resources: {
|
||||
cpuRequest: res?.cpuRequest || '100m',
|
||||
cpuLimit: res?.cpuLimit || '500m',
|
||||
memoryRequest: res?.memoryRequest || '256Mi',
|
||||
memoryLimit: res?.memoryLimit || '512Mi',
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
private resolveEnvVars(app: Application): Record<string, string> {
|
||||
const platformDomain = this.configService.get('platform.domain') || 'apps.cloudhost.ir';
|
||||
return ensureAppUrlEnv(app, platformDomain);
|
||||
@@ -162,26 +192,8 @@ export class KubernetesService implements OnModuleInit {
|
||||
wordpress: {
|
||||
enabled: isWordPress,
|
||||
},
|
||||
redis: {
|
||||
enabled: app.enableRedis || false,
|
||||
storageSize: '1Gi',
|
||||
resources: {
|
||||
cpuRequest: '50m',
|
||||
cpuLimit: '200m',
|
||||
memoryRequest: '64Mi',
|
||||
memoryLimit: '256Mi',
|
||||
},
|
||||
},
|
||||
rabbitmq: {
|
||||
enabled: app.enableRabbitmq || false,
|
||||
storageSize: '2Gi',
|
||||
resources: {
|
||||
cpuRequest: '100m',
|
||||
cpuLimit: '500m',
|
||||
memoryRequest: '256Mi',
|
||||
memoryLimit: '512Mi',
|
||||
},
|
||||
},
|
||||
redis: this.buildRedisHelmBlock(app),
|
||||
rabbitmq: this.buildRabbitmqHelmBlock(app),
|
||||
elasticsearch: {
|
||||
enabled: app.enableElasticsearch || false,
|
||||
logPaths: app.logPaths || [],
|
||||
|
||||
Reference in New Issue
Block a user