Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ func (ua *UpdateAction) modifyNodeGroupLaunchTemplate(group *cmproto.NodeGroup)
}

// modifyNodeGroupNodeTemplate nodeTemplate field
func (ua *UpdateAction) modifyNodeGroupNodeTemplate(group *cmproto.NodeGroup) {
func (ua *UpdateAction) modifyNodeGroupNodeTemplate(group *cmproto.NodeGroup) { // nolint
if ua.req.NodeTemplate != nil {
if group.NodeTemplate == nil {
group.NodeTemplate = &cmproto.NodeTemplate{}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -472,8 +472,8 @@ func GetClusterExternalNodeScript(ctx context.Context, info *cloudprovider.Cloud

// GenerateNTAddExistedInstanceReq 生成上架节点请求. 节点模板抽象理论上需要用户保证节点配置高度一致, 若用户配置了多盘挂载,
// 则使用用户配置选项若没有配置节点模板 或者 节点模板没有配置多盘选项, 则需要自动进行多盘挂载
func GenerateNTAddExistedInstanceReq(ctx context.Context, info *cloudprovider.CloudDependBasicInfo, nodeIDs, nodeIPs []string,
passwd, operator string, options *NodeAdvancedOptions) *api.AddExistedInstanceReq {
func GenerateNTAddExistedInstanceReq(ctx context.Context, info *cloudprovider.CloudDependBasicInfo, nodeIDs,
nodeIPs []string, passwd, operator string, options *NodeAdvancedOptions) *api.AddExistedInstanceReq {
req := &api.AddExistedInstanceReq{
ClusterID: info.Cluster.SystemID,
InstanceIDs: nodeIDs,
Expand Down Expand Up @@ -530,8 +530,8 @@ func GenerateNTAddExistedInstanceReq(ctx context.Context, info *cloudprovider.Cl
}

// genGpuAdvSettingOverride 生成GPU节点的节点定制化高级配置
func genGpuAdvSettingOverride(req *api.AddExistedInstanceReq, info *cloudprovider.CloudDependBasicInfo, nodeIDs, nodeIPs []string,
operator string, options *NodeAdvancedOptions, gpuNodeTemplate *proto.NodeTemplate) {
func genGpuAdvSettingOverride(req *api.AddExistedInstanceReq, info *cloudprovider.CloudDependBasicInfo, nodeIDs,
nodeIPs []string, operator string, options *NodeAdvancedOptions, gpuNodeTemplate *proto.NodeTemplate) {
// 未使用节点模板 或者 节点模板未配置磁盘格式化
if info.NodeTemplate == nil || len(info.NodeTemplate.DataDisks) == 0 {
// 使用默认配置, 主要解决CVM多盘挂载问题
Expand Down Expand Up @@ -568,7 +568,8 @@ func genGpuAdvSettingOverride(req *api.AddExistedInstanceReq, info *cloudprovide
}

// gpuNodeTemplatesMapByNodeIDs get gpuNodeTemplatesMap by nodeIDs, map key: nodeId, value: gpuNodeTemplate
func getGPUNodeTemplatesMapByNodeIDs(nodeIDs []string, cmOption *cloudprovider.CommonOption) (map[string]*proto.NodeTemplate, error) {
func getGPUNodeTemplatesMapByNodeIDs(nodeIDs []string, cmOption *cloudprovider.CommonOption) (
map[string]*proto.NodeTemplate, error) {
gpuNodeTemplates := make(map[string]*proto.NodeTemplate)
nodes, err := TransInstanceIDsToNodes(nodeIDs, &cloudprovider.ListNodesOption{
Common: cmOption,
Expand Down Expand Up @@ -671,8 +672,9 @@ func skipValidateOption(cls *proto.Cluster) []string {
}

// GenerateGPUAddExistedInstanceReqs generate gpu add existed instance request
func GenerateGPUAddExistedInstanceReqs(ctx context.Context, info *cloudprovider.CloudDependBasicInfo, nodeIDs, nodeIPs []string,
idToIP map[string]string, passwd, operator string, options *NodeAdvancedOptions) []*api.AddExistedInstanceReq {
func GenerateGPUAddExistedInstanceReqs(ctx context.Context, info *cloudprovider.CloudDependBasicInfo,
nodeIDs, nodeIPs []string, idToIP map[string]string, passwd, operator string,
options *NodeAdvancedOptions) []*api.AddExistedInstanceReq {
taskID, stepName := cloudprovider.GetTaskIDAndStepNameFromContext(ctx)

reqs := make([]*api.AddExistedInstanceReq, 0)
Expand Down Expand Up @@ -728,8 +730,8 @@ func GenerateGPUAddExistedInstanceReqs(ctx context.Context, info *cloudprovider.
// NodeGroup生成上架节点请求, 解决多盘问题主要取决于用户是否配置 多盘挂载, 类比于qcloud产品

// GenerateNGAddExistedInstanceReq xxx
func GenerateNGAddExistedInstanceReq(ctx context.Context, info *cloudprovider.CloudDependBasicInfo, nodeIDs, nodeIPs []string,
passwd, operator string, options *NodeAdvancedOptions) *api.AddExistedInstanceReq {
func GenerateNGAddExistedInstanceReq(ctx context.Context, info *cloudprovider.CloudDependBasicInfo, nodeIDs,
nodeIPs []string, passwd, operator string, options *NodeAdvancedOptions) *api.AddExistedInstanceReq {
req := &api.AddExistedInstanceReq{
ClusterID: info.Cluster.SystemID,
InstanceIDs: nodeIDs,
Expand Down Expand Up @@ -767,7 +769,7 @@ func generateGpuInfoInNGReq(ctx context.Context, req *api.AddExistedInstanceReq,
isGpuNode := true
for _, node := range nodes {
if !node.GetIsGpuNode() {
isGpuNode = false
isGpuNode = false // nolint
return
}
}
Expand Down Expand Up @@ -1063,7 +1065,7 @@ type AddExistedInstanceResult struct {
}

// AddNodesToCluster add nodes to cluster and return nodes result
func AddNodesToCluster(ctx context.Context, info *cloudprovider.CloudDependBasicInfo, options *NodeAdvancedOptions,
func AddNodesToCluster(ctx context.Context, info *cloudprovider.CloudDependBasicInfo, options *NodeAdvancedOptions, // nolint
nodeIDs []string, passwd string, isNodeGroup bool, idToIP map[string]string,
operator string) (*AddExistedInstanceResult, error) {
taskID, stepName := cloudprovider.GetTaskIDAndStepNameFromContext(ctx)
Expand Down Expand Up @@ -1100,7 +1102,7 @@ func AddNodesToCluster(ctx context.Context, info *cloudprovider.CloudDependBasic
}
}

if addInstanceReqs == nil || len(addInstanceReqs) == 0 {
if len(addInstanceReqs) == 0 {
return nil, fmt.Errorf("AddNodesToCluster[%s] addInstanceReqs is empty", taskID)
}

Expand Down Expand Up @@ -1178,7 +1180,8 @@ type gpuNodesInfo struct {
}

// getImagesToGpuNodesInfoMap get gpu nodes info map
func getImagesToGpuNodesInfoMap(nodeIds []string, info *cloudprovider.CloudDependBasicInfo) (map[string]*gpuNodesInfo, error) {
func getImagesToGpuNodesInfoMap(nodeIds []string, info *cloudprovider.CloudDependBasicInfo) (
map[string]*gpuNodesInfo, error) {
imageToGpuNodesInfo := make(map[string]*gpuNodesInfo)
gpuNodeTemplatesMap, err := getGPUNodeTemplatesMapByNodeIDs(nodeIds, info.CmOption)
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ const (

tableName = "nodetemplate"
// ProjectIDKey xxx
ProjectIDKey = "projectid"
templateIDKey = "nodetemplateid"
ProjectIDKey = "projectid"
templateIDKey = "nodetemplateid"
// NameKey xxx
NameKey = "name"
defaultCloudAccountListLength = 4000
)
Expand Down
3 changes: 0 additions & 3 deletions bcs-services/bcs-platform-manager/cmd/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (

"github.com/Tencent/bk-bcs/bcs-services/bcs-platform-manager/pkg/api"
"github.com/Tencent/bk-bcs/bcs-services/bcs-platform-manager/pkg/component"
"github.com/Tencent/bk-bcs/bcs-services/bcs-platform-manager/pkg/component/bcs"
"github.com/Tencent/bk-bcs/bcs-services/bcs-platform-manager/pkg/config"
"github.com/Tencent/bk-bcs/bcs-services/bcs-platform-manager/pkg/discovery"
"github.com/Tencent/bk-bcs/bcs-services/bcs-platform-manager/pkg/storage"
Expand Down Expand Up @@ -81,7 +80,5 @@ func runAPIServer(ctx context.Context, g *run.Group, opt *option) error {
g.Add(server.Run, func(err error) { _ = server.Close(); component.GetAuditClient().Close() })
g.Add(sd.Run, func(error) {})

bcs.CacheListClusters()

return nil
}
74 changes: 62 additions & 12 deletions bcs-services/bcs-platform-manager/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@ module github.com/Tencent/bk-bcs/bcs-services/bcs-platform-manager

go 1.23.0

replace (
configcenter => github.com/Tencent/bk-cmdb v0.0.0-20220923072424-595387cbc3cb
k8s.io/client-go => k8s.io/client-go v0.32.2
)

require (
configcenter v0.0.0-00010101000000-000000000000
github.com/Tencent/bk-bcs/bcs-common v0.0.0-20250729093702-993155773a94
github.com/Tencent/bk-bcs/bcs-services/pkg v0.0.0-20250729093702-993155773a94
github.com/dustin/go-humanize v1.0.1
Expand All @@ -19,16 +25,16 @@ require (
github.com/google/uuid v1.6.0
github.com/mitchellh/go-homedir v1.1.0
github.com/oklog/run v1.1.0
github.com/parnurzeal/gorequest v0.2.16
github.com/patrickmn/go-cache v2.1.0+incompatible
github.com/pkg/errors v0.9.1
github.com/prometheus/prometheus v1.8.2-0.20220308163432-03831554a519
github.com/spf13/cobra v1.9.1
github.com/spf13/viper v1.20.1
github.com/stretchr/testify v1.10.0
github.com/swaggo/http-swagger v1.3.4
go-micro.dev/v4 v4.10.2
go.mongodb.org/mongo-driver v1.17.4
go.opentelemetry.io/contrib/instrumentation/go.mongodb.org/mongo-driver/mongo/otelmongo v0.62.0
go.mongodb.org/mongo-driver v1.9.1
go.opentelemetry.io/contrib/instrumentation/go.mongodb.org/mongo-driver/mongo/otelmongo v0.33.0
go.opentelemetry.io/otel v1.37.0
go.opentelemetry.io/otel/trace v1.37.0
google.golang.org/grpc v1.74.2
Expand All @@ -40,79 +46,103 @@ require (
github.com/KyleBanks/depth v1.2.1 // indirect
github.com/Microsoft/go-winio v0.6.1 // indirect
github.com/ProtonMail/go-crypto v1.1.3 // indirect
github.com/Tencent/bk-bcs/bcs-runtime/bcs-k8s/kubernetes/common v0.0.0-20220330120237-0bbed74dcf6d // indirect
github.com/TencentBlueKing/bk-audit-go-sdk v0.0.6 // indirect
github.com/TencentBlueKing/gopkg v1.1.0 // indirect
github.com/TencentBlueKing/iam-go-sdk v0.1.6 // indirect
github.com/ajg/form v1.5.1 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bitly/go-simplejson v0.5.0 // indirect
github.com/bytedance/sonic v1.9.1 // indirect
github.com/cenkalti/backoff/v5 v5.0.3 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect
github.com/cloudflare/circl v1.3.7 // indirect
github.com/coccyx/timeparser v0.0.0-20161029180942-5644122b3667 // indirect
github.com/coreos/go-semver v0.3.0 // indirect
github.com/coreos/go-systemd/v22 v22.3.2 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.6 // indirect
github.com/cyphar/filepath-securejoin v0.2.5 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
github.com/emirpasic/gods v1.18.1 // indirect
github.com/envoyproxy/protoc-gen-validate v1.2.1 // indirect
github.com/evanphx/json-patch/v5 v5.6.0 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/fsnotify/fsnotify v1.9.0 // indirect
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.8 // indirect
github.com/ggicci/owl v0.8.2 // indirect
github.com/gin-gonic/gin v1.9.1 // indirect
github.com/go-acme/lego/v4 v4.4.0 // indirect
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect
github.com/go-git/go-billy/v5 v5.6.0 // indirect
github.com/go-git/go-git/v5 v5.13.0 // indirect
github.com/go-logr/logr v1.4.3 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-openapi/jsonpointer v0.19.5 // indirect
github.com/go-openapi/jsonreference v0.20.0 // indirect
github.com/go-openapi/jsonpointer v0.21.0 // indirect
github.com/go-openapi/jsonreference v0.20.2 // indirect
github.com/go-openapi/spec v0.20.9 // indirect
github.com/go-openapi/swag v0.21.1 // indirect
github.com/go-openapi/swag v0.23.0 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-sql-driver/mysql v1.7.1 // indirect
github.com/go-stack/stack v1.8.0 // indirect
github.com/gobwas/httphead v0.1.0 // indirect
github.com/gobwas/pool v0.2.1 // indirect
github.com/gobwas/ws v1.2.1 // indirect
github.com/goccy/go-json v0.10.2 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang-migrate/migrate/v4 v4.17.0 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/golang/snappy v1.0.0 // indirect
github.com/google/gnostic-models v0.6.8 // indirect
github.com/google/go-cmp v0.7.0 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/gorilla/handlers v1.5.1 // indirect
github.com/grpc-ecosystem/grpc-gateway v1.16.0 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.1 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/imdario/mergo v0.3.13 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/joyt/godate v0.0.0-20150226210126-7151572574a7 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/juju/ratelimit v1.0.1 // indirect
github.com/kevinburke/ssh_config v1.2.0 // indirect
github.com/klauspost/compress v1.18.0 // indirect
github.com/klauspost/cpuid/v2 v2.2.4 // indirect
github.com/labstack/echo/v4 v4.13.4 // indirect
github.com/labstack/gommon v0.4.2 // indirect
github.com/leodido/go-urn v1.4.0 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattbaird/jsonpatch v0.0.0-20200820163806-098863c1fc24 // indirect
github.com/mattn/go-colorable v0.1.14 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/miekg/dns v1.1.50 // indirect
github.com/mitchellh/hashstructure v1.1.0 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/montanaflynn/stats v0.7.1 // indirect
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/nxadm/tail v1.4.8 // indirect
github.com/openzipkin/zipkin-go v0.4.3 // indirect
github.com/oxtoacart/bpool v0.0.0-20190530202638-03653db5a59c // indirect
github.com/parnurzeal/gorequest v0.2.16 // indirect
github.com/pelletier/go-toml/v2 v2.2.3 // indirect
github.com/pjbgf/sha1cd v0.3.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_golang v1.19.0 // indirect
github.com/prometheus/client_model v0.5.0 // indirect
github.com/prometheus/common v0.48.0 // indirect
github.com/prometheus/procfs v0.12.0 // indirect
github.com/rs/xid v1.4.0 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/sagikazarmark/locafero v0.7.0 // indirect
github.com/samuel/go-zookeeper v0.0.0-20201211165307-7117e9ea2414 // indirect
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/skeema/knownhosts v1.3.0 // indirect
Expand All @@ -124,10 +154,15 @@ require (
github.com/subosito/gotenv v1.6.0 // indirect
github.com/swaggo/files v0.0.0-20220610200504-28940afbdbfe // indirect
github.com/swaggo/swag v1.8.1 // indirect
github.com/tidwall/gjson v1.14.1 // indirect
github.com/tidwall/match v1.1.1 // indirect
github.com/tidwall/pretty v1.2.0 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/ugorji/go/codec v1.2.12 // indirect
github.com/urfave/cli/v2 v2.8.1 // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/valyala/fasttemplate v1.2.2 // indirect
github.com/x448/float16 v0.8.4 // indirect
github.com/xanzy/ssh-agent v0.3.3 // indirect
github.com/xdg-go/pbkdf2 v1.0.0 // indirect
github.com/xdg-go/scram v1.1.2 // indirect
Expand All @@ -149,19 +184,34 @@ require (
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/multierr v1.9.0 // indirect
go.uber.org/zap v1.24.0 // indirect
golang.org/x/arch v0.3.0 // indirect
golang.org/x/crypto v0.40.0 // indirect
golang.org/x/mod v0.25.0 // indirect
golang.org/x/net v0.42.0 // indirect
golang.org/x/oauth2 v0.30.0 // indirect
golang.org/x/sync v0.16.0 // indirect
golang.org/x/sys v0.34.0 // indirect
golang.org/x/term v0.33.0 // indirect
golang.org/x/text v0.27.0 // indirect
golang.org/x/time v0.11.0 // indirect
golang.org/x/tools v0.34.0 // indirect
google.golang.org/genproto v0.0.0-20241118233622-e639e219e697 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20250728155136-f173205681a0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20250728155136-f173205681a0 // indirect
google.golang.org/protobuf v1.36.6 // indirect
gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
gopkg.in/warnings.v0 v0.1.2 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
k8s.io/klog/v2 v2.100.1 // indirect
k8s.io/api v0.32.2 // indirect
k8s.io/apimachinery v0.32.2 // indirect
k8s.io/client-go v0.24.2 // indirect
k8s.io/klog v1.0.0 // indirect
k8s.io/klog/v2 v2.130.1 // indirect
k8s.io/kube-openapi v0.0.0-20241105132330-32ad38e42d3f // indirect
k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 // indirect
moul.io/http2curl v1.0.0 // indirect
sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.4.2 // indirect
sigs.k8s.io/yaml v1.4.0 // indirect
)
Original file line number Diff line number Diff line change
Expand Up @@ -10,37 +10,43 @@
* limitations under the License.
*/

// Package pod pod operate
package pod
// Package cloudvpc cloudvpc operate
package cloudvpc

import (
"context"

"github.com/Tencent/bk-bcs/bcs-services/bcs-platform-manager/pkg/storage"
"github.com/Tencent/bk-bcs/bcs-services/bcs-platform-manager/pkg/storage/entity"
"github.com/Tencent/bk-bcs/bcs-common/pkg/bcsapi/clustermanager"

clustermgr "github.com/Tencent/bk-bcs/bcs-services/bcs-platform-manager/pkg/component/bcs/clustermanager"
)

// SampleRequset 示例请求
type SampleRequset struct {
ProjectId string `json:"projectId" in:"path=projectId" validate:"required"`
ClusterId string `json:"clusterId" in:"path=clusterId" validate:"required"`
}
// CreateCloudVPC 创建VPC
// @Summary 创建VPC
// @Tags Logs
// @Produce json
// @Success 200 {array} k8sclient.Container
// @Router /cloudvpc [post]
func CreateCloudVPC(ctx context.Context, req *clustermanager.CreateCloudVPCRequest) (*bool, error) {
result, err := clustermgr.CreateCloudVPC(ctx, req)
if err != nil {
return nil, err
}

// SampleResponse 示例响应
type SampleResponse struct {
Id string `json:"id"`
return &result, nil
}

// GetPodContainers 获取 Pod 容器列表
// @Summary 获取 Pod 容器列表
// UpdateCloudVPC 更新VPC
// @Summary 更新VPC
// @Tags Logs
// @Produce json
// @Success 200 {array} k8sclient.Container
// @Router /namespaces/:namespace/pods/:pod/containers [get]
func GetPodContainers(c context.Context, req *SampleRequset) (*entity.Audit, error) {
audit, err := storage.GlobalStorage.GetAudit(c, req.ProjectId, req.ClusterId)
// @Router /cloudvpc [put]
func UpdateCloudVPC(ctx context.Context, req *clustermanager.UpdateCloudVPCRequest) (*bool, error) {
result, err := clustermgr.UpdateCloudVPC(ctx, req)
if err != nil {
return nil, err
}
return audit, nil

return &result, nil
}
Loading
Loading