Implement proxyclass

This commit is contained in:
Raj Singh 2025-04-02 01:19:02 -05:00
parent 23fae133f8
commit 14843b758c
5 changed files with 38 additions and 16 deletions

View File

@ -1,4 +1,2 @@
- name: OPERATOR_DEFAULT_LOAD_BALANCER
value: {{ .Values.defaultLoadBalancer | quote }}
- name: PROXY_EPHEMERAL_KEYS
value: {{ .Values.ephemeralKeys | quote }}
- name: PROXY_EPHEMERAL_KEYS
value: {{ .Values.operatorConfig.ephemeralKeys | quote }}

View File

@ -71,6 +71,12 @@ operatorConfig:
# value: "value1"
# - name: EXTRA_VAR2
# value: "value2"
# If true, use ephemeral device authentication keys for all proxies by default.
# Ephemeral devices are automatically deleted from your tailnet when they
# disconnect, helping keep your tailnet clean.
# This can be overridden per proxy by setting spec.ephemeral in the ProxyClass.
ephemeralKeys: false
# In the case that you already have a tailscale ingressclass in your cluster (or vcluster), you can disable the creation here
ingressClass:
@ -111,12 +117,3 @@ apiServerProxyConfig:
mode: "false" # "true", "false", "noauth"
imagePullSecrets: []
# If true, the operator will consider LoadBalancer Services with no
# loadBalancerClass field set as Tailscale Services.
defaultLoadBalancer: false
# If true, use ephemeral device authentication keys for all proxies.
# Ephemeral devices are automatically deleted from your tailnet when they
# disconnect, helping keep your tailnet clean.
ephemeralKeys: false

View File

@ -58,6 +58,13 @@ spec:
https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status
type: object
properties:
ephemeral:
description: |-
Set Ephemeral to true to make the proxy authenticate as an ephemeral device.
Ephemeral devices are automatically deleted from your tailnet when they
disconnect, helping keep your tailnet clean.
Defaults to false.
type: boolean
metrics:
description: |-
Configuration for proxy metrics. Metrics are currently not supported

View File

@ -377,7 +377,12 @@ func (a *tailscaleSTSReconciler) createOrGetSecret(ctx context.Context, logger *
if len(tags) == 0 {
tags = a.defaultTags
}
authKey, err = newAuthKey(ctx, a.tsClient, tags, a.proxyUseEphemeralKeys)
// Determine if we should use ephemeral keys based on ProxyClass first, falling back to operator config
ephemeral := a.proxyUseEphemeralKeys
if stsC.ProxyClass != nil {
ephemeral = stsC.ProxyClass.Spec.Ephemeral
}
authKey, err = newAuthKey(ctx, a.tsClient, tags, ephemeral)
if err != nil {
return "", "", nil, err
}
@ -962,8 +967,17 @@ func tailscaledConfig(stsC *tailscaleSTSConfig, newAuthkey string, oldSecret *co
conf.AppConnector.Advertise = true
}
}
if shouldAcceptRoutes(stsC.ProxyClass) {
conf.AcceptRoutes = "true"
// Apply ProxyClass settings if available
if stsC.ProxyClass != nil {
// Set AcceptRoutes if specified in ProxyClass
if shouldAcceptRoutes(stsC.ProxyClass) {
conf.AcceptRoutes = "true"
}
// For ephemeral devices, we set this in the auth key when created
// The ephemeral setting is handled at auth key creation time in the newAuthKey function
// We don't need to set it directly in the config
}
if newAuthkey != "" {

View File

@ -81,6 +81,12 @@ type ProxyClassSpec struct {
// renewed.
// +optional
UseLetsEncryptStagingEnvironment bool `json:"useLetsEncryptStagingEnvironment,omitempty"`
// Set Ephemeral to true to make the proxy authenticate as an ephemeral device.
// Ephemeral devices are automatically deleted from your tailnet when they
// disconnect, helping keep your tailnet clean.
// Defaults to false.
// +optional
Ephemeral bool `json:"ephemeral,omitempty"`
}
type TailscaleConfig struct {