resources

package
v0.0.0-...-950e6cb Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 26, 2024 License: Apache-2.0 Imports: 13 Imported by: 5

Documentation

Index

Constants

View Source
const (
	Pod = "Pod"
	PVC = "PVC"
)
View Source
const (
	DBPodLabelInstanceKey      = "app.kubernetes.io/instance"
	DBPodLabelManagedByKey     = "app.kubernetes.io/managed-by"
	DBPodLabelManagedByValue   = "kubeblocks"
	DBPodLabelComponentNameKey = "apps.kubeblocks.io/component-name"
	TerminalIDLabelKey         = "TerminalID"
	AppLabelKey                = "app"
	AppDeployLabelKey          = "cloud.sealos.io/app-deploy-manager"
	JobNameLabelKey            = "job-name"
	ACMEChallengeKey           = "acme.cert-manager.io/http01-solver"
	KubeBlocksBackUpName       = "kubeblocks-backup-data"
)
View Source
const (
	DB            = "DB"
	APP           = "APP"
	TERMINAL      = "TERMINAL"
	JOB           = "JOB"
	OTHER         = "OTHER"
	ObjectStorage = "OBJECT-STORAGE"
	CVM           = "CLOUD-VM"
)
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
)
View Source
const (
	QuotaLimitsCPU       = "QUOTA_LIMITS_CPU"
	QuotaLimitsMemory    = "QUOTA_LIMITS_MEMORY"
	QuotaLimitsStorage   = "QUOTA_LIMITS_STORAGE"
	QuotaLimitsGPU       = "QUOTA_LIMITS_GPU"
	QuotaLimitsNodePorts = "QUOTA_LIMITS_NODE_PORTS"
)
View Source
const (
	DefaultQuotaLimitsCPU       = "16"
	DefaultQuotaLimitsMemory    = "64Gi"
	DefaultQuotaLimitsStorage   = "100Gi"
	DefaultQuotaLimitsGPU       = "8"
	DefaultQuotaLimitsNodePorts = "3"
)
View Source
const GpuResourcePrefix = "gpu-"

GpuResourcePrefix GPUResource = gpu- + gpu.Product ; ex. gpu-tesla-v100

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,
}
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 ConvertEnumUsedToString(costs map[uint8]int64) (costsMap map[string]int64)

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 GetGpuResourceProduct(resource string) string

func IsGpuResource

func IsGpuResource(resource string) bool

func NewGpuResource

func NewGpuResource(product string) corev1.ResourceName

Types

type AppCost

type AppCost struct {
	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"`
	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,omitempty"`
	// 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"`
}

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 EnumUsedMap

type EnumUsedMap map[uint8]int64

resource consumption

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"`
	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 Payment

type Payment struct {
	Method  string `json:"method" bson:"method"`
	UserID  string `json:"user_id" bson:"user_id"`
	Amount  int64  `json:"amount,omitempty"`
	TradeNO string `json:"tradeNO,omitempty"`
	// CodeURL is the codeURL of wechatpay
	CodeURL string `json:"codeURL,omitempty"`
}

type Price

type Price struct {
	Property string `json:"property" bson:"property"`
	Price    int64  `json:"price" bson:"price"`
	Detail   string `json:"detail" bson:"detail"`
}

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) GetInLabels

func (p *ResourceNamed) GetInLabels() []*sealos_networkmanager.Label

func (*ResourceNamed) GetNotExistLabels

func (p *ResourceNamed) GetNotExistLabels() []*sealos_networkmanager.Label

func (*ResourceNamed) Labels

func (p *ResourceNamed) Labels() map[string]string

func (*ResourceNamed) Name

func (p *ResourceNamed) Name() string

func (*ResourceNamed) String

func (p *ResourceNamed) String() string

func (*ResourceNamed) Type

func (p *ResourceNamed) Type() uint8

func (*ResourceNamed) TypeString

func (p *ResourceNamed) TypeString() string

type Transfer

type Transfer struct {
	From   string `json:"from" bson:"from,omitempty"`
	To     string `json:"to" bson:"to,omitempty"`
	Amount int64  `json:"amount" bson:"amount"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL