mirror of https://github.com/tailscale/tailscale/
cmd/k8s-operator,k8s-operator: add ProxyGroup CRD (#13591)
The ProxyGroup CRD specifies a set of N pods which will each be a tailnet device, and will have M different ingress or egress services mapped onto them. It is the mechanism for specifying how highly available proxies need to be. This commit only adds the definition, no controller loop, and so it is not currently functional. This commit also splits out TailnetDevice and RecorderTailnetDevice into separate structs because the URL field is specific to recorders, but we want a more generic struct for use in the ProxyGroup status field. Updates #13406 Signed-off-by: Tom Proctor <tomhjp@users.noreply.github.com>pull/13607/head
parent
7ec8bdf8b1
commit
cab2e6ea67
@ -0,0 +1,188 @@
|
|||||||
|
apiVersion: apiextensions.k8s.io/v1
|
||||||
|
kind: CustomResourceDefinition
|
||||||
|
metadata:
|
||||||
|
annotations:
|
||||||
|
controller-gen.kubebuilder.io/version: v0.15.1-0.20240618033008-7824932b0cab
|
||||||
|
name: proxygroups.tailscale.com
|
||||||
|
spec:
|
||||||
|
group: tailscale.com
|
||||||
|
names:
|
||||||
|
kind: ProxyGroup
|
||||||
|
listKind: ProxyGroupList
|
||||||
|
plural: proxygroups
|
||||||
|
shortNames:
|
||||||
|
- pg
|
||||||
|
singular: proxygroup
|
||||||
|
scope: Cluster
|
||||||
|
versions:
|
||||||
|
- additionalPrinterColumns:
|
||||||
|
- description: Status of the deployed ProxyGroup resources.
|
||||||
|
jsonPath: .status.conditions[?(@.type == "ProxyGroupReady")].reason
|
||||||
|
name: Status
|
||||||
|
type: string
|
||||||
|
name: v1alpha1
|
||||||
|
schema:
|
||||||
|
openAPIV3Schema:
|
||||||
|
type: object
|
||||||
|
required:
|
||||||
|
- spec
|
||||||
|
properties:
|
||||||
|
apiVersion:
|
||||||
|
description: |-
|
||||||
|
APIVersion defines the versioned schema of this representation of an object.
|
||||||
|
Servers should convert recognized schemas to the latest internal value, and
|
||||||
|
may reject unrecognized values.
|
||||||
|
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
|
||||||
|
type: string
|
||||||
|
kind:
|
||||||
|
description: |-
|
||||||
|
Kind is a string value representing the REST resource this object represents.
|
||||||
|
Servers may infer this from the endpoint the client submits requests to.
|
||||||
|
Cannot be updated.
|
||||||
|
In CamelCase.
|
||||||
|
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
|
||||||
|
type: string
|
||||||
|
metadata:
|
||||||
|
type: object
|
||||||
|
spec:
|
||||||
|
description: Spec describes the desired ProxyGroup instances.
|
||||||
|
type: object
|
||||||
|
required:
|
||||||
|
- type
|
||||||
|
properties:
|
||||||
|
hostnamePrefix:
|
||||||
|
description: |-
|
||||||
|
HostnamePrefix is the hostname prefix to use for tailnet devices created
|
||||||
|
by the ProxyGroup. Each device will have the integer number from its
|
||||||
|
StatefulSet pod appended to this prefix to form the full hostname.
|
||||||
|
HostnamePrefix can contain lower case letters, numbers and dashes, it
|
||||||
|
must not start with a dash and must be between 1 and 62 characters long.
|
||||||
|
type: string
|
||||||
|
pattern: ^[a-z0-9][a-z0-9-]{0,61}$
|
||||||
|
proxyClass:
|
||||||
|
description: |-
|
||||||
|
ProxyClass is the name of the ProxyClass custom resource that contains
|
||||||
|
configuration options that should be applied to the resources created
|
||||||
|
for this ProxyGroup. If unset, and no default ProxyClass is set, the
|
||||||
|
operator will create resources with the default configuration.
|
||||||
|
type: string
|
||||||
|
replicas:
|
||||||
|
description: |-
|
||||||
|
Replicas specifies how many replicas to create the StatefulSet with.
|
||||||
|
Defaults to 2.
|
||||||
|
type: integer
|
||||||
|
tags:
|
||||||
|
description: |-
|
||||||
|
Tags that the Tailscale devices will be tagged with. Defaults to [tag:k8s].
|
||||||
|
If you specify custom tags here, make sure you also make the operator
|
||||||
|
an owner of these tags.
|
||||||
|
See https://tailscale.com/kb/1236/kubernetes-operator/#setting-up-the-kubernetes-operator.
|
||||||
|
Tags cannot be changed once a ProxyGroup device has been created.
|
||||||
|
Tag values must be in form ^tag:[a-zA-Z][a-zA-Z0-9-]*$.
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
type: string
|
||||||
|
pattern: ^tag:[a-zA-Z][a-zA-Z0-9-]*$
|
||||||
|
type:
|
||||||
|
description: |-
|
||||||
|
Type of the ProxyGroup, either ingress or egress. Each set of proxies
|
||||||
|
managed by a single ProxyGroup definition operate as only ingress or
|
||||||
|
only egress proxies.
|
||||||
|
type: string
|
||||||
|
enum:
|
||||||
|
- egress
|
||||||
|
status:
|
||||||
|
description: |-
|
||||||
|
ProxyGroupStatus describes the status of the ProxyGroup resources. This is
|
||||||
|
set and managed by the Tailscale operator.
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
conditions:
|
||||||
|
description: |-
|
||||||
|
List of status conditions to indicate the status of the ProxyGroup
|
||||||
|
resources. Known condition types are `ProxyGroupReady`.
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
description: Condition contains details for one aspect of the current state of this API Resource.
|
||||||
|
type: object
|
||||||
|
required:
|
||||||
|
- lastTransitionTime
|
||||||
|
- message
|
||||||
|
- reason
|
||||||
|
- status
|
||||||
|
- type
|
||||||
|
properties:
|
||||||
|
lastTransitionTime:
|
||||||
|
description: |-
|
||||||
|
lastTransitionTime is the last time the condition transitioned from one status to another.
|
||||||
|
This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable.
|
||||||
|
type: string
|
||||||
|
format: date-time
|
||||||
|
message:
|
||||||
|
description: |-
|
||||||
|
message is a human readable message indicating details about the transition.
|
||||||
|
This may be an empty string.
|
||||||
|
type: string
|
||||||
|
maxLength: 32768
|
||||||
|
observedGeneration:
|
||||||
|
description: |-
|
||||||
|
observedGeneration represents the .metadata.generation that the condition was set based upon.
|
||||||
|
For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date
|
||||||
|
with respect to the current state of the instance.
|
||||||
|
type: integer
|
||||||
|
format: int64
|
||||||
|
minimum: 0
|
||||||
|
reason:
|
||||||
|
description: |-
|
||||||
|
reason contains a programmatic identifier indicating the reason for the condition's last transition.
|
||||||
|
Producers of specific condition types may define expected values and meanings for this field,
|
||||||
|
and whether the values are considered a guaranteed API.
|
||||||
|
The value should be a CamelCase string.
|
||||||
|
This field may not be empty.
|
||||||
|
type: string
|
||||||
|
maxLength: 1024
|
||||||
|
minLength: 1
|
||||||
|
pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$
|
||||||
|
status:
|
||||||
|
description: status of the condition, one of True, False, Unknown.
|
||||||
|
type: string
|
||||||
|
enum:
|
||||||
|
- "True"
|
||||||
|
- "False"
|
||||||
|
- Unknown
|
||||||
|
type:
|
||||||
|
description: type of condition in CamelCase or in foo.example.com/CamelCase.
|
||||||
|
type: string
|
||||||
|
maxLength: 316
|
||||||
|
pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$
|
||||||
|
x-kubernetes-list-map-keys:
|
||||||
|
- type
|
||||||
|
x-kubernetes-list-type: map
|
||||||
|
devices:
|
||||||
|
description: List of tailnet devices associated with the ProxyGroup StatefulSet.
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
type: object
|
||||||
|
required:
|
||||||
|
- hostname
|
||||||
|
properties:
|
||||||
|
hostname:
|
||||||
|
description: |-
|
||||||
|
Hostname is the fully qualified domain name of the device.
|
||||||
|
If MagicDNS is enabled in your tailnet, it is the MagicDNS name of the
|
||||||
|
node.
|
||||||
|
type: string
|
||||||
|
tailnetIPs:
|
||||||
|
description: |-
|
||||||
|
TailnetIPs is the set of tailnet IP addresses (both IPv4 and IPv6)
|
||||||
|
assigned to the device.
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
type: string
|
||||||
|
x-kubernetes-list-map-keys:
|
||||||
|
- hostname
|
||||||
|
x-kubernetes-list-type: map
|
||||||
|
served: true
|
||||||
|
storage: true
|
||||||
|
subresources:
|
||||||
|
status: {}
|
@ -0,0 +1,112 @@
|
|||||||
|
// Copyright (c) Tailscale Inc & AUTHORS
|
||||||
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
|
||||||
|
//go:build !plan9
|
||||||
|
|
||||||
|
package v1alpha1
|
||||||
|
|
||||||
|
import (
|
||||||
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
)
|
||||||
|
|
||||||
|
// +kubebuilder:object:root=true
|
||||||
|
// +kubebuilder:subresource:status
|
||||||
|
// +kubebuilder:resource:scope=Cluster,shortName=pg
|
||||||
|
// +kubebuilder:printcolumn:name="Status",type="string",JSONPath=`.status.conditions[?(@.type == "ProxyGroupReady")].reason`,description="Status of the deployed ProxyGroup resources."
|
||||||
|
|
||||||
|
type ProxyGroup struct {
|
||||||
|
metav1.TypeMeta `json:",inline"`
|
||||||
|
metav1.ObjectMeta `json:"metadata,omitempty"`
|
||||||
|
|
||||||
|
// Spec describes the desired ProxyGroup instances.
|
||||||
|
Spec ProxyGroupSpec `json:"spec"`
|
||||||
|
|
||||||
|
// ProxyGroupStatus describes the status of the ProxyGroup resources. This is
|
||||||
|
// set and managed by the Tailscale operator.
|
||||||
|
// +optional
|
||||||
|
Status ProxyGroupStatus `json:"status"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// +kubebuilder:object:root=true
|
||||||
|
|
||||||
|
type ProxyGroupList struct {
|
||||||
|
metav1.TypeMeta `json:",inline"`
|
||||||
|
metav1.ListMeta `json:"metadata"`
|
||||||
|
|
||||||
|
Items []ProxyGroup `json:"items"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ProxyGroupSpec struct {
|
||||||
|
// Type of the ProxyGroup, either ingress or egress. Each set of proxies
|
||||||
|
// managed by a single ProxyGroup definition operate as only ingress or
|
||||||
|
// only egress proxies.
|
||||||
|
Type ProxyClassType `json:"type"`
|
||||||
|
|
||||||
|
// Tags that the Tailscale devices will be tagged with. Defaults to [tag:k8s].
|
||||||
|
// If you specify custom tags here, make sure you also make the operator
|
||||||
|
// an owner of these tags.
|
||||||
|
// See https://tailscale.com/kb/1236/kubernetes-operator/#setting-up-the-kubernetes-operator.
|
||||||
|
// Tags cannot be changed once a ProxyGroup device has been created.
|
||||||
|
// Tag values must be in form ^tag:[a-zA-Z][a-zA-Z0-9-]*$.
|
||||||
|
// +optional
|
||||||
|
Tags Tags `json:"tags,omitempty"`
|
||||||
|
|
||||||
|
// Replicas specifies how many replicas to create the StatefulSet with.
|
||||||
|
// Defaults to 2.
|
||||||
|
// +optional
|
||||||
|
Replicas *int `json:"replicas,omitempty"`
|
||||||
|
|
||||||
|
// HostnamePrefix is the hostname prefix to use for tailnet devices created
|
||||||
|
// by the ProxyGroup. Each device will have the integer number from its
|
||||||
|
// StatefulSet pod appended to this prefix to form the full hostname.
|
||||||
|
// HostnamePrefix can contain lower case letters, numbers and dashes, it
|
||||||
|
// must not start with a dash and must be between 1 and 62 characters long.
|
||||||
|
// +optional
|
||||||
|
HostnamePrefix HostnamePrefix `json:"hostnamePrefix,omitempty"`
|
||||||
|
|
||||||
|
// ProxyClass is the name of the ProxyClass custom resource that contains
|
||||||
|
// configuration options that should be applied to the resources created
|
||||||
|
// for this ProxyGroup. If unset, and no default ProxyClass is set, the
|
||||||
|
// operator will create resources with the default configuration.
|
||||||
|
// +optional
|
||||||
|
ProxyClass string `json:"proxyClass,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ProxyGroupStatus struct {
|
||||||
|
// List of status conditions to indicate the status of the ProxyGroup
|
||||||
|
// resources. Known condition types are `ProxyGroupReady`.
|
||||||
|
// +listType=map
|
||||||
|
// +listMapKey=type
|
||||||
|
// +optional
|
||||||
|
Conditions []metav1.Condition `json:"conditions,omitempty"`
|
||||||
|
|
||||||
|
// List of tailnet devices associated with the ProxyGroup StatefulSet.
|
||||||
|
// +listType=map
|
||||||
|
// +listMapKey=hostname
|
||||||
|
// +optional
|
||||||
|
Devices []TailnetDevice `json:"devices,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type TailnetDevice struct {
|
||||||
|
// Hostname is the fully qualified domain name of the device.
|
||||||
|
// If MagicDNS is enabled in your tailnet, it is the MagicDNS name of the
|
||||||
|
// node.
|
||||||
|
Hostname string `json:"hostname"`
|
||||||
|
|
||||||
|
// TailnetIPs is the set of tailnet IP addresses (both IPv4 and IPv6)
|
||||||
|
// assigned to the device.
|
||||||
|
// +optional
|
||||||
|
TailnetIPs []string `json:"tailnetIPs,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// +kubebuilder:validation:Type=string
|
||||||
|
// +kubebuilder:validation:Enum=egress
|
||||||
|
type ProxyClassType string
|
||||||
|
|
||||||
|
const (
|
||||||
|
ProxyClassTypeEgress ProxyClassType = "egress"
|
||||||
|
)
|
||||||
|
|
||||||
|
// +kubebuilder:validation:Type=string
|
||||||
|
// +kubebuilder:validation:Pattern=`^[a-z0-9][a-z0-9-]{0,61}$`
|
||||||
|
type HostnamePrefix string
|
Loading…
Reference in New Issue