Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rebase replace-with-etcd onto upstream latest main #1693

Merged
merged 14 commits into from
Jul 30, 2024
Merged
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
67 changes: 61 additions & 6 deletions assets/k8sclusterinfo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,66 @@
# <csp>: Name of the CSP
# nodegroupsWithCluster:
# version:
# - region: [region1, region2, all(special keyword)]
# - region: [region1, region2, common(special keyword: most of regions)]
#

k8scluster:
azure:
nodegroupsWithCluster: true
nodeImageDesignation: false
version:
- region: [westeurope,westus]
available:
- name: 1.29
id: 1.29.4
- name: 1.28
id: 1.28.9
- name: 1.27
id: 1.27.13
- region: [common]
available:
- name: 1.29
id: 1.29.5
- name: 1.28
id: 1.28.10
- name: 1.27
id: 1.27.14
rootDisk:
- region: [common]
type:
- name: default
id: default
size:
min: 10
max: 40
gcp:
nodegroupsWithCluster: true
nodeImageDesignation: true
version:
- region: [common]
available:
- name: 1.29
id: 1.29.6-gke.1038001
- name: 1.28
id: 1.28.11-gke.1019001
- name: 1.26
id: 1.27.14-gke.1059002
rootDisk:
- region: [common]
type:
- name: default
id: default
size:
min: 10
max: 40
alibaba:
nodegroupsWithCluster: false
nodeImageDesignation: true
version:
- region: [ap-northeast-1,ap-northeast-2,ap-southeast-1,ap-southeast-3,ap-southeast-5,us-west-1,us-east-1,eu-central-1,eu-west-1,cn-beijing,cn-hongkong,cn-shanghai,cn-huhehaote,cn-heyuan,cn-wulanchabu,cn-guangzhou]
# ServiceUnavailable or NotSupportedSLB
- region: [me-east-1, cn-zhangjiakou, cn-hangzhou, cn-shenzhen, cn-chengdu, ap-south-1, ap-sourtheast-2]
# ap-northeast-1,ap-northeast-2,ap-southeast-1,ap-southeast-3,ap-southeast-5,us-west-1,us-east-1,eu-central-1,eu-west-1,cn-beijing,cn-hongkong,cn-shanghai,cn-huhehaote,cn-heyuan,cn-wulanchabu,cn-guangzhou
- region: [common]
available:
- name: 1.30
id: 1.30.1-aliyun.1
Expand All @@ -21,7 +74,7 @@ k8scluster:
- name: 1.26
id: 1.26.15-aliyun.1
rootDisk:
- region: [all]
- region: [common]
type:
- name: cloud_essd
id: cloud_essd
Expand All @@ -30,6 +83,7 @@ k8scluster:
max: 40
nhncloud:
nodegroupsWithCluster: true
nodeImageDesignation: true
version:
- region: [kr1, kr2]
available:
Expand All @@ -42,7 +96,7 @@ k8scluster:
- name: 1.26
id: v1.26.3
rootDisk:
- region: [all]
- region: [common]
type:
- name: default
id: default
Expand All @@ -51,8 +105,9 @@ k8scluster:
max: 40
tencent:
nodegroupsWithCluster: false
nodeImageDesignation: true
version:
- region: [all]
- region: [common]
available:
- name: 1.28
id: 1.28.3
Expand All @@ -61,7 +116,7 @@ k8scluster:
- name: 1.24
id: 1.24.4
rootDisk:
- region: [all]
- region: [common]
type:
- name: default
id: default
Expand Down
2 changes: 2 additions & 0 deletions src/core/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ const (
StrK8s string = "k8s"
StrKubernetes string = "kubernetes"
StrContainer string = "container"
StrCommon string = "common"
StrEmpty string = "empty"
StrDefaultResourceName string = "-systemdefault-"
// StrFirewallRule string = "firewallRule"

Expand Down
58 changes: 50 additions & 8 deletions src/core/common/utility.go
Original file line number Diff line number Diff line change
Expand Up @@ -1307,30 +1307,50 @@ func getK8sClusterDetail(providerName string) *K8sClusterDetail {
// GetAvailableK8sClusterVersion is func to get available kubernetes cluster versions for provider and region from K8sClusterInfo
func GetAvailableK8sClusterVersion(providerName string, regionName string) (*[]K8sClusterVersionDetailAvailable, error) {
//
// Check available K8sCluster version and node image in k8sclusterinfo.yaml
// Check available K8sCluster version in k8sclusterinfo.yaml
//

providerName = strings.ToLower(providerName)
regionName = strings.ToLower(regionName)

// Get K8sClusterDetail for providerName
k8sClusterDetail := getK8sClusterDetail(providerName)
if k8sClusterDetail == nil {
return nil, fmt.Errorf("unsupported provider(%s) for kubernetes cluster", providerName)
}

// Get Available Versions for regionName
// Check if 'regionName' exists
var availableVersion *[]K8sClusterVersionDetailAvailable = nil
for _, versionDetail := range k8sClusterDetail.Version {
for _, region := range versionDetail.Region {
region = strings.ToLower(region)
if region == "all" || region == regionName {
availableVersion = &versionDetail.Available
if strings.EqualFold(region, regionName) {
if len(versionDetail.Available) == 0 {
availableVersion = &[]K8sClusterVersionDetailAvailable{{StrEmpty, StrEmpty}}
} else {
availableVersion = &versionDetail.Available
}
return availableVersion, nil
}
}
}

// Check if 'common' exists
for _, versionDetail := range k8sClusterDetail.Version {
for _, region := range versionDetail.Region {
region = strings.ToLower(region)
if strings.EqualFold(region, StrCommon) {
if len(versionDetail.Available) == 0 {
availableVersion = &[]K8sClusterVersionDetailAvailable{{StrEmpty, StrEmpty}}
} else {
availableVersion = &versionDetail.Available
}
return availableVersion, nil
}
}
}

return nil, fmt.Errorf("no available kubernetes cluster version for provider(%s):region(%s)", providerName, regionName)
return nil, fmt.Errorf("no entry for provider(%s):region(%s)", providerName, regionName)
}

// GetAvailableK8sClusterNodeImage is func to get available kubernetes cluster node images for provider and region from K8sClusterInfo
Expand All @@ -1340,20 +1360,42 @@ func GetAvailableK8sClusterNodeImage(providerName string, regionName string) (*[
//

providerName = strings.ToLower(providerName)
regionName = strings.ToLower(regionName)

// Get K8sClusterDetail for providerName
k8sClusterDetail := getK8sClusterDetail(providerName)
if k8sClusterDetail == nil {
return nil, fmt.Errorf("unsupported provider(%s) for kubernetes cluster", providerName)
}

// Get Available Node Image for regionName
// Check if 'regionName' exists
var availableNodeImage *[]K8sClusterNodeImageDetailAvailable = nil
for _, nodeImageDetail := range k8sClusterDetail.NodeImage {
for _, region := range nodeImageDetail.Region {
region = strings.ToLower(region)
if region == "all" || region == regionName {
availableNodeImage = &nodeImageDetail.Available
if strings.EqualFold(region, regionName) {
if len(nodeImageDetail.Available) == 0 {
availableNodeImage = &[]K8sClusterNodeImageDetailAvailable{{StrEmpty, StrEmpty}}
break
} else {
availableNodeImage = &nodeImageDetail.Available
}
return availableNodeImage, nil
}
}
}

// Check if 'common' exists
for _, nodeImageDetail := range k8sClusterDetail.NodeImage {
for _, region := range nodeImageDetail.Region {
region = strings.ToLower(region)
if strings.EqualFold(region, StrCommon) {
if len(nodeImageDetail.Available) == 0 {
availableNodeImage = &[]K8sClusterNodeImageDetailAvailable{{StrEmpty, StrEmpty}}
break
} else {
availableNodeImage = &nodeImageDetail.Available
}
return availableNodeImage, nil
}
}
Expand Down
Loading