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
9 changes: 7 additions & 2 deletions bcs-services/bcs-cluster-manager/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ require (
github.com/gorilla/mux v1.8.0
github.com/gorilla/websocket v1.4.2
github.com/grpc-ecosystem/grpc-gateway v1.16.0
github.com/huaweicloud/huaweicloud-sdk-go-v3 v0.1.154
github.com/huaweicloud/huaweicloud-sdk-go-v3 v0.1.199
github.com/kirito41dd/xslice v0.0.1
github.com/leodido/go-urn v1.4.0 // indirect
github.com/parnurzeal/gorequest v0.2.16
Expand Down Expand Up @@ -117,6 +117,7 @@ require (
github.com/evanphx/json-patch v4.12.0+incompatible // indirect
github.com/evanphx/json-patch/v5 v5.5.0 // indirect
github.com/exponent-io/jsonpath v0.0.0-20151013193312-d6023ce2651d // indirect
github.com/fatih/color v1.10.0 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.3 // indirect
Expand All @@ -138,6 +139,7 @@ require (
github.com/gobwas/httphead v0.1.0 // indirect
github.com/gobwas/pool v0.2.1 // indirect
github.com/gobwas/ws v1.0.4 // indirect
github.com/goccy/go-yaml v1.9.8 // indirect
github.com/gofrs/flock v0.8.1 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang-jwt/jwt/v4 v4.5.0 // indirect
Expand Down Expand Up @@ -166,7 +168,7 @@ require (
github.com/jinzhu/now v1.1.5 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/json-iterator/go v1.1.13-0.20220915233716-71ac16282d12 // indirect
github.com/juju/ratelimit v1.0.1 // indirect
github.com/kelseyhightower/envconfig v1.4.0 // indirect
github.com/kevinburke/ssh_config v1.2.0 // indirect
Expand All @@ -175,6 +177,8 @@ require (
github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de // indirect
github.com/mailru/easyjson v0.7.6 // indirect
github.com/mattbaird/jsonpatch v0.0.0-20200820163806-098863c1fc24 // indirect
github.com/mattn/go-colorable v0.1.8 // indirect
github.com/mattn/go-isatty v0.0.19 // indirect
github.com/miekg/dns v1.1.50 // indirect
github.com/mitchellh/go-wordwrap v1.0.0 // indirect
github.com/mitchellh/hashstructure v1.1.0 // indirect
Expand Down Expand Up @@ -240,6 +244,7 @@ require (
golang.org/x/term v0.27.0 // indirect
golang.org/x/text v0.21.0 // indirect
golang.org/x/time v0.5.0 // indirect
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/genproto v0.0.0-20240123012728-ef4313101c80 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240318140521-94a12d6c2237 // indirect
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,8 @@ func (cli *CceClient) CreateKubernetesClusterCert(clsId string, duration int32)
request := &model.CreateKubernetesClusterCertRequest{
ClusterId: clsId,
}
request.Body = &model.CertDuration{
Duration: duration,
request.Body = &model.ClusterCertDuration{
Duration: &duration,
}

response, err := cli.cce.CreateKubernetesClusterCert(request)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,16 +293,17 @@ type PublicIp struct {
Enable bool
}

func GetChargeConfig(charge ChargePrepaid) (billingMode int32, periodType string, periodNum int32,
isAutoRenew string, isAutoPay string) {
func GetChargeConfig(charge ChargePrepaid) (billingMode model.NodeTemplateBillingMode, periodType string,
periodNum int32, isAutoRenew string, isAutoPay string) {
periodType = "month"
periodNum = 1
isAutoRenew = "false"
isAutoPay = "true"
billingMode = model.GetNodeTemplateBillingModeEnum().E_0

periodNum = int32(charge.Period)
if charge.ChargeType == icommon.PREPAID {
billingMode = 1
billingMode = model.GetNodeTemplateBillingModeEnum().E_1
if charge.Period >= 12 {
periodType = "year"
periodNum = int32(charge.Period / 12)
Expand All @@ -314,11 +315,11 @@ func GetChargeConfig(charge ChargePrepaid) (billingMode int32, periodType string
return
}

func GetPublicIp(publicIp PublicIp) *model.NodePublicIp {
func GetPublicIp(publicIp PublicIp) *model.NodeEipSpec {
if publicIp.Enable {
shareType := eipModel.GetCreatePublicipBandwidthOptionShareTypeEnum().PER.Value()
return &model.NodePublicIp{
Iptype: common.StringPtr("5_bgp"),
return &model.NodeEipSpec{
Iptype: "5_bgp",
Bandwidth: &model.NodeBandwidth{
Chargemode: func() *string {
if publicIp.ChangeType == ChargemodeBandwidth {
Expand Down Expand Up @@ -355,8 +356,9 @@ func GetRuntime(containerRuntime string) *model.Runtime {

func (req CreateNodePoolRequest) trans2NodePoolTemplate() *model.CreateNodePoolRequest {
var (
NodePoolSpecType = model.GetNodePoolSpecTypeEnum().VM
taints = Taint2ModelTaint(req.Spec.Template.Taints)
NodePoolSpecType = model.GetNodePoolSpecTypeEnum().VM
taints = Taint2ModelTaint(req.Spec.Template.Taints)
policyOnExistingNodes = "ignore"
)

dataVolumes, storageSelectors, storageGroups := GetDataVolumeAndStorgeConfig(req.Spec.Template.DataVolumes)
Expand All @@ -373,22 +375,22 @@ func (req CreateNodePoolRequest) trans2NodePoolTemplate() *model.CreateNodePoolR
},
Spec: &model.NodePoolSpec{
Type: &NodePoolSpecType,
NodeTemplate: &model.NodeSpec{
Flavor: req.Spec.Template.Flavor,
Az: req.Spec.Template.Az,
NodeTemplate: &model.NodeTemplate{
Flavor: &req.Spec.Template.Flavor,
Az: &req.Spec.Template.Az,
Os: &req.Spec.Template.Os,
Login: Login2ModelLogin(&req.Spec.Template.Login),
RootVolume: &model.Volume{
Size: req.Spec.Template.RootVolume.Size,
Volumetype: req.Spec.Template.RootVolume.VolumeType,
},
DataVolumes: dataVolumes,
DataVolumes: &dataVolumes,
Storage: &model.Storage{
StorageSelectors: storageSelectors,
StorageGroups: storageGroups,
},
BillingMode: &billingMode,
Taints: &taints,
Taints: taints,
K8sTags: req.Spec.Template.Labels,
Runtime: GetRuntime(req.Spec.Template.ContainerRuntime),
InitializedConditions: &[]string{
Expand Down Expand Up @@ -419,6 +421,9 @@ func (req CreateNodePoolRequest) trans2NodePoolTemplate() *model.CreateNodePoolR
}
return &securityIds
}(),
TaintPolicyOnExistingNodes: &policyOnExistingNodes,
LabelPolicyOnExistingNodes: &policyOnExistingNodes,
UserTagsPolicyOnExistingNodes: &policyOnExistingNodes,
},
},
}
Expand Down Expand Up @@ -477,7 +482,7 @@ func (un UpdateNodePoolRequest) trans2ModelUpdateNodePoolRequest(clsId string, n
}

nodePoolMeta := &model.NodePoolMetadataUpdate{
Name: un.Name,
Name: &un.Name,
}

nodeSpec := &model.NodeSpecUpdate{
Expand Down Expand Up @@ -533,7 +538,7 @@ type AddNodesRequest struct {
}

// Taint2ModelTaint trans taint
func Taint2ModelTaint(taints []v1.Taint) []model.Taint {
func Taint2ModelTaint(taints []v1.Taint) *[]model.Taint {
mTaints := make([]model.Taint, 0)

for i := range taints {
Expand All @@ -544,7 +549,7 @@ func Taint2ModelTaint(taints []v1.Taint) []model.Taint {
})
}

return mTaints
return &mTaints
}

// Login2ModelLogin trans login
Expand Down Expand Up @@ -601,7 +606,7 @@ func (ar AddNodesRequest) Trans2AddNodesRequest(clsId string, opt *cloudprovider
K8sOptions: func() *model.ReinstallK8sOptionsConfig {
return &model.ReinstallK8sOptionsConfig{
Labels: ar.Labels,
Taints: &taints,
Taints: taints,
MaxPods: &ar.MaxPods,
}
}(),
Expand Down Expand Up @@ -957,6 +962,7 @@ func (c *CreateClusterRequest) Trans2CreateClusterRequest() *model.CreateCluster
confOverName := "kube-apiserver"
confName := "support-overload"
var confValue interface{} = true
billingModeValue := billingMode.Value()

req := &model.CreateClusterRequest{
Body: &model.Cluster{
Expand All @@ -982,7 +988,7 @@ func (c *CreateClusterRequest) Trans2CreateClusterRequest() *model.CreateCluster
SecurityGroup: &c.Spec.SecurityGroupID,
},
ServiceNetwork: &model.ServiceNetwork{IPv4CIDR: &c.Spec.ServiceCidr},
BillingMode: &billingMode,
BillingMode: &billingModeValue,
ClusterTags: &clusterTags,
KubeProxyMode: func() *model.ClusterSpecKubeProxyMode {
proxyMode := model.GetClusterSpecKubeProxyModeEnum().IPTABLES
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,21 @@ func GenerateModifyClusterNodePoolInput(group *proto.NodeGroup, clusterID string
oldNodePool *model.NodePool) *model.UpdateNodePoolRequest {
// cce nodePool名称以小写字母开头,由小写字母、数字、中划线(-)组成,长度范围1-50位,且不能以中划线(-)结尾
name := strings.ToLower(group.NodeGroupID)
taints := make([]model.Taint, 0)
userTags := make([]model.UserTag, 0)

req := &model.UpdateNodePoolRequest{
NodepoolId: group.CloudNodeGroupID,
ClusterId: clusterID,
Body: &model.NodePoolUpdate{
Metadata: &model.NodePoolMetadataUpdate{
Name: name,
Name: &name,
},
Spec: &model.NodePoolSpecUpdate{
NodeTemplate: &model.NodeSpecUpdate{
Taints: make([]model.Taint, 0),
Taints: &taints,
K8sTags: map[string]string{},
UserTags: make([]model.UserTag, 0),
UserTags: &userTags,
},
//更新节点池不能更新节点数量,只能通过UpdateDesiredNodes方法更新,会影响互斥性
InitialNodeCount: *oldNodePool.Spec.InitialNodeCount,
Expand All @@ -81,7 +83,7 @@ func GenerateModifyClusterNodePoolInput(group *proto.NodeGroup, clusterID string
effect = model.GetTaintEffectEnum().NO_EXECUTE
}
value := v.Value
req.Body.Spec.NodeTemplate.Taints = append(req.Body.Spec.NodeTemplate.Taints, model.Taint{
*req.Body.Spec.NodeTemplate.Taints = append(*req.Body.Spec.NodeTemplate.Taints, model.Taint{
Key: v.Key,
Value: &value,
Effect: effect,
Expand All @@ -91,16 +93,16 @@ func GenerateModifyClusterNodePoolInput(group *proto.NodeGroup, clusterID string

req.Body.Spec.NodeTemplate.K8sTags = group.NodeTemplate.Labels

if len(req.Body.Spec.NodeTemplate.Taints) == 0 && oldNodePool.Spec.NodeTemplate.Taints != nil {
req.Body.Spec.NodeTemplate.Taints = *oldNodePool.Spec.NodeTemplate.Taints
if len(*req.Body.Spec.NodeTemplate.Taints) == 0 && oldNodePool.Spec.NodeTemplate.Taints != nil {
req.Body.Spec.NodeTemplate.Taints = oldNodePool.Spec.NodeTemplate.Taints
}

if len(req.Body.Spec.NodeTemplate.K8sTags) == 0 && oldNodePool.Spec.NodeTemplate.K8sTags != nil {
req.Body.Spec.NodeTemplate.K8sTags = oldNodePool.Spec.NodeTemplate.K8sTags
}

if len(req.Body.Spec.NodeTemplate.UserTags) == 0 && oldNodePool.Spec.NodeTemplate.UserTags != nil {
req.Body.Spec.NodeTemplate.UserTags = *oldNodePool.Spec.NodeTemplate.UserTags
if len(*req.Body.Spec.NodeTemplate.UserTags) == 0 && oldNodePool.Spec.NodeTemplate.UserTags != nil {
req.Body.Spec.NodeTemplate.UserTags = oldNodePool.Spec.NodeTemplate.UserTags
}

return req
Expand Down
Loading