'Helm charts and Ingress resources

I'm pretty new to K8s.

I'm trying to make my app visible to the outside world. I have deployed this Nginx Ingress Controller with my apps, using Helm and helmfile which has given me an external ip address and a load balancer.

As I understand it, I now need an ingress resource to configure the route mappings.

I plan on using this ingress resource as a starting point.

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: minimal-ingress
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /
spec:
  ingressClassName: nginx-example
  rules:
  - http:
      paths:
      - path: /testpath
        pathType: Prefix
        backend:
          service:
            name: test
            port:
              number: 80

My apps are deployed in separate namespaces on port 80.

My question is: where do I put the yaml for creating the resources?

I want to keep everything in Helm if possible to make managing the configuration easier, so I don't want to use kubectl unless i have to.

My helmfile

repositories:
 
- name: stable
  url: https://charts.helm.sh/stable
- name: nginx-stable
  url: https://helm.nginx.com/stable

releases:

  # other apps configured here

  - name: ingress-nginx
    namespace: ingress
    createNamespace: true
    chart: nginx-stable/nginx-ingress
    values:
      - ./ingress/values.yaml
    version: 0.10.4
    installed: true 

My Ingress Controller values.yaml:

---
rbac:
  create: true

serviceAccount:
  create: true
  name: nginx-ingress-public

controller:
  ingressClassResource:
    enabled: true
    default: true

  replicaCount: 3
  minAvailable: 3
  updateStrategy:
    rollingUpdate:
      maxSurge: 3
      maxUnavailable: 0


Solution 1:[1]

You should deploy the ingress controller only once as it can handle all ingress traffic for your whole cluster.

Sometimes it makes sense to deploy multiple, for example we run 2 ingress controller. 1 for internal traffic (private IP) and one for external traffic (public IP).

Once you have that, you just tell your other helm releases to use its ingress class.

The ingress manifest is usually a template of your helm chart. So you put it in templates. If you do helm create my-app, you get a good starting point, including ingress.

Once you have an ingress template in your chart, you can add some reasonable defaults for this template to the values.yaml of the chart, as usual.

When deploying the chart, you can use certain flags to override the defaults. i.e. -f and --set.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1