CDK for setting ALB controller in EKS UPGRADE FAILED: another operation

Viewed 193

I have an application that needs to be deployed on EKS, and I'm having trouble setting up an ingress ALB.

I am using the following as a sample for how this should be set up. https://github.com/aws-samples/nexus-oss-on-aws/blob/d3a092d72041b65ca1c09d174818b513594d3e11/src/lib/sonatype-nexus3-stack.ts#L207-L242

It's in TypeScript and I'm converting it to Python. My code is as below.

from aws_cdk import (
    Stack,
    aws_eks as eks,
    aws_ec2 as ec2,
    aws_iam as iam,
    Duration
)
from constructs import Construct

class TestStack(Stack):

    def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None:
        super().__init__(scope, construct_id, **kwargs)

        vpc = ec2.Vpc(self, "test-vpc",
            vpc_name="test-vpc",
            cidr="10.0.0.0/16"
        )

        eks_role = iam.Role(
            self, 'test-eks-role',
            role_name = 'test-eks-role',
            assumed_by=iam.CompositePrincipal(
                iam.ServicePrincipal('eks.amazonaws.com')
            ),
            managed_policies=[iam.ManagedPolicy.from_aws_managed_policy_name('AmazonEKSClusterPolicy')],
        )

        cluster = eks.Cluster(
            self, "test-cluster",
            cluster_name="test-cluster",
            masters_role=eks_role,
            version=eks.KubernetesVersion.V1_21,
            vpc=vpc,
            vpc_subnets=[ec2.SubnetSelection(subnet_type=ec2.SubnetType.PRIVATE_WITH_NAT)]
        )
        
        alb_service_account = cluster.add_service_account(
            'test-cluster-service-account',
            name='test-cluster-service-account'
        )

        import requests

        alb_controller_url = 'https://raw.githubusercontent.com/kubernetes-sigs/aws-load-balancer-controller/v2.2.0/docs/install/iam_policy.json'
        policy_json = requests.get(url=alb_controller_url).json()

        for statement in policy_json['Statement']:
            alb_service_account.add_to_principal_policy(iam.PolicyStatement.from_json(statement))

        cluster.add_helm_chart(
            'aws-load-balancer-controller-helm-chart',
            chart='aws-load-balancer-controller',
            repository='https://aws.github.io/eks-charts',
            release='aws-load-balancer-controller',
            version='1.4.1',
            wait=True,
            timeout=Duration.minutes(15),
            values={
                "clusterName": cluster.cluster_name,
                "image": {
                    "repository": "602401143452.dkr.ecr.ap-southeast-2.amazonaws.com/amazon/aws-load-balancer-controller:v2.4.1",
                },
                "serviceAccount": {
                    "create": False,
                    "name": alb_service_account.service_account_name,
                },
            },
        )

Right now I'm getting the following cryptic error message.

Received response status [FAILED] from custom resource. Message returned: Error: b'Error: UPGRADE FAILED: another operation (i
nstall/upgrade/rollback) is in progress\n'

Any advice would be greatly appreciated!

1 Answers

There is an AlbController construct available in the CDK, you could try with that and see if that works for you.

I am actually using the construct myself but am facing the same error message. There is this GitHub issue regarding the Helm error itself, however the rollback solution mentioned there is not applicable for me, there appears to be no state of the Helm release despite the error. I have raised this as an issue on the CDK repo.

Related