forked from labring/sealos
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: resources monitor, metering controller, billing controller, bil…
…lingrecordquery, pricequery controller (labring#3008) * change accountbalance struct add billing controller; add new query CRD: billingresordquery and pricequery, and query controller; modify the storage amount ratio to 1:1000000 optimize mongo query code * hide the old metering controller * add query gvk to debt webhook white list; monitor data table by day, eg: monitor_20230517; billing collection cancels the timing table and changes it to an index type table; optimize the billing logic and bill by the hour; optimize the use of gonanoid to generate 12-digit bill id; payment crd adds the PaymentMethod field, which is used to identify wechat or other billing methods in the future. * add resources controller workflow fix payment controller panic error add resources controller cluster image workflow
- Loading branch information
Showing
81 changed files
with
6,113 additions
and
752 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* | ||
Copyright 2023. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package v1 | ||
|
||
import ( | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
||
// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN! | ||
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized. | ||
|
||
// BillingRecordQuerySpec defines the desired state of BillingRecordQuery | ||
type BillingRecordQuerySpec struct { | ||
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster | ||
// Important: Run "make" to regenerate code after modifying this file | ||
Page int `json:"page"` | ||
PageSize int `json:"pageSize"` | ||
StartTime metav1.Time `json:"startTime"` | ||
EndTime metav1.Time `json:"endTime"` | ||
OrderID string `json:"orderID,omitempty"` | ||
Type Type `json:"type"` | ||
} | ||
|
||
// BillingRecordQueryStatus defines the observed state of BillingRecordQuery | ||
type BillingRecordQueryStatus struct { | ||
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster | ||
// Important: Run "make" to regenerate code after modifying this file | ||
PageLength int `json:"pageLength"` | ||
RechargeAmount int64 `json:"rechargeAmount"` | ||
DeductionAmount Costs `json:"deductionAmount,omitempty"` | ||
Items []AccountBalanceSpec `json:"item,omitempty"` | ||
} | ||
|
||
//+kubebuilder:object:root=true | ||
//+kubebuilder:subresource:status | ||
|
||
// BillingRecordQuery is the Schema for the billingrecordqueries API | ||
type BillingRecordQuery struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ObjectMeta `json:"metadata,omitempty"` | ||
|
||
Spec BillingRecordQuerySpec `json:"spec,omitempty"` | ||
Status BillingRecordQueryStatus `json:"status,omitempty"` | ||
} | ||
|
||
//+kubebuilder:object:root=true | ||
|
||
// BillingRecordQueryList contains a list of BillingRecordQuery | ||
type BillingRecordQueryList struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ListMeta `json:"metadata,omitempty"` | ||
Items []BillingRecordQuery `json:"items"` | ||
} | ||
|
||
func init() { | ||
SchemeBuilder.Register(&BillingRecordQuery{}, &BillingRecordQueryList{}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
Copyright 2023. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package v1 | ||
|
||
import ( | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
||
// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN! | ||
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized. | ||
|
||
// PriceQuerySpec defines the desired state of PriceQuery | ||
type PriceQuerySpec struct { | ||
} | ||
|
||
// PriceQueryStatus defines the observed state of PriceQuery | ||
type PriceQueryStatus struct { | ||
BillingRecords []BillingRecord `json:"billingRecords,omitempty"` | ||
} | ||
|
||
type BillingRecord struct { | ||
ResourceType string `json:"resourceType"` | ||
Price int64 `json:"price"` | ||
DiscountType string `json:"discountType,omitempty"` | ||
} | ||
|
||
//+kubebuilder:object:root=true | ||
//+kubebuilder:subresource:status | ||
|
||
// PriceQuery is the Schema for the pricequeries API | ||
type PriceQuery struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ObjectMeta `json:"metadata,omitempty"` | ||
|
||
Spec PriceQuerySpec `json:"spec,omitempty"` | ||
Status PriceQueryStatus `json:"status,omitempty"` | ||
} | ||
|
||
//+kubebuilder:object:root=true | ||
|
||
// PriceQueryList contains a list of PriceQuery | ||
type PriceQueryList struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ListMeta `json:"metadata,omitempty"` | ||
Items []PriceQuery `json:"items"` | ||
} | ||
|
||
func init() { | ||
SchemeBuilder.Register(&PriceQuery{}, &PriceQueryList{}) | ||
} |
Oops, something went wrong.