The Ops Community ⚙️

Joseph D. Marhee
Joseph D. Marhee

Posted on

Caddy Ingress Controller with Rancher-managed RKE2/K3s

The default Ingress controller for RKE2 and K3s are Nginx and Traefik, respectively, but both can have this overridden; for example, K3s can be deployed using Nginx in place of Traefik, using the K3s Helm Controller, and likewise for Ingress controllers like the one provided for Caddy.

To do this when deploying clusters via Rancher Manager, there are two steps:

  1. Disable the default Ingress in the Cluster specification.
  2. Add an additional manifest to the spec.rkeConfig to add a Helm Chart for the Caddy Ingress.

For the first step, either uncheck the box for Nginx (or Traefik for K3s) Ingress in your Rancher UI:

Image description

Or, in the cluster yaml, ensure this line is present:

    machineGlobalConfig:
      cni: calico
      disable:
        - rke2-ingress-nginx
Enter fullscreen mode Exit fullscreen mode

in your machineGlobalConfig.

For step 2, add the following:

---
apiVersion: v1
kind: Namespace
metadata:
  name: caddy-system
---
apiVersion: helm.cattle.io/v1
kind: HelmChart
metadata:
  name: caddy-ingress-controller
  namespace: kube-system
spec:
  repo: https://caddyserver.github.io/ingress
  chart: caddy-ingress-controller
  targetNamespace: caddy-system
#  valuesContent: |
#    minikube: true #hostNet for testing, otherwise use load balancer
#    loadBalancer:
#       enabled: false
#    automaticHTTPS: your@email.com 
Enter fullscreen mode Exit fullscreen mode

to, either, the UI field for additional manifests:

Image description

or to .spec.rkeConfig in the yaml editor:

  rkeConfig:
    additionalManifest: |-
      ---
      apiVersion: v1
      kind: Namespace
      metadata:
        name: caddy-system
      ---
      apiVersion: helm.cattle.io/v1
      kind: HelmChart
      metadata:
        name: caddy-ingress-controller
        namespace: kube-system
      spec:
        repo: https://caddyserver.github.io/ingress
        chart: caddy-ingress-controller
        targetNamespace: caddy-system
Enter fullscreen mode Exit fullscreen mode

Once your cluster is done provisioning, you can verify that Caddy is running as your default Ingress:

Image description

Top comments (0)