Documentation ¶
Index ¶
- Constants
- Variables
- func ConvertEnumUsedToString(costs map[uint8]int64) (costsMap map[string]int64)
- func DefaultLimitRangeLimits() []corev1.LimitRangeItem
- func DefaultResourceQuotaHard() corev1.ResourceList
- func GetDefaultLimitRange(ns, name string) *corev1.LimitRange
- func GetDefaultResourceQuota(ns, name string) *corev1.ResourceQuota
- func GetGpuResourceProduct(resource string) string
- func IsGpuResource(resource string) bool
- func NewGpuResource(product string) corev1.ResourceName
- type ActiveBilling
- type AppCost
- type Billing
- type BillingHandler
- type BillingStatus
- type BillingType
- type ConsumptionStatus
- type EnumUsedMap
- type Monitor
- type Payment
- type Price
- type PropertyList
- type PropertyType
- type PropertyTypeEnumMap
- type PropertyTypeLS
- type PropertyTypeStringMap
- type ResourceNamed
- func (r *ResourceNamed) Name() string
- func (r *ResourceNamed) ParentName() string
- func (r *ResourceNamed) ParentType() uint8
- func (r *ResourceNamed) SetInstanceParent(instances map[string]struct{})
- func (r *ResourceNamed) String() string
- func (r *ResourceNamed) Type() uint8
- func (r *ResourceNamed) TypeString() string
- type Transfer
- type UsedMap
Constants ¶
View Source
const ( DBPodLabelInstanceKey = "app.kubernetes.io/instance" DBPodLabelComponentNameKey = "apps.kubeblocks.io/component-name" TerminalIDLabelKey = "TerminalID" AppLabelKey = "app" AppDeployLabelKey = "cloud.sealos.io/app-deploy-manager" AppStoreDeployLabelKey = "cloud.sealos.io/deploy-on-sealos" JobNameLabelKey = "job-name" ACMEChallengeKey = "acme.cert-manager.io/http01-solver" KubeBlocksBackUpName = "kubeblocks-backup-data" InstanceLabelKey = "app.kubernetes.io/instance" )
View Source
const ( DB = "DB" APP = "APP" TERMINAL = "TERMINAL" JOB = "JOB" OTHER = "OTHER" ObjectStorage = "OBJECT-STORAGE" CVM = "CLOUD-VM" AppStore = "APP-STORE" DBBackup = "DB-BACKUP" DevBox = "DEV-BOX" LLMToken = "LLM-TOKEN" )
View Source
const ( // average value AVG = "AVG" // accumulated value SUM = "SUM" // difference value DIF = "DIF" )
View Source
const ( ResourceRequestGpu corev1.ResourceName = "requests." + gpu.NvidiaGpuKey ResourceLimitGpu corev1.ResourceName = "limits." + gpu.NvidiaGpuKey ResourceObjectStorageSize corev1.ResourceName = "objectstorage/size" ResourceObjectStorageBucket corev1.ResourceName = "objectstorage/bucket" )
View Source
const ( QuotaLimitsCPU = "QUOTA_LIMITS_CPU" QuotaLimitsMemory = "QUOTA_LIMITS_MEMORY" QuotaLimitsStorage = "QUOTA_LIMITS_STORAGE" QuotaLimitsGPU = "QUOTA_LIMITS_GPU" QuotaLimitsNodePorts = "QUOTA_LIMITS_NODE_PORTS" QuotaObjectStorageSize = "QUOTA_OBJECT_STORAGE_SIZE" QuotaObjectStorageBucket = "QUOTA_OBJECT_STORAGE_BUCKET" LimitRangeCPU = "LIMIT_RANGE_CPU" LimitRangeMemory = "LIMIT_RANGE_MEMORY" LimitRangeEphemeralStorage = "LIMIT_RANGE_EPHEMERAL_STORAGE" LimitRangeRepCPU = "LIMIT_RANGE_REP_CPU" LimitRangeRepMemory = "LIMIT_RANGE_REP_MEMORY" LimitRangeRepEphemeralStorage = "LIMIT_RANGE_REP_EPHEMERAL_STORAGE" )
View Source
const ( DefaultQuotaLimitsCPU = "16" DefaultQuotaLimitsMemory = "64Gi" DefaultQuotaLimitsStorage = "100Gi" DefaultQuotaLimitsGPU = "8" DefaultQuotaLimitsNodePorts = "10" DefaultQuotaObjectStorageSize = "100Gi" DefaultQuotaObjectStorageBucket = "5" )
View Source
const GpuResourcePrefix = "gpu-"
GpuResourcePrefix GPUResource = gpu- + gpu.Product ; ex. gpu-tesla-v100
View Source
const ResourceGPU corev1.ResourceName = gpu.NvidiaGpuKey
View Source
const ResourceNetwork = "network"
Variables ¶
View Source
var AppType = map[string]uint8{ DB: db, APP: app, TERMINAL: terminal, JOB: job, OTHER: other, ObjectStorage: objectStorage, CVM: cvm, AppStore: appStore, DBBackup: dbBackup, DevBox: devBox, LLMToken: llmToken, }
View Source
var AppTypeReverse = map[uint8]string{ // contains filtered or unexported fields }
View Source
var DefaultPropertyTypeLS = newPropertyTypeLS(DefaultPropertyTypeList)
View Source
var DefaultPropertyTypeList = []PropertyType{ { Name: "cpu", Enum: 0, PriceType: AVG, UnitPrice: 2.237442922, UnitString: "1m", }, { Name: "memory", Enum: 1, PriceType: AVG, UnitPrice: 1.092501427, UnitString: "1Mi", }, { Name: "storage", Enum: 2, PriceType: AVG, UnitPrice: 0, UnitString: "1Mi", }, { Name: "network", Enum: 3, PriceType: SUM, UnitPrice: 0, UnitString: "1Mi", }, { Name: "services.nodeports", Enum: 4, PriceType: AVG, UnitPrice: 2.083, ViewPrice: 2083, UnitString: "1", }, }
Functions ¶
func ConvertEnumUsedToString ¶
func DefaultLimitRangeLimits ¶
func DefaultLimitRangeLimits() []corev1.LimitRangeItem
func DefaultResourceQuotaHard ¶
func DefaultResourceQuotaHard() corev1.ResourceList
func GetDefaultLimitRange ¶
func GetDefaultLimitRange(ns, name string) *corev1.LimitRange
func GetDefaultResourceQuota ¶
func GetDefaultResourceQuota(ns, name string) *corev1.ResourceQuota
func GetGpuResourceProduct ¶
func IsGpuResource ¶
func NewGpuResource ¶
func NewGpuResource(product string) corev1.ResourceName
Types ¶
type ActiveBilling ¶
type ActiveBilling struct { ID primitive.ObjectID `json:"_id,omitempty" bson:"_id,omitempty"` Time time.Time `json:"time,omitempty" bson:"time"` Namespace string `json:"namespace" bson:"namespace"` AppType string `json:"app_type" bson:"app_type"` AppName string `json:"app_name" bson:"app_name"` Used UsedMap `json:"used,omitempty" bson:"used,omitempty"` Amount int64 `json:"amount" bson:"amount,omitempty"` Owner string `json:"owner" bson:"owner,omitempty"` UserUID uuid.UUID `json:"user_uid" bson:"user_uid"` Status ConsumptionStatus `json:"status" bson:"status"` }
type AppCost ¶
type AppCost struct { Type uint8 `json:"type" bson:"type"` Used EnumUsedMap `json:"used" bson:"used"` UsedAmount EnumUsedMap `json:"used_amount" bson:"used_amount"` Amount int64 `json:"amount" bson:"amount,omitempty"` Name string `json:"name" bson:"name"` }
type Billing ¶
type Billing struct { Time time.Time `json:"time" bson:"time"` OrderID string `json:"order_id" bson:"order_id"` Type common.Type `json:"type" bson:"type"` //Name string `json:"name" bson:"name"` Namespace string `json:"namespace" bson:"namespace"` AppCosts []AppCost `json:"app_costs,omitempty" bson:"app_costs,omitempty"` AppName string `json:"app_name,omitempty" bson:"app_name,omitempty"` AppType uint8 `json:"app_type,omitempty" bson:"app_type,omitempty"` Amount int64 `json:"amount" bson:"amount,omitempty"` Owner string `json:"owner" bson:"owner,omitempty"` // 0: 未结算 1: 已结算 Status BillingStatus `json:"status" bson:"status"` // if type = Consumption, then payment is not nil Payment *Payment `json:"payment" bson:"payment,omitempty"` // if type = Transfer, then transfer is not nil Transfer *Transfer `json:"transfer" bson:"transfer,omitempty"` Detail string `json:"detail" bson:"detail,omitempty"` UserUID uuid.UUID `json:"user_uid" bson:"user_uid,omitempty"` }
type BillingHandler ¶
type BillingHandler struct { OrderID string `json:"order_id" bson:"order_id"` Time time.Time `json:"time" bson:"time"` Amount int64 `json:"amount" bson:"amount,omitempty"` Status BillingStatus `json:"status" bson:"status,omitempty"` }
type BillingStatus ¶
type BillingStatus int
const ( // 0: 未结算 1: 已结算 Unsettled BillingStatus = iota Settled )
type BillingType ¶
type BillingType int
type ConsumptionStatus ¶
type ConsumptionStatus string
const ( Consumed ConsumptionStatus = "consumed" Processing ConsumptionStatus = "processing" Unconsumed ConsumptionStatus = "unconsumed" ErrorConsumed ConsumptionStatus = "error_consumed" )
type Monitor ¶
type Monitor struct { Time time.Time `json:"time" bson:"time"` // equal namespace Category string `json:"category" bson:"category"` Type uint8 `json:"type" bson:"type"` ParentType uint8 `json:"parent_type" bson:"parent_type"` ParentName string `json:"parent_name" bson:"parent_name"` Name string `json:"name" bson:"name"` Used EnumUsedMap `json:"used" bson:"used"` Property string `json:"property,omitempty" bson:"property,omitempty"` }
Composite index: category, property, time, speed up query
type PropertyList ¶
type PropertyList []PropertyType
type PropertyType ¶
type PropertyType struct { // For the monitoring storage enumeration type, use uint 8 to save memory // 0 cpu, 1 memory, 2 storage, 3 network ... expandable Name string `json:"name" bson:"name"` Alias string `json:"alias" bson:"alias"` Enum uint8 `json:"enum" bson:"enum"` //AVG, SUM, DIF value. The cumulative value is the average value by default PriceType string `json:"price_type,omitempty" bson:"price_type,omitempty"` // Price = UsedAmount (avg || accumulated-value || difference-value) / Unit * UnitPrice UnitPrice float64 `json:"unit_price" bson:"unit_price"` ViewPrice float64 `json:"view_price" bson:"view_price"` EncryptUnitPrice string `json:"encrypt_unit_price" bson:"encrypt_unit_price"` Unit resource.Quantity `json:"-" bson:"-"` // <digit> ::= 0 | 1 | ... | 9 // <digits> ::= <digit> | <digit><digits> // <number> ::= <digits> | <digits>.<digits> | <digits>. | .<digits> // <sign> ::= "+" | "-" // <signedNumber> ::= <number> | <sign><number> // <suffix> ::= <binarySI> | <decimalExponent> | <decimalSI> // <binarySI> ::= Ki | Mi | Gi | Ti | Pi | Ei // // (International System of units; See: http://physics.nist.gov/cuu/Units/binary.html) // // <decimalSI> ::= m | "" | k | M | G | T | P | E // // (Note that 1024 = 1Ki but 1000 = 1k; I didn't choose the capitalization.) // // <decimalExponent> ::= "e" <signedNumber> | "E" <signedNumber> UnitString string `json:"unit" bson:"unit"` //charging cycle second UnitPeriod string `json:"unit_period,omitempty" bson:"unit_period,omitempty"` }
type PropertyTypeEnumMap ¶
type PropertyTypeEnumMap map[uint8]PropertyType
type PropertyTypeLS ¶
type PropertyTypeLS struct { Types []PropertyType StringMap map[string]PropertyType EnumMap map[uint8]PropertyType }
func NewPropertyTypeLS ¶
func NewPropertyTypeLS(types []PropertyType) (ls *PropertyTypeLS)
type PropertyTypeStringMap ¶
type PropertyTypeStringMap map[string]PropertyType
type ResourceNamed ¶
type ResourceNamed struct {
// contains filtered or unexported fields
}
func NewObjStorageResourceNamed ¶
func NewObjStorageResourceNamed(bucket string) *ResourceNamed
func NewResourceNamed ¶
func NewResourceNamed(cr client.Object) *ResourceNamed
func (*ResourceNamed) Name ¶
func (r *ResourceNamed) Name() string
func (*ResourceNamed) ParentName ¶
func (r *ResourceNamed) ParentName() string
func (*ResourceNamed) ParentType ¶
func (r *ResourceNamed) ParentType() uint8
func (*ResourceNamed) SetInstanceParent ¶
func (r *ResourceNamed) SetInstanceParent(instances map[string]struct{})
func (*ResourceNamed) String ¶
func (r *ResourceNamed) String() string
func (*ResourceNamed) Type ¶
func (r *ResourceNamed) Type() uint8
func (*ResourceNamed) TypeString ¶
func (r *ResourceNamed) TypeString() string
Click to show internal directories.
Click to hide internal directories.