-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
operator: Support trusted_cluster resources (#49920)
* Add UpsertTrustedClusterV2 rpc This supersedes UpsertTrustedCluster rpc. V2 performs resource name validation. * Replace confusing UpsertValidationTrustedCluster name * Use UpsertTrustedClusterV2 in tests * Address feedback - Remove unnecessary ping - Update error messages - Use skipNameValidation consts - Validate cluster name before establishing trust - Do not reveal cluster name in error message - Use BadParameter instead of CompareFailed * Use webclient.Find * Fix test/lint * Allow label updates * Fix test * Update CRDs 1. Run `make manifests`. 2. Run `make -C crdgen update-protos`. 3. Run `make -C crdgen update-snapshot`. * Implement trusted_cluster CRD * Update docs * Support secret lookup * Update secret lookup docs * Fix error handling * Use V2 * Implement CreateTrustedClusterV2 and UpdateTrustedClusterV2 * Address feedback * Minor fixes * Use Create/Update instead of Upsert * Update crdgen * Update trusted_cluster tests * Move V2 RPCs to the trust service * crdgen * Remove V2 suffix * 2024 -> 2025 * Use slog
- Loading branch information
1 parent
9948ed4
commit 646329d
Showing
32 changed files
with
2,074 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
...pages/reference/operator-resources/resources.teleport.dev_trustedclustersv2.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
--- | ||
title: TeleportTrustedClusterV2 | ||
description: Provides a comprehensive list of fields in the TeleportTrustedClusterV2 resource available through the Teleport Kubernetes operator | ||
tocDepth: 3 | ||
--- | ||
|
||
{/*Auto-generated file. Do not edit.*/} | ||
{/*To regenerate, navigate to integrations/operator and run "make crd-docs".*/} | ||
|
||
This guide is a comprehensive reference to the fields in the `TeleportTrustedClusterV2` | ||
resource, which you can apply after installing the Teleport Kubernetes operator. | ||
|
||
|
||
## resources.teleport.dev/v1 | ||
|
||
**apiVersion:** resources.teleport.dev/v1 | ||
|
||
|Field|Type|Description| | ||
|---|---|---| | ||
|apiVersion|string|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| | ||
|kind|string|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| | ||
|metadata|object|| | ||
|spec|[object](#spec)|TrustedCluster resource definition v2 from Teleport| | ||
|
||
### spec | ||
|
||
|Field|Type|Description| | ||
|---|---|---| | ||
|enabled|boolean|Enabled is a bool that indicates if the TrustedCluster is enabled or disabled. Setting Enabled to false has a side effect of deleting the user and host certificate authority (CA).| | ||
|role_map|[][object](#specrole_map-items)|RoleMap specifies role mappings to remote roles.| | ||
|token|string|Token is the authorization token provided by another cluster needed by this cluster to join. This field supports secret lookup. See the operator documentation for more details.| | ||
|tunnel_addr|string|ReverseTunnelAddress is the address of the SSH proxy server of the cluster to join. If not set, it is derived from `<metadata.name>:<default reverse tunnel port>`.| | ||
|web_proxy_addr|string|ProxyAddress is the address of the web proxy server of the cluster to join. If not set, it is derived from `<metadata.name>:<default web proxy server port>`.| | ||
|
||
### spec.role_map items | ||
|
||
|Field|Type|Description| | ||
|---|---|---| | ||
|local|[]string|Local specifies local roles to map to| | ||
|remote|string|Remote specifies remote role name to map from| | ||
|
149 changes: 149 additions & 0 deletions
149
...ster/charts/teleport-operator/operator-crds/resources.teleport.dev_trustedclustersv2.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
apiVersion: apiextensions.k8s.io/v1 | ||
kind: CustomResourceDefinition | ||
metadata: | ||
creationTimestamp: null | ||
name: teleporttrustedclustersv2.resources.teleport.dev | ||
spec: | ||
group: resources.teleport.dev | ||
names: | ||
kind: TeleportTrustedClusterV2 | ||
listKind: TeleportTrustedClusterV2List | ||
plural: teleporttrustedclustersv2 | ||
shortNames: | ||
- trustedclusterv2 | ||
- trustedclustersv2 | ||
singular: teleporttrustedclusterv2 | ||
scope: Namespaced | ||
versions: | ||
- name: v1 | ||
schema: | ||
openAPIV3Schema: | ||
description: TrustedClusterV2 is the Schema for the trustedclustersv2 API | ||
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: TrustedCluster resource definition v2 from Teleport | ||
properties: | ||
enabled: | ||
description: Enabled is a bool that indicates if the TrustedCluster | ||
is enabled or disabled. Setting Enabled to false has a side effect | ||
of deleting the user and host certificate authority (CA). | ||
type: boolean | ||
role_map: | ||
description: RoleMap specifies role mappings to remote roles. | ||
items: | ||
properties: | ||
local: | ||
description: Local specifies local roles to map to | ||
items: | ||
type: string | ||
nullable: true | ||
type: array | ||
remote: | ||
description: Remote specifies remote role name to map from | ||
type: string | ||
type: object | ||
type: array | ||
token: | ||
description: Token is the authorization token provided by another | ||
cluster needed by this cluster to join. This field supports secret | ||
lookup. See the operator documentation for more details. | ||
type: string | ||
tunnel_addr: | ||
description: ReverseTunnelAddress is the address of the SSH proxy | ||
server of the cluster to join. If not set, it is derived from `<metadata.name>:<default | ||
reverse tunnel port>`. | ||
type: string | ||
web_proxy_addr: | ||
description: ProxyAddress is the address of the web proxy server of | ||
the cluster to join. If not set, it is derived from `<metadata.name>:<default | ||
web proxy server port>`. | ||
type: string | ||
type: object | ||
status: | ||
description: Status defines the observed state of the Teleport resource | ||
properties: | ||
conditions: | ||
description: Conditions represent the latest available observations | ||
of an object's state | ||
items: | ||
description: Condition contains details for one aspect of the current | ||
state of this API Resource. | ||
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. | ||
format: date-time | ||
type: string | ||
message: | ||
description: |- | ||
message is a human readable message indicating details about the transition. | ||
This may be an empty string. | ||
maxLength: 32768 | ||
type: string | ||
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. | ||
format: int64 | ||
minimum: 0 | ||
type: integer | ||
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. | ||
maxLength: 1024 | ||
minLength: 1 | ||
pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$ | ||
type: string | ||
status: | ||
description: status of the condition, one of True, False, Unknown. | ||
enum: | ||
- "True" | ||
- "False" | ||
- Unknown | ||
type: string | ||
type: | ||
description: type of condition in CamelCase or in foo.example.com/CamelCase. | ||
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])$ | ||
type: string | ||
required: | ||
- lastTransitionTime | ||
- message | ||
- reason | ||
- status | ||
- type | ||
type: object | ||
type: array | ||
teleportResourceID: | ||
format: int64 | ||
type: integer | ||
type: object | ||
type: object | ||
served: true | ||
storage: true | ||
subresources: | ||
status: {} | ||
status: | ||
acceptedNames: | ||
kind: "" | ||
plural: "" | ||
conditions: null | ||
storedVersions: null |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
96 changes: 96 additions & 0 deletions
96
integrations/operator/apis/resources/v1/trusted_cluster_types.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
/* | ||
* Teleport | ||
* Copyright (C) 2025 Gravitational, Inc. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package v1 | ||
|
||
import ( | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
|
||
"github.com/gravitational/teleport/api/types" | ||
"github.com/gravitational/teleport/integrations/operator/apis/resources" | ||
) | ||
|
||
func init() { | ||
SchemeBuilder.Register(&TeleportTrustedClusterV2{}, &TeleportTrustedClusterV2List{}) | ||
} | ||
|
||
//+kubebuilder:object:root=true | ||
//+kubebuilder:subresource:status | ||
|
||
// TeleportTrustedClusterV2 is the Schema for the trusted_clusters API | ||
type TeleportTrustedClusterV2 struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ObjectMeta `json:"metadata,omitempty"` | ||
|
||
Spec TeleportTrustedClusterV2Spec `json:"spec,omitempty"` | ||
Status resources.Status `json:"status,omitempty"` | ||
} | ||
|
||
//+kubebuilder:object:root=true | ||
|
||
// TeleportTrustedClusterV2List contains a list of TeleportTrustedClusterV2 | ||
type TeleportTrustedClusterV2List struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ListMeta `json:"metadata,omitempty"` | ||
Items []TeleportTrustedClusterV2 `json:"items"` | ||
} | ||
|
||
// ToTeleport converts the resource to the teleport trusted_cluster API type. | ||
func (r TeleportTrustedClusterV2) ToTeleport() types.TrustedCluster { | ||
return &types.TrustedClusterV2{ | ||
Kind: types.KindTrustedCluster, | ||
Version: types.V2, | ||
Metadata: types.Metadata{ | ||
Name: r.Name, | ||
Labels: r.Labels, | ||
Description: r.Annotations[resources.DescriptionKey], | ||
}, | ||
Spec: types.TrustedClusterSpecV2(r.Spec), | ||
} | ||
} | ||
|
||
// TeleportTrustedClusterV2Spec defines the desired state of TeleportTrustedClusterV2 | ||
type TeleportTrustedClusterV2Spec types.TrustedClusterSpecV2 | ||
|
||
// Marshal serializes a spec into binary data. | ||
func (spec *TeleportTrustedClusterV2Spec) Marshal() ([]byte, error) { | ||
return (*types.TrustedClusterSpecV2)(spec).Marshal() | ||
} | ||
|
||
// Unmarshal deserializes a spec from binary data. | ||
func (spec *TeleportTrustedClusterV2Spec) Unmarshal(data []byte) error { | ||
return (*types.TrustedClusterSpecV2)(spec).Unmarshal(data) | ||
} | ||
|
||
// DeepCopyInto deep-copies one trusted_cluster spec into another. | ||
// Required to satisfy runtime.Object interface. | ||
func (spec *TeleportTrustedClusterV2Spec) DeepCopyInto(out *TeleportTrustedClusterV2Spec) { | ||
data, err := spec.Marshal() | ||
if err != nil { | ||
panic(err) | ||
} | ||
*out = TeleportTrustedClusterV2Spec{} | ||
if err = out.Unmarshal(data); err != nil { | ||
panic(err) | ||
} | ||
} | ||
|
||
// StatusConditions returns a pointer to Status.Conditions slice. | ||
func (r *TeleportTrustedClusterV2) StatusConditions() *[]metav1.Condition { | ||
return &r.Status.Conditions | ||
} |
Oops, something went wrong.