<p>After talking with the support staff from the cloud provider, reading through the docs and looking at how other cloud providers do it, I believe that both of them are needed.</p>
<p>In order to have a simple DNS zone management, you need to expose all your cluster nodes in some way and that way is with an external LoadBalancer.</p>
<p>The LoadBalancer makes sure to always point to all the cluster nodes even when there are changes to the nodes themselves (add / remove). This way you can update the DNS zone for the domain you want by pointing to the LoadBalancer IP. Of course, you will need to make sure that this IP will not change.</p>
<p>Since now there is a way to route external traffic from your custom domain to the kubernetes cluster, you need to know where to redirect that traffic.</p>
<p>Here comes the Ingress Controller.</p>
<p>With it you can forward traffic based on host name, for example, in order to reach your desired Service.</p>
<p>Comparing two cloud providers and their approach for publicly exposing an application, I found that both of them are using an external LoadBalancer together with an IngressController:</p>
<ol>
<li><p>Scaleway</p>
<p>In order to expose all cluster nodes through a LoadBalancer you need to create a Service with the following:</p>
</li>
</ol>
<pre><code>spec:
  type: LoadBalancer
  ports:
    - port: 80
      name: http
      targetPort: 80
    - port: 443
      name: https
      targetPort: 443
</code></pre>
<p><code>targetPort</code> is required to be those exact ports.</p>
<p>After LoadBalancer is created you can use its IP address for the DNS Records.</p>
<p>Now, you can create the Ingress Controller to forward traffic to Services.</p>
<ol start="2">
<li><p>AWS</p>
<p>You can create an Ingress Controller which itself creates an AWS Application Load Balancer.</p>
<p>The ALB does not have an IP, instead it relies on a CNAME Record.</p>
</li>
</ol>
<p>Both of them are using an external LoadBalancer to forward traffic to the cluster and both of them are using IngressController to redirect traffic to Services.</p>
<p>I believe this is the way of publicly expose an application behind a kubernetes cluster.</p>

CC BY-SA 4.0
2021-12-16T16:41:25.227Z
an ALB has an IP, but it changes frequently but you only need a CNAME if you're not using route53, which has a special type of A record called alias that let's you point to an ALB. An ingress controller doesn't create an ALB. You could have traefik (ingress controller) installed on your cluster and not have an ALB at all. That is useful if you have a single node cluster for development, for example.
Magus
CC BY-SA 4.0
2021-12-13T17:06:46.977Z
2021-12-13T17:06:46.977Z
Razvan Toader
<p>A LoadBalancer is a cloud specific resource, you wouldn't have a LoadBalancer if you had kubernetes running on a raspberrypi, for example. Instead you would have to provision your own using something like metalLB.</p>
<p>When you create a LoadBalancer in aws, it creates a NLB<a href="https://docs.aws.amazon.com/elasticloadbalancing/latest/network/introduction.html" rel="nofollow noreferrer">enter link description here</a>, a resource external to the cluster.</p>
<p>An Ingress type is a way of routing requests to the correct services.</p>
<p>So, your request would go through:</p>
<ol>
<li>Internet - going all the way from your browser to your cloud provider</li>
<li>NLB (LoadBalancer) - on your cloud provider network</li>
<li>VM (ec2) - routed from the NLB</li>
<li>Ingress - finds the correct service to proxy the request to</li>
<li>Service - Also a load balancer, but internal to the cluster, find the deployment/statefulset, etc and gets the replicaset and picks a pod to route the request to</li>
<li>Pod - receives the request</li>
<li>Container - processes the request</li>
</ol>
<p>And that's not even the most complex setup. You can add ambassadors, sidecars, MTLs, VPNs. Things can go crazy.</p>
<p>Here's a meme for clarification:</p>
<p><a href="https://i.sstatic.net/JoeHY.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/JoeHY.jpg" alt="enter image description here" /></a></p>

CC BY-SA 4.0
2021-12-16T16:37:33.740Z
2021-12-16T16:43:35.693Z
2021-12-16T16:43:35.693Z
Magus
<p>I am new to kubernetes and I am trying to expose an application publicly. I am using Scaleway as the cloud provider (if it matters).</p>
<p>From what I understand, there are multiple ways of doing this.</p>
<ol>
<li><p>Create an Ingress Controller</p>
<p>By doing this, the ingress exposes a nodes IP address and port and forwards all requests to the attached service.</p>
<p>I pointed the DNS record to the publicly exposed IP.</p>
<p>SSL certificate is created using cert-manager and it seems to work great with the ingress controller meaning that the certificate is automatically created and attached to the ingress resource.</p>
<p>How do you manage DNS records when the cluster has multiple nodes which can be deleted / created automatically?</p>
</li>
<li><p>Create a Load Balancer type service</p>
<p>This creates a cloud provided Load Balancer which internally is configured to route all traffic to all nodes from the cluster.</p>
<p>With this approach I can point the DNS records to the Load Balancer IP which in turn can be configured to preserve the public IP, meaning that cluster nodes can be attached / removed and it will not affect the DNS records.</p>
<p>But I do not know how to add a SSL certificate using this approach. Any thoughts?</p>
</li>
</ol>
<p>Which of the two approaches is best suited for exposing an application keeping in mind the DNS management and SSL certificates?</p>

CC BY-SA 4.0
2021-12-13T11:58:27.223Z
There's any chance of you consider use the Istio like a service mesh? When you use them it's possible use VirtualService to expose the DNS through of LB.
Vader
CC BY-SA 4.0
2021-12-13T15:26:11.177Z
@WeyderFerreira I am open to trying istio but without understanding the basics it will be an overkill
Razvan Toader
<kubernetes><load-balance><ingress><ssl>
Ingress vs Load Balancer
Razvan Toader
# Ingress vs Load Balancer

(Asked by: username_0 on 2021-12-13)

I am new to kubernetes and I am trying to expose an application publicly. I am using Scaleway as the cloud provider (if it matters).

From what I understand, there are multiple ways of doing this.

1. Create an Ingress Controller

   By doing this, the ingress exposes a nodes IP address and port and forwards all requests to the attached service.

   I pointed the DNS record to the publicly exposed IP.

   SSL certificate is created using cert-manager and it seems to work great with the ingress controller meaning that the certificate is automatically created and attached to the ingress resource.

   How do you manage DNS records when the cluster has multiple nodes which can be deleted / created automatically?
2. Create a Load Balancer type service

   This creates a cloud provided Load Balancer which internally is configured to route all traffic to all nodes from the cluster.

   With this approach I can point the DNS records to the Load Balancer IP which in turn can be configured to preserve the public IP, meaning that cluster nodes can be attached / removed and it will not affect the DNS records.

   But I do not know how to add a SSL certificate using this approach. Any thoughts?

Which of the two approaches is best suited for exposing an application keeping in mind the DNS management and SSL certificates?

**Tags:** kubernetes, load-balance, ingress, ssl

> **Comments:**
> **username_1**: There's any chance of you consider use the Istio like a service mesh? When you use them it's possible use VirtualService to expose the DNS through of LB.  
> **username_0**: @WeyderFerreira I am open to trying istio but without understanding the basics it will be an overkill  

---

## 2 answers

### Answer by username_0 on 2021-12-13. Score: 3

After talking with the support staff from the cloud provider, reading through the docs and looking at how other cloud providers do it, I believe that both of them are needed.
In order to have a simple DNS zone management, you need to expose all your cluster nodes in some way and that way is with an external LoadBalancer.
The LoadBalancer makes sure to always point to all the cluster nodes even when there are changes to the nodes themselves (add / remove). This way you can update the DNS zone for the domain you want by pointing to the LoadBalancer IP. Of course, you will need to make sure that this IP will not change.
Since now there is a way to route external traffic from your custom domain to the kubernetes cluster, you need to know where to redirect that traffic.
Here comes the Ingress Controller.
With it you can forward traffic based on host name, for example, in order to reach your desired Service.
Comparing two cloud providers and their approach for publicly exposing an application, I found that both of them are using an external LoadBalancer together with an IngressController:

Scaleway
In order to expose all cluster nodes through a LoadBalancer you need to create a Service with the following:


spec:
  type: LoadBalancer
  ports:
    - port: 80
      name: http
      targetPort: 80
    - port: 443
      name: https
      targetPort: 443

targetPort is required to be those exact ports.
After LoadBalancer is created you can use its IP address for the DNS Records.
Now, you can create the Ingress Controller to forward traffic to Services.

AWS
You can create an Ingress Controller which itself creates an AWS Application Load Balancer.
The ALB does not have an IP, instead it relies on a CNAME Record.


Both of them are using an external LoadBalancer to forward traffic to the cluster and both of them are using IngressController to redirect traffic to Services.
I believe this is the way of publicly expose an application behind a kubernetes cluster.

> **Comments:**
> **username_2**: an ALB has an IP, but it changes frequently but you only need a CNAME if you're not using route53, which has a special type of A record called alias that let's you point to an ALB. An ingress controller doesn't create an ALB. You could have traefik (ingress controller) installed on your cluster and not have an ALB at all. That is useful if you have a single node cluster for development, for example.  

---

### Answer by username_2 on 2021-12-16. Score: 1

A LoadBalancer is a cloud specific resource, you wouldn't have a LoadBalancer if you had kubernetes running on a raspberrypi, for example. Instead you would have to provision your own using something like metalLB.

When you create a LoadBalancer in aws, it creates a NLB[enter link description here](https://docs.aws.amazon.com/elasticloadbalancing/latest/network/introduction.html), a resource external to the cluster.

An Ingress type is a way of routing requests to the correct services.

So, your request would go through:

1. Internet - going all the way from your browser to your cloud provider
2. NLB (LoadBalancer) - on your cloud provider network
3. VM (ec2) - routed from the NLB
4. Ingress - finds the correct service to proxy the request to
5. Service - Also a load balancer, but internal to the cluster, find the deployment/statefulset, etc and gets the replicaset and picks a pod to route the request to
6. Pod - receives the request
7. Container - processes the request

And that's not even the most complex setup. You can add ambassadors, sidecars, MTLs, VPNs. Things can go crazy.

Here's a meme for clarification:

[![enter image description here](https://i.sstatic.net/JoeHY.jpg)](https://i.sstatic.net/JoeHY.jpg)


---

