Skip to content

FR: Specifying node selector for k8s operator proxy pods #9062

Closed

Description

@zlepper

What are you trying to do?

When I tag a service to be available in tailscale it creates a stateful set to handle the proxying. Sadly this proxy doesn't come with any node selectors available so AKS tries to start it on the windows node I have in my cluster. This ofcause doesn't work.

I can't manually add in the node selector due to how Tailscale operates with the kubernetes api, since it overwrites any changes done manually.

How should we solve this?

At the very least adding a default node selector of kubernetes.io/os=linux would at least allow tailscale to start. But even better i would like to be able to actually control what the node selector actually is, so i can ensure that tailscale is at least running somewhat close to the service it's going to be talking to.

What is the impact of not solving this?

I think i can workaround it by applying a taint to the windows node, but that means i have to modify all my windows workloads to have a toleration to that taint.

Anything else?

I wasn't entirely sure if this should be considered a bug.

Activity

  1. jakedgy commented on Aug 29, 2023

    @jakedgy
    Contributor

    What if we just remove the embedded proxy.yaml file from the operator binary and include it in the container at a path that users can override via ConfigMap?

    I've started working on a Helm chart for the operator -- it could reuse some of the relevant podSpecTemplate fragments to simplify tweaking things on the proxy StatefulSet like annotations, nodeSelectors, tolerations, etc.

  2. maisem commented on Aug 29, 2023

    @maisem
    Contributor

    What if we just remove the embedded proxy.yaml file from the operator binary and include it in the container at a path that users can override via ConfigMap?

    that sgtm, we would need to move some of the fields that are set there (like initContainers) to be set by the operator

  3. zlepper commented on Aug 30, 2023

    @zlepper
    Author

    What if we just remove the embedded proxy.yaml file from the operator binary and include it in the container at a path that users can override via ConfigMap?

    I've started working on a Helm chart for the operator -- it could reuse some of the relevant podSpecTemplate fragments to simplify tweaking things on the proxy StatefulSet like annotations, nodeSelectors, tolerations, etc.

    That would certainly solve the issue I have :)

  4. jakedgy commented on Sep 1, 2023

    @jakedgy
    Contributor

    that sgtm, we would need to move some of the fields that are set there (like initContainers) to be set by the operator

    @maisem I propose we just use a ConfigMap with the proxy skeleton as data:

    kind: ConfigMap
    metadata:
      name: tailscale-operator-proxy
    data:
      kind: StatefulSet
      ...

    Then we just mount proxy.yaml somewhere in the operator container filesystem. Add another argument to the operator to specify the filepath of the proxy template.

    On the helm side, we can provide some guardrails that make it behave like any other podSpecTemplate.

    proxy:
      annotations:
      labels:
      tolerations:
      topologySpreadConstraints:
      nodeSelector:
      # etc...

    If we add Kustomize support, we could start with a default base, a userspace mode overlay, and users can just add their own overlays as needed.

  5. zlepper commented on Sep 1, 2023

    @zlepper
    Author

    Just to ask a stupid question which I assume has already been discussed to death somewhere: have you considered using some Custom Kubernetes resources for managing what the operator does rather than trying to layer it on top of existing resources? Or at least an addition to annotations if advanced control is required?

    I imagine there might be use-cases where controlling the proxy location by service might be beneficial, for example to co-locate it with the pods it is servicing. (Not required to solve my problem adequately, just as a thought?)

    On the other hand, I love the simplicity of just adding a couple of annotations and then things just work.

  6. jakedgy commented on Sep 1, 2023

    @jakedgy
    Contributor

    Just to ask a stupid question which I assume has already been discussed to death somewhere: have you considered using some Custom Kubernetes resources for managing what the operator does rather than trying to layer it on top of existing resources? Or at least an addition to annotations if advanced control is required?

    I imagine there might be use-cases where controlling the proxy location by service might be beneficial, for example to co-locate it with the pods it is servicing. (Not required to solve my problem adequately, just as a thought?)

    On the other hand, I love the simplicity of just adding a couple of annotations and then things just work.

    Please take this with a grain of salt -- I don't work at Tailscale, I'm just some random guy...

    I prefer to stick with annotations until I understand more of the usage patterns and an API starts to emerge. If you go down the CRD path prematurely, you can end up locking a major version into something that isn't a great fit for some of the use cases you uncover along the way.

  7. jakedgy commented on Sep 4, 2023

    @jakedgy
    Contributor

    Taking a stab at a Helm Chart in #9224.

    I still need to get the ConfigMap built for the proxy template, but the idea is that it will follow the same pod syntax pattern .Values.operator.

  8. GMartinez-Sisti commented on Nov 9, 2023

    @GMartinez-Sisti
    Contributor

    I'm also blocked by something similar to this.

    We annotate services on k8s to make the tailscale-operator create the resources, the proxy pod created by the operator will sit on a different namespace than the resource. When using network policies and automation, we need to have predictive behaviour so we can configure the access between the proxy pod and the actual workload. The operator currently labels the tailscale statefulset pod with something like this:

      labels:
        app: <random-guid>
        controller-revision-hash: ts-<service-name>-<ts-sts><ts-sts-pod-ordinal><config-hash>
        statefulset.kubernetes.io/pod-name: ts-<service-name>-<ts-sts><ts-sts-pod-ordinal>

    None of this can be inferred from any existing configuration before the service is created, and waiting to get this information after the resource is created is not something we want to rely on.

    So, ideally the proxy could be customised further, either by adding a CRD with base templates, through extra tags for individual componentes (doesn't scale very well) or with a single tag that would be used as a cumulative template to the default one.

  9. irbekrm commented on Feb 23, 2024

    @irbekrm
    Contributor

    Node selectors and other customization for proxy resources can now (v1.60) be applied via a ProxyClass custom resource https://tailscale.com/kb/1236/kubernetes-operator#cluster-resource-customization-using-proxyclass-custom-resource.

    We are planning to eventually add more customization options to ProxyClass.
    Feedback on whether it fits your workflow + what other fields you might need to configure (and why) is very welcome.

  10. GMartinez-Sisti commented on Feb 26, 2024

    @GMartinez-Sisti
    Contributor

    Node selectors and other customization for proxy resources can now (v1.60) be applied via a ProxyClass custom resource https://tailscale.com/kb/1236/kubernetes-operator#cluster-resource-customization-using-proxyclass-custom-resource.

    We are planning to eventually add more customization options to ProxyClass. Feedback on whether it fits your workflow + what other fields you might need to configure (and why) is very welcome.

    Hi @irbekrm, thank you for checking 😄 Unfortunately we're not using the Ingress feature. We're only using annotated services to create tailscale proxies automatically with the k8s-operator. This is mostly because we have also TCP services and we are using the same logic to expose on all of them.

  11. irbekrm commented on Feb 26, 2024

    @irbekrm
    Contributor

    @GMartinez-Sisti ProxyClass works with Services. You can set tailscale.com/proxy-class=<proxy-class-name> label on a Service to refer to a ProxyClass.

  12. GMartinez-Sisti commented on Feb 26, 2024

    @GMartinez-Sisti
    Contributor

    @GMartinez-Sisti ProxyClass works with Services. You can set tailscale.com/proxy-class=<proxy-class-name> label on a Service to refer to a ProxyClass.

    Then it should cover our use cases since we can use labels for the network policies/discovery 🌟 . I thought this was just for Ingress services, maybe the class term threw me off 😅. Thanks!

  13. irbekrm commented on Feb 26, 2024

    @irbekrm
    Contributor

    maybe the class term threw me off

    Yeah the name is inspired from IngressClass, but really there is nothing Ingress-specific. Hope it'll work!

  14. irbekrm commented on Apr 15, 2024

    @irbekrm
    Contributor

    Closing as implemented in #11074

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

L1 Very fewP3 Can't get startedT0 New featurefrkubernetes

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions