<p>I want to use existing AWS ALB for my kubernetes setup. i.e. I don't want alb-ingress-controller create or update any existing AWS resource ie. Target groups, roles etc. </p>

<p>How can I make ALB to communicate with Kubernetes cluster, henceforth passing the request to existing services and getting the response back to ALB to display in the front end?</p>

<p>I tried <a href="https://github.com/coreos/alb-ingress-controller/" rel="nofollow noreferrer">this</a> but it will create new ALB for new ingress resource. I want to use the existing one.</p>

<p>You basically have to open a node port on the instances where the Kubernetes Pods are running. Then you need to let the ALB point to those instances. There are two ways of configuring this. Either via Pods or via Services.</p>

<p>To configure it via a <strong>Service</strong> you need to specify <code>.spec.ports[].nodePort</code>. In the default setup the port needs to be between <code>30000</code> and <code>32000</code>. This port gets opened on every node and will be redirected to the specified Pods (which might be on any other node). This has the downside that there is another hop, which also can cost money when using a multi-AZ setup. An example Service could look like this:</p>

<pre><code>---
apiVersion: v1
kind: Service

metadata:
  name: my-frontend
  labels:
    app: my-frontend

spec:
  type: NodePort
  selector:
    app: my-frontend
  ports:
  - port: 8080
    nodePort: 30082
</code></pre>

<p>To configure it via a <strong>Pod</strong> you need to specify <code>.spec.containers[].ports[].hostPort</code>. This can be any port number, but it has to be free on the node where the Pod gets scheduled. This means that there can only be one Pod per node and it might conflict with ports from other applications. This has the downside that not all instances will be healthy from an ALB point-of-view, since only nodes with that Pod accept traffic. You could add a sidecar container which registers the current node on the ALB, but this would mean additional complexity. An example could look like this:</p>

<pre><code>---
apiVersion: extensions/v1beta1
kind: Deployment

metadata:
  name: my-frontend
  labels:
    app: my-frontend

spec:
  replicas: 3

  selector:
    matchLabels:
      app: my-frontend

  template:
    metadata:
      name: my-frontend
      labels:
        app: my-frontend

    spec:
      containers:
      - name: nginx
        image: "nginx"

        ports:
        - containerPort: 80
          hostPort: 8080
</code></pre>
