0

I hope this makes sense.

We currently deploy our microservices in ECS via CloudFormation script, using a parameterized CloudFrormation template that we fill out per microservice. We use a single ALB configured with multiple /path rules, where each rule is for a microservice. So essentially our listener rules looks like

api.company.com -> alb-microservices/default -> default-target-group
                                    /microservice1/* -> microservice1-target-group
                                    /microservice2/* -> microservice2-target-group

So when our application sends a RESTful API call to api.company.com/microservice1/some_path/... it goes to microservice1, etc.

We create each listener rules via this CloudFormation resource

AlbListenerRule:
  Type: AWS::ElasticLoadBalancingV2::ListenerRule
  Condition: UseListenerRule
  Properties:
    ListenerArn:
      Fn::ImportValue:
        !Sub "${ECSClusterStackNameParameter}-ListenerArn"
    Actions:
      -
        Type: forward
        TargetGroupArn: !Ref AlbTargetGroup
    Conditions:
      -
        Field: path-pattern
        Values: [ !Ref LoadBalancerPathCondition ]
    Priority: !Ref ListenerRulePriority

With this, we can just add paths to our ALB, as we build microservices. Each microservice has its corresponding "ListenerRulePriority" number that we calculate on the fly. Make sense?

I understand the 1:1 correspondence between the ALB above and a Kubernetes Ingress resource, and I want to parameterize a microservice-ingress.yaml manifest file. Essentially, I just want to parameterize the path in my ingress manifest file to give it different paths, and I want it to "append" to the listener rules of my ALB, and I'm thinking the "ListenerRulePriority" has relevance. However, I don't know where the concept of "ListenerRulePriority" comes in. How does it?

Jonas
  • 121,568
  • 97
  • 310
  • 388
Chris F
  • 14,337
  • 30
  • 94
  • 192
  • I think you are looking for to add an `Ingress`-resource for each app in Kuberntes. Together they use one ALB combined. – Jonas Feb 12 '21 at 19:16
  • @Jonas read the whole post please, especially the LAST paragraph. – Chris F Feb 12 '21 at 20:03
  • How can all of my microservices use the SAME Ingress, and just append their `/path` , i.e., listener rule, to it? Thanks! – Chris F Feb 12 '21 at 20:25
  • They all have their own Ingress-resource, with only the `/path` that the apps uses. – Jonas Feb 12 '21 at 20:26
  • But won't applying microservice2's Ingress manifest overwrite the path applied by say microservice1's Ingress manifest? Note that they both use the SAME Ingress. If no then we're good. If yes, then how can I make this work? – Chris F Feb 12 '21 at 20:29
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/228650/discussion-between-chris-f-and-jonas). – Chris F Feb 12 '21 at 20:36

1 Answers1

0

You should create an Ingress-resource for each application, e.g. one for microservice1 and one for microservice2.

The will have its own paths, e.g. Ingress for microservice1 may have

/microservice1

and the Ingress resource for microservice2 may have

/microservice2

Then in the cluster, you typically have an Ingress-controller that interpret the Ingress-resources. On AWS EKS this is typically AWS Load Balancer Controller and it will manage one AWS Application Load Balancer and will append all paths from Ingress-resources in your cluster to this load balancer.

E.g. both:

/microservice1
/microservice2

Note: this has recently changed on AWS EKS: Introducing AWS Load Balancer Controller. The blog post Introducing the AWS Load Balancer Controller is good about the changes and functionality.

Jonas
  • 121,568
  • 97
  • 310
  • 388
  • Follow up question. How do I create an Ingress Controller in AWS? Is it just a `Service` resource with a `LoadBalancer` type? The README.md file in the second link didn't say how to use it. – Chris F Feb 12 '21 at 21:41
  • Here is the deployment doc, indeed not easy to find. https://kubernetes-sigs.github.io/aws-load-balancer-controller/latest/deploy/installation/ – Jonas Feb 12 '21 at 21:44
  • Thanks again Jonas! – Chris F Feb 12 '21 at 21:46