@chimoney.io/iaas-k8s-deployment
Version:
Kubernetes Infrastructure as a Service deployment package for streamlined multi-cloud environments
140 lines • 4.35 kB
TypeScript
import { PlanTier, TierConfiguration, TierResourceAllocation } from "../types/plans.js";
import { Logger } from "../types/index.js";
export interface ClusterCapacity {
totalCpu: string;
totalMemory: string;
totalStorage: string;
availableCpu: string;
availableMemory: string;
availableStorage: string;
nodeCount: number;
}
export interface TierAllocationResult {
success: boolean;
tierConfig: TierConfiguration;
helmValues: any;
resourceQuota: any;
limitRange: any;
estimatedCosts: {
monthly: number;
yearly: number;
currency: string;
};
warnings: string[];
errors: string[];
}
export interface TierValidationResult {
isValid: boolean;
canAllocate: boolean;
resourceUtilization: {
cpuUsagePercent: number;
memoryUsagePercent: number;
storageUsagePercent: number;
};
recommendations: string[];
errors: string[];
}
export declare class TierCalculator {
private logger;
constructor(logger: Logger);
/**
* Calculate resource allocation for a given tier
*/
calculateTierAllocation(planTier: PlanTier, companyName: string, namespace: string, options?: {
kubecostEnabled?: boolean;
billingAccountId?: string;
customLabels?: Record<string, string>;
}): TierAllocationResult;
/**
* Validate if a tier can be allocated given cluster capacity
*/
validateTierAgainstCapacity(planTier: PlanTier, clusterCapacity: ClusterCapacity, existingAllocations?: TierConfiguration[]): TierValidationResult;
/**
* Calculate optimal cluster capacity for a set of tier allocations
*/
calculateOptimalClusterCapacity(tierAllocations: {
tier: PlanTier;
count: number;
}[]): ClusterCapacity;
/**
* Generate Helm values for tier-based deployment
*/
private generateHelmValues;
/**
* Generate Kubernetes ResourceQuota for tier
*/
generateResourceQuota(tierConfig: TierConfiguration, namespace: string): any;
/**
* Generate Kubernetes LimitRange for tier
*/
generateLimitRange(tierConfig: TierConfiguration, namespace: string): any;
/**
* Calculate total resources required for a tier
*/
private calculateTotalTierResources;
/**
* Parse resource value string to number
*/
private parseResourceValue;
/**
* Calculate limit from request (typically 1.5-2x request)
*/
private calculateLimitFromRequest;
/**
* Add tier-specific warnings
*/
private addTierWarnings;
/**
* Calculate resources for a given tier
*/
calculateResources(planTier: PlanTier): TierResourceAllocation;
/**
* Validate tier resources
*/
validateTierResources(planTier: PlanTier, resources: TierResourceAllocation): {
isValid: boolean;
errors: string[];
warnings: string[];
};
/**
* Calculate monthly cost for a tier
*/
calculateMonthlyCost(planTier: PlanTier): number;
/**
* Make generateHelmValues public for CLI usage
*/
generateHelmValuesForTier(planTier: PlanTier, companyName: string, namespace: string, options?: {
kubecostEnabled?: boolean;
billingAccountId?: string;
customLabels?: Record<string, string>;
}): any;
/**
* Get tier budget for monitoring dashboards
*/
getTierBudget(tier: PlanTier): number;
/**
* Get tier CPU limits for monitoring dashboards
*/
getTierCpuLimits(tier: PlanTier): string;
/**
* Get tier memory limits for monitoring dashboards
*/
getTierMemoryLimits(tier: PlanTier): string;
/**
* Get tier resource quota values
*/
getTierResourceQuota(tier: PlanTier, resource: string, type: "requests" | "limits" | "claims"): string;
/**
* Helper method to extract resource quota values
*/
private getResourceQuotaValue;
}
/**
* Helper function to create tier calculator instance
*/
export declare function createTierCalculator(logger: Logger): TierCalculator;
/**
* Quick tier allocation for shared deployments
*/
export declare function quickTierAllocation(planTier: PlanTier, companyName: string, namespace: string, logger: Logger): TierAllocationResult;
//# sourceMappingURL=tier-calculator.d.ts.map