Repository navigation
Description
Current behaviour
Users can expose cluster workloads to tailnet using Ingress. In this case Tailscale Kubernetes operator acts as a Kubernetes ingress controller. In Kubernetes multiple ingress controllers of diferent types can co-exist in a cluster. Ingress class name is used to determine whether a controller should parse an Ingress resource.
Our operator only creates resources for Ingresses with class name 'tailscale' (it just does string comparison on ingress.spec.ingressClassName field).
Problem
Ingress spec guides controllers towards setting ingress.spec.className to a name of an IngressClass resource (that an ingress controller has been configured with).
We are aware of one validating webhook that comes with the AWS load balancer controller that validates all Ingress resources applied to cluster and rejects any where an IngressClass with a name of spec.ingressClassName does not exist for that Ingress. (See code and a related discussion - looks like they are not going to change this behaviour).
Currently users who want to create a Tailscale Ingress in an EKS cluster with AWS load balancer controller deployed need to manually create a 'tailscale' IngressClass resource.
Could IngressClass be useful for us?
IngressClassmakes it easier for multiple instances of the same controller type to co-exist in a cluster. (Cluster admins can configure each with its ownIngressClassandIngressresources can then be configured to be implemented by the desired controller instance using class name. We currently do not support multiple Tailscale operator instances in the cluster, but we might in the future.ingressclass.spec.parametersallows passing a reference to an arbitrary resource for that class. That might be useful if we start supporting multiple operator instances.IngressClasshas a way of specifying that a certainIngressClassshould be default in the cluster. That would allow users to, for example, migrate all existingIngressresource in cluster to be TailscaleIngresses by deploying a 'default' TailscaleIngressClass. I am not sure whether folks will be wanting to do that- ourIngressimplementation is somewhat different than i.e ingress-nginx (for example, we don't useingress.spec.tls.secretNamethat would be commonly set on otherIngresses, the DNS name is different- so I think migrating to Tailscale Ingress would anyway require more work and consideration than just switchingIngressClass).
How to solve
The simplest way would be to just include a default IngressClass resource with our installation manifests (other ingress controller implementation installations include that), but not allow users to modify it (provide a different class etc) and not fail when it does not exist for some reason.
Should we also validate the IngressClass in controller code?
We could add a check that the IngressClass exists and log a warning if it does not- that would make it easier for us to start using the resource in future if needed.
We probably want to document that we don't accept classes with different names (I don't see why anyone would need to modify the name) and don't accept default class annotation.
Activity
cmd/k8s-operator: validate that the right IngressClass exists in clus…
cmd/k8s-operator/deploy: deploy a Tailscale IngressClass resource.
cmd/k8s-operator: adds a tailscale IngressClass resource, prints warn…
irbekrm commentedon Jan 16, 2024
We've added a default
IngressClassin #10823.unstable-v1.57.90 tailscale/k8s-operator image tag/1.57.90 Helm chart from tailscale dev Helm repository contains this change- do let us know if there are any further issues!
cmd/k8s-operator: adds a tailscale IngressClass resource, prints warn…
cmd/k8s-operator: adds a tailscale IngressClass resource, prints warn…