Skip to content

FR: K8s Operator: add tailscale.com & custom labels to pod template spec #10854

Closed

Description

@JJGadgets

What are you trying to do?

I'd like to have predictable labels on the spawned Tailscale StatefulSet pods, for use with network policies and other label-matching operations.

How should we solve this?

Supporting both of the below solutions would be ideal, but just one for now is also fine.

  1. Propagating the current tailscale.com StatefulSet labels to the pod template spec so spawned pods also get the labels. This is useful for having network policies that allow traffic based on a specific app, e.g. network policy to allow ingress traffic to Minecraft pods.

e.g:

apiVersion: apps/v1
kind: StatefulSet
metadata:
  labels:
    tailscale.com/managed: "true"
    tailscale.com/parent-resource: minecraft
    tailscale.com/parent-resource-ns: minecraft
    tailscale.com/parent-resource-type: svc
...
spec:
  template:
    metadata:
      labels:
        tailscale.com/managed: "true"
        tailscale.com/parent-resource: minecraft
        tailscale.com/parent-resource-ns: minecraft
        tailscale.com/parent-resource-type: svc
  1. Allowing setting custom labels on the pod template in the Helm chart. This is useful for e.g. Istio sidecar, Multus NetworkAttachments, etc.

e.g:

apiVersion: apps/v1
kind: StatefulSet
...
spec:
  template:
    metadata:
      labels:
        egress.home.arpa/internet: "allow"

What is the impact of not solving this?

I am forced to allow all the Tailscale pods to access all pods that are exposed via Tailscale, e.g. my Minecraft Tailscale pod can access my ingress-nginx pods.

I'd like to make my network policies more specific, to only allow an app's Tailscale pod to access only said app pod and no other pods.

Anything else?

No response

Activity

  1. irbekrm commented on Jan 15, 2024

    @irbekrm
    Contributor

    Thanks @JJGadgets .

    We are planning to implement a proxy configuration mechanism #10709 - that will also allow you to configure custom labels.

  2. JJGadgets commented on Jan 15, 2024

    @JJGadgets
    Author

    @irbekrm that would help with custom labels indeed, what about propagating the labels currently set on the StatefulSet controller resource onto the pod template spec in the StatefulSet resource itself?

    I'd be happy to let the mentioned ProxyClass CRD issue track the pod custom labels FR and change this issue to only track the FR for label propagation from StatefulSet resource to pods.

  3. irbekrm commented on Jan 15, 2024

    @irbekrm
    Contributor

    what about propagating the labels currently set on the StatefulSet controller resource onto the pod template spec in the StatefulSet resource itself

    Sounds good- I don't see a reason to not do that especially given that it helps with configuring network policies.

  4. irbekrm commented on Jan 16, 2024

    @irbekrm
    Contributor

    #10861 added syncing of Statefulset labels to Pods.

    unstable-v1.57.90 tailscale/k8s-operator image tag/1.57.90 Helm chart from tailscale dev Helm repository contains this change.

  5. irbekrm commented on Feb 23, 2024

    @irbekrm
    Contributor

    Custom user-defined labels and other customization 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.

  6. irbekrm commented on Apr 5, 2024

    @irbekrm
    Contributor

    Closing as this has been implemented (see above comment)

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    L3 Some usersP1 NuisanceT0 New featurefrkubernetes

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions