feat: refactor metering ,support Third-party resource access and idempotent (#2258)

* feat:design metering、podresource、resource api type
* metering watch user ns and create
* feat:add e2e test about metering watch ns
* feat:metering watch extensionResourcePrice
* feat:pod-controller create resurce CR logic
* feat:metering watch Resource create by resource-Controller and update Metering
* feat:metering create AccountBalance and account will watch it and deduction balancde
* feat:add infra calculate test
* feat:add deploy.yaml and temporary ci
* feat:change account ns to sealos-system
* fix:update resourceName
* feat:add deduction info to account chargelist
* fix:payment error
* fix:update resource name
* Modify inappropriate places in the code by github Comment

Signed-off-by: 晓杰 <2561589453@qq.com>
This commit is contained in:
晓杰
2022-12-29 14:43:06 +08:00
committed by GitHub
parent c0d082cce5
commit fd8ae0dfd6
72 changed files with 3970 additions and 374 deletions
+29
View File
@@ -0,0 +1,29 @@
// Copyright © 2022 sealos.
//
// 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 metering
import (
"context"
"sigs.k8s.io/controller-runtime/pkg/client"
)
type ResourceControllerInterface interface {
// CreateOrUpdateExtensionResourcesPrice need to create a ExtensionResourcesPrice to make metering-quota know this resource
CreateOrUpdateExtensionResourcesPrice(ctx context.Context, obj client.Object) error
// UpdateResourceUsed update metering-quota resource used
UpdateResourceUsed(ctx context.Context, obj client.Object) error
}