diff --git a/providers/alicloud/README.md b/providers/alicloud/README.md index 68f0acba0..6d0796bc5 100644 --- a/providers/alicloud/README.md +++ b/providers/alicloud/README.md @@ -53,5 +53,5 @@ spec: Alibaba Cloud serverless kubernetes allows you to quickly create kubernetes container applications without having to manage and maintain clusters and servers. It is based on ECI and fully compatible with the Kuberentes API. -You can find more infomation via [alibaba cloud serverless kubernetes product doc](https://www.alibabacloud.com/help/doc-detail/71479.htm) +You can find more infomation via [alibaba cloud serverless kubernetes product doc](https://www.alibabacloud.com/help/doc-detail/94078.htm) diff --git a/providers/alicloud/config.go b/providers/alicloud/config.go index 5cf294b72..92c26d709 100644 --- a/providers/alicloud/config.go +++ b/providers/alicloud/config.go @@ -15,6 +15,7 @@ type providerConfig struct { Pods string VSwitch string SecureGroup string + ClusterName string } func (p *ECIProvider) loadConfig(r io.Reader) error { @@ -47,5 +48,9 @@ func (p *ECIProvider) loadConfig(r io.Reader) error { if p.operatingSystem == "" { p.operatingSystem = providers.OperatingSystemLinux } + p.clusterName = config.ClusterName + if p.clusterName == "" { + p.clusterName = "default" + } return nil } diff --git a/providers/alicloud/eci.go b/providers/alicloud/eci.go index e090f1a89..ef396171c 100644 --- a/providers/alicloud/eci.go +++ b/providers/alicloud/eci.go @@ -42,6 +42,7 @@ type ECIProvider struct { region string nodeName string operatingSystem string + clusterName string cpu string memory string pods string @@ -101,7 +102,12 @@ func NewECIProvider(config string, rm *manager.ResourceManager, nodeName, operat return nil, err } } - + if r := os.Getenv("ECI_CLUSTER_NAME"); r != "" { + p.clusterName = r + } + if p.clusterName == "" { + p.clusterName = "default" + } if r := os.Getenv("ECI_REGION"); r != "" { p.region = r } @@ -204,10 +210,10 @@ func (p *ECIProvider) CreatePod(ctx context.Context, pod *v1.Pod) error { request.ImageRegistryCredentials = creds CreationTimestamp := pod.CreationTimestamp.UTC().Format(podTagTimeFormat) tags := []eci.Tag{ - eci.Tag{Key: "PodName", Value: pod.Name}, - eci.Tag{Key: "ClusterName", Value: pod.ClusterName}, - eci.Tag{Key: "NodeName", Value: pod.Spec.NodeName}, + eci.Tag{Key: "ClusterName", Value: p.clusterName}, + eci.Tag{Key: "NodeName", Value: p.nodeName}, eci.Tag{Key: "NameSpace", Value: pod.Namespace}, + eci.Tag{Key: "PodName", Value: pod.Name}, eci.Tag{Key: "UID", Value: string(pod.UID)}, eci.Tag{Key: "CreationTimestamp", Value: CreationTimestamp}, } @@ -347,6 +353,13 @@ func (p *ECIProvider) GetCgs() []eci.ContainerGroup { if getECITagValue(&cg, "NodeName") != p.nodeName { continue } + cn := getECITagValue(&cg, "ClusterName") + if cn == "" { + cn = "default" + } + if cn != p.clusterName { + continue + } cgs = append(cgs, cg) } if request.NextToken == "" { @@ -771,7 +784,7 @@ func containerGroupToPod(cg *eci.ContainerGroup) (*v1.Pod, error) { Message: "", Reason: "", HostIP: "", - PodIP: cg.InternetIp, + PodIP: cg.IntranetIp, StartTime: &containerStartTime, ContainerStatuses: containerStatuses, }, diff --git a/providers/alicloud/eci.toml b/providers/alicloud/eci.toml index acb3090e6..f37ae378b 100644 --- a/providers/alicloud/eci.toml +++ b/providers/alicloud/eci.toml @@ -3,3 +3,4 @@ OperatingSystem = "Linux" CPU = "20" Memory = "100Gi" Pods = "20" +ClusterName = "default"