Documentation ¶
Index ¶
- Constants
- Variables
- func CheckOpts(billingRecordQuery *accountv1.BillingRecordQuery) error
- func GetDebtName(AccountName string) string
- func GetLimit0ResourceQuota(namespace string) *corev1.ResourceQuota
- func GetUserNamespace(AccountName string) string
- func GetUserOwner(user *userv1.User) string
- func RawParseRechargeConfig() (activities pkgtypes.Activities, discountsteps []int64, ...)
- func SetDebtStatus(debt *accountv1.Debt, status accountv1.DebtStatusType) bool
- type AccountReconciler
- func (r *AccountReconciler) BillingCVM() error
- func (r *AccountReconciler) DeletePayment(ctx context.Context) error
- func (r *AccountReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error)
- func (r *AccountReconciler) SetupWithManager(mgr ctrl.Manager, rateOpts controller.Options) error
- type AnnotationChangedPredicate
- type BillingInfoQueryReconciler
- func (r *BillingInfoQueryReconciler) AppTypeQuery(_ context.Context, _ ctrl.Request, _ *accountv1.BillingInfoQuery) (result string, err error)
- func (r *BillingInfoQueryReconciler) ConvertPropertiesToQuery() error
- func (r *BillingInfoQueryReconciler) NamespacesHistoryQuery(ctx context.Context, req ctrl.Request, _ *accountv1.BillingInfoQuery) (result string, err error)
- func (r *BillingInfoQueryReconciler) PropertiesQuery(_ context.Context, _ ctrl.Request, _ *accountv1.BillingInfoQuery) (result string, err error)
- func (r *BillingInfoQueryReconciler) RechargeQuery(_ context.Context, _ ctrl.Request, ...) (result string, err error)
- func (r *BillingInfoQueryReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctl ctrl.Result, err error)
- func (r *BillingInfoQueryReconciler) SetupWithManager(mgr ctrl.Manager) error
- type BillingReconciler
- type BillingRecordQueryReconciler
- func (r *BillingRecordQueryReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error)
- func (r *BillingRecordQueryReconciler) ReconcilePriceQuery(ctx context.Context, priceQuery *accountv1.PriceQuery) (ctrl.Result, error)
- func (r *BillingRecordQueryReconciler) SetupWithManager(mgr ctrl.Manager, rateOpts controller.Options) error
- type DebtReconciler
- func (r *DebtReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error)
- func (r *DebtReconciler) ResumeUserResource(ctx context.Context, namespaces []string) error
- func (r *DebtReconciler) SetupWithManager(mgr ctrl.Manager, rateOpts controller.Options) error
- func (r *DebtReconciler) SuspendUserResource(ctx context.Context, namespaces []string) error
- type NamespaceBillingHistoryReconciler
- type NamespaceReconciler
- func (r *NamespaceReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error)
- func (r *NamespaceReconciler) ResumeUserResource(ctx context.Context, namespace string) error
- func (r *NamespaceReconciler) SetupWithManager(mgr ctrl.Manager) error
- func (r *NamespaceReconciler) SuspendUserResource(ctx context.Context, namespace string) error
- type OnlyCreatePredicate
- type PaymentReconciler
- type PodReconciler
- type PodReconcilerOptions
- type SmsConfig
- type UserOwnerPredicate
Constants ¶
const ( ACCOUNTNAMESPACEENV = "ACCOUNT_NAMESPACE" DEFAULTACCOUNTNAMESPACE = "sealos-system" AccountAnnotationNewAccount = "account.sealos.io/new-account" AccountAnnotationIgnoreQuota = "account.sealos.io/ignore-quota" NEWACCOUNTAMOUNTENV = "NEW_ACCOUNT_AMOUNT" RECHARGEGIFT = "recharge-gift" SEALOS = "sealos" DefaultInitialBalance = 5_000_000 )
const ( UserNamespacePrefix = "ns-" ResourceQuotaPrefix = "quota-" )
const ( DebtDetectionCycleEnv = "DebtDetectionCycleSeconds" SMSAccessKeyIDEnv = "SMS_AK" SMSAccessKeySecretEnv = "SMS_SK" SMSEndpointEnv = "SMS_ENDPOINT" SMSSignNameEnv = "SMS_SIGN_NAME" SMSCodeMapEnv = "SMS_CODE_MAP" )
const ( WarningNotice = iota ApproachingDeletionNotice ImminentDeletionNotice FinalDeletionNotice )
const ( DebtLimit0Name = "debt-limit0" OSAccessKey = "CONSOLE_ACCESS_KEY" OSSecretKey = "CONSOLE_SECRET_KEY" Disabled = "disabled" Enabled = "enabled" OSInternalEndpointEnv = "OSInternalEndpoint" OSNamespace = "OSNamespace" OSAdminSecret = "OSAdminSecret" )
const BaseUnit = 1_000_000
const BillingAnnotationLastUpdateTime = "account.sealos.io/last-update-time"
Variables ¶
var DebtConfig = accountv1.DefaultDebtConfig
var ErrAccountNotExist = errors.New("account not exist")
var NoticeTemplateEN map[int]string
var NoticeTemplateZH map[int]string
var TitleTemplateEN = map[int]string{ WarningNotice: "Debt Warning", ApproachingDeletionNotice: "Resource Suspension Warning", ImminentDeletionNotice: "Resource Release Warning", FinalDeletionNotice: "Resource Release Warning", }
var TitleTemplateZH = map[int]string{ WarningNotice: "欠费告警", ApproachingDeletionNotice: "资源暂停告警", ImminentDeletionNotice: "资源释放告警", FinalDeletionNotice: "资源已释放告警", }
Functions ¶
func CheckOpts ¶
func CheckOpts(billingRecordQuery *accountv1.BillingRecordQuery) error
func GetDebtName ¶
func GetLimit0ResourceQuota ¶
func GetLimit0ResourceQuota(namespace string) *corev1.ResourceQuota
func GetUserNamespace ¶
func GetUserOwner ¶
func RawParseRechargeConfig ¶
func RawParseRechargeConfig() (activities pkgtypes.Activities, discountsteps []int64, discountratios []float64, returnErr error)
func SetDebtStatus ¶
func SetDebtStatus(debt *accountv1.Debt, status accountv1.DebtStatusType) bool
Types ¶
type AccountReconciler ¶
type AccountReconciler struct { client.Client AccountV2 database.AccountV2 Scheme *runtime.Scheme Logger logr.Logger AccountSystemNamespace string DBClient database.Account CVMDBClient database.CVM MongoDBURI string Activities pkgtypes.Activities DefaultDiscount pkgtypes.RechargeDiscount }
AccountReconciler reconciles an Account object
func (*AccountReconciler) BillingCVM ¶
func (r *AccountReconciler) BillingCVM() error
func (*AccountReconciler) DeletePayment ¶
func (r *AccountReconciler) DeletePayment(ctx context.Context) error
DeletePayment delete payments that exist for more than 5 minutes
func (*AccountReconciler) SetupWithManager ¶
func (r *AccountReconciler) SetupWithManager(mgr ctrl.Manager, rateOpts controller.Options) error
SetupWithManager sets up the controller with the Manager.
type AnnotationChangedPredicate ¶
func (AnnotationChangedPredicate) Create ¶
func (AnnotationChangedPredicate) Create(e event.CreateEvent) bool
func (AnnotationChangedPredicate) Update ¶
func (AnnotationChangedPredicate) Update(e event.UpdateEvent) bool
type BillingInfoQueryReconciler ¶
type BillingInfoQueryReconciler struct { client.Client logr.Logger Scheme *runtime.Scheme DBClient database.Account //TODO init AccountV2 database.AccountV2 AccountSystemNamespace string Properties *resources.PropertyTypeLS Activities types.Activities DefaultDiscount types.RechargeDiscount QueryFuncMap map[string]func(context.Context, ctrl.Request, *accountv1.BillingInfoQuery) (string, error) // contains filtered or unexported fields }
BillingInfoQueryReconciler reconciles a BillingInfoQuery object
func (*BillingInfoQueryReconciler) AppTypeQuery ¶
func (r *BillingInfoQueryReconciler) AppTypeQuery(_ context.Context, _ ctrl.Request, _ *accountv1.BillingInfoQuery) (result string, err error)
func (*BillingInfoQueryReconciler) ConvertPropertiesToQuery ¶
func (r *BillingInfoQueryReconciler) ConvertPropertiesToQuery() error
func (*BillingInfoQueryReconciler) NamespacesHistoryQuery ¶
func (r *BillingInfoQueryReconciler) NamespacesHistoryQuery(ctx context.Context, req ctrl.Request, _ *accountv1.BillingInfoQuery) (result string, err error)
func (*BillingInfoQueryReconciler) PropertiesQuery ¶
func (r *BillingInfoQueryReconciler) PropertiesQuery(_ context.Context, _ ctrl.Request, _ *accountv1.BillingInfoQuery) (result string, err error)
func (*BillingInfoQueryReconciler) RechargeQuery ¶
func (r *BillingInfoQueryReconciler) RechargeQuery(_ context.Context, _ ctrl.Request, billingInfoQuery *accountv1.BillingInfoQuery) (result string, err error)
func (*BillingInfoQueryReconciler) SetupWithManager ¶
func (r *BillingInfoQueryReconciler) SetupWithManager(mgr ctrl.Manager) error
SetupWithManager sets up the controller with the Manager.
type BillingReconciler ¶
type BillingReconciler struct { client.Client Scheme *runtime.Scheme logr.Logger DBClient database.Account AccountV2 database.AccountV2 Properties *resources.PropertyTypeLS }
BillingReconciler reconciles a Billing object
func (*BillingReconciler) Reconcile ¶
Reconcile is part of the main kubernetes reconciliation loop which aims to move the current state of the cluster closer to the desired state. TODO(user): Modify the Reconcile function to compare the state specified by the Billing object against the actual cluster state, and then perform operations to make the cluster state reflect the state specified by the user.
For more details, check Reconcile and its Result here: - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.11.2/pkg/reconcile
func (*BillingReconciler) SetupWithManager ¶
func (r *BillingReconciler) SetupWithManager(mgr ctrl.Manager, rateOpts controller.Options) error
SetupWithManager sets up the controller with the Manager.
type BillingRecordQueryReconciler ¶
type BillingRecordQueryReconciler struct { client.Client Scheme *runtime.Scheme Logger logr.Logger MongoDBURI string AccountSystemNamespace string }
BillingRecordQueryReconciler reconciles a BillingRecordQuery object
func (*BillingRecordQueryReconciler) Reconcile ¶
func (r *BillingRecordQueryReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error)
Reconcile is part of the main kubernetes reconciliation loop which aims to move the current state of the cluster closer to the desired state. TODO(user): Modify the Reconcile function to compare the state specified by the BillingRecordQuery object against the actual cluster state, and then perform operations to make the cluster state reflect the state specified by the user.
For more details, check Reconcile and its Result here: - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.11.2/pkg/reconcile
func (*BillingRecordQueryReconciler) ReconcilePriceQuery ¶
func (r *BillingRecordQueryReconciler) ReconcilePriceQuery(ctx context.Context, priceQuery *accountv1.PriceQuery) (ctrl.Result, error)
func (*BillingRecordQueryReconciler) SetupWithManager ¶
func (r *BillingRecordQueryReconciler) SetupWithManager(mgr ctrl.Manager, rateOpts controller.Options) error
SetupWithManager sets up the controller with the Manager.
type DebtReconciler ¶
type DebtReconciler struct { client.Client AccountV2 database.AccountV2 Scheme *runtime.Scheme DebtDetectionCycle time.Duration LocalRegionID string logr.Logger SmsConfig *SmsConfig // contains filtered or unexported fields }
DebtReconciler reconciles a Debt object
func (*DebtReconciler) ResumeUserResource ¶
func (r *DebtReconciler) ResumeUserResource(ctx context.Context, namespaces []string) error
func (*DebtReconciler) SetupWithManager ¶
func (r *DebtReconciler) SetupWithManager(mgr ctrl.Manager, rateOpts controller.Options) error
SetupWithManager sets up the controller with the Manager.
func (*DebtReconciler) SuspendUserResource ¶
func (r *DebtReconciler) SuspendUserResource(ctx context.Context, namespaces []string) error
type NamespaceBillingHistoryReconciler ¶
type NamespaceBillingHistoryReconciler struct { client.Client Scheme *runtime.Scheme Logger logr.Logger MongoDBURI string }
NamespaceBillingHistoryReconciler reconciles a NamespaceBillingHistory object
func (*NamespaceBillingHistoryReconciler) Reconcile ¶
func (r *NamespaceBillingHistoryReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error)
Reconcile is part of the main kubernetes reconciliation loop which aims to move the current state of the cluster closer to the desired state. TODO(user): Modify the Reconcile function to compare the state specified by the NamespaceBillingHistory object against the actual cluster state, and then perform operations to make the cluster state reflect the state specified by the user.
For more details, check Reconcile and its Result here: - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.11.2/pkg/reconcile
func (*NamespaceBillingHistoryReconciler) SetupWithManager ¶
func (r *NamespaceBillingHistoryReconciler) SetupWithManager(mgr ctrl.Manager) error
SetupWithManager sets up the controller with the Manager.
type NamespaceReconciler ¶
type NamespaceReconciler struct { Client client.WithWatch Log logr.Logger Scheme *runtime.Scheme OSAdminClient *madmin.AdminClient OSNamespace string OSAdminSecret string InternalEndpoint string }
NamespaceReconciler reconciles a Namespace object
func (*NamespaceReconciler) Reconcile ¶
Reconcile is part of the main kubernetes reconciliation loop which aims to move the current state of the cluster closer to the desired state. TODO(user): Modify the Reconcile function to compare the state specified by the Namespace object against the actual cluster state, and then perform operations to make the cluster state reflect the state specified by the user.
For more details, check Reconcile and its Result here: - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.11.2/pkg/reconcile
func (*NamespaceReconciler) ResumeUserResource ¶
func (r *NamespaceReconciler) ResumeUserResource(ctx context.Context, namespace string) error
func (*NamespaceReconciler) SetupWithManager ¶
func (r *NamespaceReconciler) SetupWithManager(mgr ctrl.Manager) error
SetupWithManager sets up the controller with the Manager.
func (*NamespaceReconciler) SuspendUserResource ¶
func (r *NamespaceReconciler) SuspendUserResource(ctx context.Context, namespace string) error
type OnlyCreatePredicate ¶
func (OnlyCreatePredicate) Create ¶
func (OnlyCreatePredicate) Create(_ event.CreateEvent) bool
func (OnlyCreatePredicate) Update ¶
func (OnlyCreatePredicate) Update(_ event.UpdateEvent) bool
type PaymentReconciler ¶
type PaymentReconciler struct { client.Client Scheme *runtime.Scheme Logger logr.Logger // contains filtered or unexported fields }
PaymentReconciler reconciles a Payment object
func (*PaymentReconciler) Reconcile ¶
Reconcile is part of the main kubernetes reconciliation loop which aims to move the current state of the cluster closer to the desired state. TODO(user): Modify the Reconcile function to compare the state specified by the Payment object against the actual cluster state, and then perform operations to make the cluster state reflect the state specified by the user.
For more details, check Reconcile and its Result here: - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.12.2/pkg/reconcile
func (*PaymentReconciler) SetupWithManager ¶
func (r *PaymentReconciler) SetupWithManager(mgr ctrl.Manager, rateOpts controller.Options) error
SetupWithManager sets up the controller with the Manager.
type PodReconciler ¶
PodReconciler reconciles a Pod object
func (*PodReconciler) Reconcile ¶
Reconcile is part of the main kubernetes reconciliation loop which aims to move the current state of the cluster closer to the desired state. TODO(user): Modify the Reconcile function to compare the state specified by the Pod object against the actual cluster state, and then perform operations to make the cluster state reflect the state specified by the user.
For more details, check Reconcile and its Result here: - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.11.2/pkg/reconcile
func (*PodReconciler) SetupWithManager ¶
func (r *PodReconciler) SetupWithManager(mgr ctrl.Manager) error
SetupWithManager sets up the controller with the Manager.
type PodReconcilerOptions ¶
type PodReconcilerOptions struct {
MaxConcurrentReconciles int
}
type UserOwnerPredicate ¶
func (UserOwnerPredicate) Create ¶
func (UserOwnerPredicate) Create(e event.CreateEvent) bool
func (UserOwnerPredicate) Update ¶
func (UserOwnerPredicate) Update(_ event.UpdateEvent) bool