controllers

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: 50 Imported by: 0

Documentation

Index

Constants

View Source
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
)
View Source
const (
	UserNamespacePrefix = "ns-"
	ResourceQuotaPrefix = "quota-"
)
View Source
const (
	DebtDetectionCycleEnv = "DebtDetectionCycleSeconds"

	SMSAccessKeyIDEnv     = "SMS_AK"
	SMSAccessKeySecretEnv = "SMS_SK"
	SMSEndpointEnv        = "SMS_ENDPOINT"
	SMSSignNameEnv        = "SMS_SIGN_NAME"
	SMSCodeMapEnv         = "SMS_CODE_MAP"
)
View Source
const (
	WarningNotice = iota
	ApproachingDeletionNotice
	ImminentDeletionNotice
	FinalDeletionNotice
)
View Source
const (
	DebtLimit0Name        = "debt-limit0"
	OSAccessKey           = "CONSOLE_ACCESS_KEY"
	OSSecretKey           = "CONSOLE_SECRET_KEY"
	Disabled              = "disabled"
	Enabled               = "enabled"
	OSInternalEndpointEnv = "OSInternalEndpoint"
	OSNamespace           = "OSNamespace"
	OSAdminSecret         = "OSAdminSecret"
)
View Source
const BaseUnit = 1_000_000
View Source
const BillingAnnotationLastUpdateTime = "account.sealos.io/last-update-time"

Variables

View Source
var ErrAccountNotExist = errors.New("account not exist")
View Source
var NoticeTemplateEN map[int]string
View Source
var NoticeTemplateZH map[int]string
View Source
var TitleTemplateEN = map[int]string{
	WarningNotice:             "Debt Warning",
	ApproachingDeletionNotice: "Resource Suspension Warning",
	ImminentDeletionNotice:    "Resource Release Warning",
	FinalDeletionNotice:       "Resource Release Warning",
}
View Source
var TitleTemplateZH = map[int]string{
	WarningNotice:             "欠费告警",
	ApproachingDeletionNotice: "资源暂停告警",
	ImminentDeletionNotice:    "资源释放告警",
	FinalDeletionNotice:       "资源已释放告警",
}

Functions

func CheckOpts

func CheckOpts(billingRecordQuery *accountv1.BillingRecordQuery) error

func GetDebtName

func GetDebtName(AccountName string) string

func GetLimit0ResourceQuota

func GetLimit0ResourceQuota(namespace string) *corev1.ResourceQuota

func GetUserNamespace

func GetUserNamespace(AccountName string) string

func GetUserOwner

func GetUserOwner(user *userv1.User) string

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

func (r *AccountReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error)

func (*AccountReconciler) SetupWithManager

func (r *AccountReconciler) SetupWithManager(mgr ctrl.Manager, rateOpts controller.Options) error

SetupWithManager sets up the controller with the Manager.

type AnnotationChangedPredicate

type AnnotationChangedPredicate struct {
	predicate.Funcs
}

func (AnnotationChangedPredicate) Create

func (AnnotationChangedPredicate) Update

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 (*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) Reconcile

func (r *BillingInfoQueryReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctl ctrl.Result, 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

func (r *BillingReconciler) 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 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

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

func (r *DebtReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error)

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

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

func (r *NamespaceReconciler) 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 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

type OnlyCreatePredicate struct {
	predicate.Funcs
}

func (OnlyCreatePredicate) Create

func (OnlyCreatePredicate) Update

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

func (r *PaymentReconciler) 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 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

type PodReconciler struct {
	client.Client
	logr.Logger
	Scheme *runtime.Scheme
}

PodReconciler reconciles a Pod object

func (*PodReconciler) Reconcile

func (r *PodReconciler) 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 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 SmsConfig

type SmsConfig struct {
	Client      *client2.Client
	SmsSignName string
	SmsCode     map[int]string
}

type UserOwnerPredicate

type UserOwnerPredicate struct {
	predicate.Funcs
}

func (UserOwnerPredicate) Create

func (UserOwnerPredicate) Update

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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