Skip to content

cmd/k8s-operator: adds a tailscale IngressClass resource, prints warning if class not found. - #10823

Merged
irbekrm merged 3 commits into
mainfrom
irbekrm/ingressclass
Jan 16, 2024
Merged

irbekrm merged 3 commits into
mainfrom
irbekrm/ingressclass

Conversation

@irbekrm

@irbekrm irbekrm commented Jan 11, 2024 •

Copy link
Copy Markdown
Contributor

See #10820 for detailed context.

This PR adds a 'tailscale' IngressClass resource to Tailscale operator manifests (helm chart and static) to prevent strict webhooks rejecting user's Tailscale Ingress resources.

It also adds a simple validation that runs at the time when an Ingress resource would be reconciled and prints a warning either if 'tailscale' IngressClass resource is not found or if the controller name does not match our controller.
This is with the thinking that in future we might actually want to utilize this IngressClass resource:

I am not certain we will need IngressClass for the above reasons, but also this is a no-op for users who install with our manifests.

Next steps:

  • document that our IngressClass cannot be modified (we do not support changing controller name or specifying a class with a different name)
  • document that we do not support default class

Notes

  • Users who have manually created a 'tailscale' IngressClass will need to delete it to upgrade to this version
  • I have tested that with manifests from this PR and tailscale Ingress resource does not get rejected by AWS load balancer's validating webhook (see the original issue description)

Some Ingress validating webhooks reject Ingresses with
.spec.ingressClassName for which there is no matching IngressClass.

Updates #10820

Signed-off-by: Irbe Krumina <[email protected]>
…ter.

We currently do not utilize the IngressClass,
however we might in the future at which point
we might start requiring that the right class
for this controller instance actually exists.

Signed-off-by: Irbe Krumina <[email protected]>
@irbekrm
irbekrm force-pushed the irbekrm/ingressclass branch from 39057ea to a7d0ad0 Compare January 11, 2024 12:12
// deprovisioning later.
func (a *IngressReconciler) maybeProvision(ctx context.Context, logger *zap.SugaredLogger, ing *networkingv1.Ingress) error {
if err := a.validateIngressClass(ctx); err != nil {
logger.Warnf("error validating tailscale IngressClass: %v. In future this might be a terminal error.", err)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This appears at default ('info') logs

{"level":"warn","ts":"2024-01-11T12:11:18Z","logger":"ingress-reconciler","msg":"error validating tailscale IngressClass: ingressclass.kubernetes.io/is-default-class annotation is set on 'tailscale' IngressClass, but Tailscale Ingress controller does not support default Ingress class. Ensure that you are using 'tailscale' IngressClass from latest Tailscale installation manifests.. In future this might be a terminal error.","ingress-ns":"default","ingress-name":"kuardfoobar"}

Name: tailscaleIngressClassName,
},
}
if err := a.Get(ctx, client.ObjectKeyFromObject(ic), ic); apierrors.IsNotFound(err) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doing this will start a watch for IngressClass as that's what c/r does by default. I don't really see that as an issue since those are small resources of which there shouldn't be many. I do want to clean up our caching logic at some point though, we could cache less and cache metadata only in some cases, but so far no-one has raised memory consumption issues or slowness

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be a code comment to make sure folks reading this code have more context? It's going to be more visible than a comment on the PR.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For this particular one I would rather not leave a comment there it's not really relevant to the code flow. I will add a TODO to re-evaluate caching in where we set up controllers.

@irbekrm
irbekrm requested review from knyar and maisem January 11, 2024 12:25

@knyar knyar left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While I reviewed the code, I am not familiar with IngressClass and can't evaluate whether this is the best way to address the issue. I am happy to learn more about this and form an opinion if you'd like some feedback on the overall approach.

Comment thread cmd/k8s-operator/ingress.go Resolved
Name: tailscaleIngressClassName,
},
}
if err := a.Get(ctx, client.ObjectKeyFromObject(ic), ic); apierrors.IsNotFound(err) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be a code comment to make sure folks reading this code have more context? It's going to be more visible than a comment on the PR.

Comment thread cmd/k8s-operator/ingress.go Resolved
Comment thread cmd/k8s-operator/ingress.go Resolved
Signed-off-by: Irbe Krumina <[email protected]>
Co-authored-by: Anton Tolchanov <[email protected]>
@freimer

freimer commented Jan 11, 2024

Copy link
Copy Markdown

I see this is more than just adding the k8s resource, as it has code changes. Looks good, as it will give flexibility in the future. Happy to test this if you want.

@irbekrm

irbekrm commented Jan 11, 2024

Copy link
Copy Markdown
Contributor Author

I see this is more than just adding the k8s resource, as it has code changes. Looks good, as it will give flexibility in the future. Happy to test this if you want.

Hi @freimer thanks, we always value extra tests and feedback. Did you also run into an issue with this on EKS/with AWS load balancer?

@freimer

freimer commented Jan 11, 2024

Copy link
Copy Markdown

I'm the reporting customer ;-)

@irbekrm

irbekrm commented Jan 12, 2024

Copy link
Copy Markdown
Contributor Author

I'm the reporting customer ;-)

I didn't realise that. Thanks for reporting the issue!

@irbekrm
irbekrm merged commit d0492fd into main Jan 16, 2024
@irbekrm
irbekrm deleted the irbekrm/ingressclass branch January 16, 2024 12:48
Asutorufa pushed a commit to Asutorufa/tailscale that referenced this pull request Jan 19, 2024
…ing if class not found. (tailscale#10823)

* cmd/k8s-operator/deploy: deploy a Tailscale IngressClass resource.

Some Ingress validating webhooks reject Ingresses with
.spec.ingressClassName for which there is no matching IngressClass.

Additionally, validate that the expected IngressClass is present,
when parsing a tailscale `Ingress`. 
We currently do not utilize the IngressClass,
however we might in the future at which point
we might start requiring that the right class
for this controller instance actually exists.

Updates tailscale#10820

Signed-off-by: Irbe Krumina <[email protected]>
Co-authored-by: Anton Tolchanov <[email protected]>
chen8945 pushed a commit to Ckid-Home/tailscale that referenced this pull request Jul 31, 2024
…ing if class not found. (tailscale#10823)

* cmd/k8s-operator/deploy: deploy a Tailscale IngressClass resource.

Some Ingress validating webhooks reject Ingresses with
.spec.ingressClassName for which there is no matching IngressClass.

Additionally, validate that the expected IngressClass is present,
when parsing a tailscale `Ingress`. 
We currently do not utilize the IngressClass,
however we might in the future at which point
we might start requiring that the right class
for this controller instance actually exists.

Updates tailscale#10820

Signed-off-by: Irbe Krumina <[email protected]>
Co-authored-by: Anton Tolchanov <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Kubernetes Operator: users need to manually create IngressClass resource to use Tailscale Ingress on some EKS setups

4 participants