Selaa lähdekoodia

get subnet information correctly for EKS cluster

Mohammed Nafees 3 vuotta sitten
vanhempi
sitoutus
db0da3d124

+ 11 - 1
api/server/handlers/cluster_integration/aws/get_cluster_info.go

@@ -90,7 +90,14 @@ func (c *GetClusterInfoHandler) ServeHTTP(w http.ResponseWriter, r *http.Request
 	ec2Svc := ec2.New(awsSession, awsConf)
 
 	subnetsInfo, err := ec2Svc.DescribeSubnets(&ec2.DescribeSubnetsInput{
-		SubnetIds: clusterInfo.Cluster.ResourcesVpcConfig.SubnetIds,
+		Filters: []*ec2.Filter{
+			{
+				Name: aws.String("vpc-id"),
+				Values: []*string{
+					clusterInfo.Cluster.ResourcesVpcConfig.VpcId,
+				},
+			},
+		},
 	})
 
 	if err != nil || len(subnetsInfo.Subnets) == 0 {
@@ -100,12 +107,15 @@ func (c *GetClusterInfoHandler) ServeHTTP(w http.ResponseWriter, r *http.Request
 
 	res := &types.GetAWSClusterInfoResponse{
 		Name:       clusterName,
+		ARN:        *clusterInfo.Cluster.Arn,
+		Status:     *clusterInfo.Cluster.Status,
 		K8sVersion: *clusterInfo.Cluster.Version,
 		EKSVersion: *clusterInfo.Cluster.PlatformVersion,
 	}
 
 	for _, subnet := range subnetsInfo.Subnets {
 		res.Subnets = append(res.Subnets, &types.AWSSubnet{
+			SubnetID:                *subnet.SubnetId,
 			AvailabilityZone:        *subnet.AvailabilityZone,
 			AvailableIPAddressCount: *subnet.AvailableIpAddressCount,
 		})

+ 3 - 0
api/types/cluster_integration.go

@@ -1,13 +1,16 @@
 package types
 
 type AWSSubnet struct {
+	SubnetID                string `json:"subnet_id"`
 	AvailabilityZone        string `json:"availability_zone"`
 	AvailableIPAddressCount int64  `json:"available_ip_address_count"`
 }
 
 type GetAWSClusterInfoResponse struct {
 	Name       string       `json:"name"`
+	ARN        string       `json:"arn"`
 	K8sVersion string       `json:"kubernetes_server_version"`
 	EKSVersion string       `json:"eks_version"`
+	Status     string       `json:"status"`
 	Subnets    []*AWSSubnet `json:"subnets"`
 }