901a20eb01
Let users size the database workload from the deploy wizard the same way Redis/RabbitMQ are configured: a resource card (CPU request/limit, memory request/limit, storage) on the Resources step, stored in optionalServiceResources.database. - entity/DTO: add `database` to optionalServiceResources - k8s: resolveDatabaseResources() applies user-selected resources on both the Helm and K8s-API deploy paths (was hardcoded 100m/256Mi→500m/512Mi) - billing: bill database CPU/RAM as a separate line on top of the app's resources; merge it through the upgrade path too - wizard: db resource card on the Resources step, disk moved into the card, cost preview + review summary include the database resources Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
61 lines
1.6 KiB
TypeScript
61 lines
1.6 KiB
TypeScript
import type {
|
|
OptionalServiceResourceConfig,
|
|
OptionalServiceResourcesMap,
|
|
PricingCatalog,
|
|
} from '@/types';
|
|
|
|
export type OptionalServiceKey = keyof OptionalServiceResourcesMap;
|
|
|
|
const FALLBACK_OPTIONAL_RESOURCES: Record<OptionalServiceKey, OptionalServiceResourceConfig> = {
|
|
database: {
|
|
cpuRequest: '100m',
|
|
cpuLimit: '500m',
|
|
memoryRequest: '256Mi',
|
|
memoryLimit: '512Mi',
|
|
storageGi: 1,
|
|
},
|
|
redis: {
|
|
cpuRequest: '50m',
|
|
cpuLimit: '200m',
|
|
memoryRequest: '64Mi',
|
|
memoryLimit: '256Mi',
|
|
storageGi: 1,
|
|
},
|
|
rabbitmq: {
|
|
cpuRequest: '100m',
|
|
cpuLimit: '500m',
|
|
memoryRequest: '256Mi',
|
|
memoryLimit: '512Mi',
|
|
storageGi: 2,
|
|
},
|
|
};
|
|
|
|
export function optionalDefaultsFromCatalog(
|
|
catalog: PricingCatalog | undefined,
|
|
service: OptionalServiceKey,
|
|
): OptionalServiceResourceConfig {
|
|
const profile = catalog?.optionalServices?.[service]?.profile;
|
|
const fallback = FALLBACK_OPTIONAL_RESOURCES[service];
|
|
if (!profile) return { ...fallback };
|
|
return {
|
|
cpuRequest: profile.cpuRequest || fallback.cpuRequest,
|
|
cpuLimit: profile.cpuLimit || fallback.cpuLimit,
|
|
memoryRequest: profile.memoryRequest || fallback.memoryRequest,
|
|
memoryLimit: profile.memoryLimit || fallback.memoryLimit,
|
|
storageGi: profile.storageGi ?? fallback.storageGi,
|
|
};
|
|
}
|
|
|
|
export function managedServiceTypeLabel(productType?: string): string {
|
|
switch (productType) {
|
|
case 'managed_database':
|
|
return 'Managed Database';
|
|
case 'managed_redis':
|
|
return 'Managed Redis';
|
|
case 'managed_rabbitmq':
|
|
return 'Managed RabbitMQ';
|
|
default:
|
|
return 'Service';
|
|
}
|
|
}
|