0

I have a script that sets up an EKS cluster with additional helpful services. One of this is to install the RDS controller kit (ACK) to spin up Aurora databases. However, sometimes when I run this script, the dbcluster custom resource runs into a problem where only one subnet is in the subnet group it's told to use.

I'm using the instructions for installing the RDS ECK helm chart using the instructions on the AWS website.

echo "Setting up RDS controller"                                                                                                                                                                  
EKS_VPC_ID=$(aws eks describe-cluster --name "${CLUSTER_NAME}" --query "cluster.resourcesVpcConfig.vpcId" --output text)                                                                          
RDS_SUBNET_GROUP_NAME="sng-${CLUSTER_NAME}"                                                                                                                                                       
RDS_SUBNET_GROUP_DESCRIPTION="RDS subnet group for EKS ${CLUSTER_NAME}"                                                                                                                           
EKS_SUBNET_IDS=$(aws ec2 describe-subnets --filter "Name=vpc-id,Values=${EKS_VPC_ID}" --query 'Subnets[?MapPublicIpOnLaunch==`false`].SubnetId' --output text)                                    
RDS_NAMESPACE="${ACK_K8S_NAMESPACE}"                                                                                                                                                              
RDS_SNG_FILE="/tmp/$(date +%Y%m%d%H%M%S)-${RDS_NAMESPACE}-$$.yaml"                                                                                                                                
cat > "$RDS_SNG_FILE" << EOF                                                                                                                                                                      
apiVersion: rds.services.k8s.aws/v1alpha1                                                                                                                                                         
kind: DBSubnetGroup                                                                                                                                                                               
metadata:                                                                                                                                                                                         
 name: ${RDS_SUBNET_GROUP_NAME}                                                                                                                                                                   
 namespace: ${RDS_NAMESPACE}                                                                                                                                                                      
spec:                                                                                                                                                                                             
 name: ${RDS_SUBNET_GROUP_NAME}                                                                                                                                                                   
 description: ${RDS_SUBNET_GROUP_DESCRIPTION}                                                                                                                                                     
 subnetIDs:                                                                                                                                                                                       
$(printf " - %s\n" ${EKS_SUBNET_IDS})                                                                                                                                                             
 tags: []                                                                                                                                                                                         
EOF                                                                                                                                                                                               

(This code is essentially copy-pasted from https://aws-controllers-k8s.github.io/community/docs/tutorials/rds-example/#install-the-ack-service-controller-for-rds )

Sometimes, EKS_SUBNET_IDS come up with only one subnet. However, running aws ec2 describe-subnets --filter "Name=vpc-id,Values=${EKS_VPC_ID}" --query 'Subnets[?MapPublicIpOnLaunch==false].SubnetId' --output text again will typically show two subnets.

What could be the cause of this? I'm pretty sure the two subnets are already in the VPC, because the cluster has already been created with the two AZ subnets ...

When debugging this, looking at the dbsubnetgroup CRD in kubernetes, I run into an interesting reasource:

arn: arn:aws:rds:us-west-2:654654xxxxxx:subgrp:sng-jwatte-cluster

When I list this in the AWS CLI, I also see two subnets:

        {
            "DBSubnetGroupName": "sng-jwatte-cluster",
            "DBSubnetGroupDescription": "RDS subnet group for EKS jwatte-cluster",
            "VpcId": "vpc-09c2f1542e2xxxxxx",
            "SubnetGroupStatus": "Complete",
            "Subnets": [
                {
                    "SubnetIdentifier": "subnet-00591d77694xxxxxx",
                    "SubnetAvailabilityZone": {
                        "Name": "us-west-2c"
                    },
                    "SubnetOutpost": {},
                    "SubnetStatus": "Active"
                },
                {
                    "SubnetIdentifier": "subnet-0b7fdeaece9xxxxxx",
                    "SubnetAvailabilityZone": {
                        "Name": "us-west-2d"
                    },
                    "SubnetOutpost": {},
                    "SubnetStatus": "Active"
                }
            ],
            "DBSubnetGroupArn": "arn:aws:rds:us-west-2:654654xxxxxx:subgrp:sng-jwatte-cluster",
            "SupportedNetworkTypes": []
        }

0

You must log in to answer this question.

Browse other questions tagged .