Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

operator: Support trusted_cluster resources #49920

Open
wants to merge 34 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 32 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
fb760dc
Add UpsertTrustedClusterV2 rpc
bernardjkim Dec 4, 2024
bc9e0fb
Replace confusing UpsertValidationTrustedCluster name
bernardjkim Dec 5, 2024
415d72e
Use UpsertTrustedClusterV2 in tests
bernardjkim Dec 5, 2024
7049271
Address feedback
bernardjkim Dec 5, 2024
7ebe5ce
Merge branch 'master' into bernard/upsert-trusted-cluster-v2
bernardjkim Dec 5, 2024
1933ba6
Use webclient.Find
bernardjkim Dec 5, 2024
cb1f827
Fix test/lint
bernardjkim Dec 5, 2024
6243ff2
Allow label updates
bernardjkim Dec 6, 2024
4142256
Fix test
bernardjkim Dec 6, 2024
5db82b4
Merge branch 'master' into bernard/upsert-trusted-cluster-v2
bernardjkim Dec 6, 2024
fb595da
Update CRDs
bernardjkim Dec 4, 2024
22c6756
Implement trusted_cluster CRD
bernardjkim Dec 4, 2024
59ba288
Update docs
bernardjkim Dec 4, 2024
ecaba63
Support secret lookup
bernardjkim Dec 7, 2024
6b86dd1
Update secret lookup docs
bernardjkim Dec 7, 2024
330a663
Fix error handling
bernardjkim Dec 7, 2024
da215a7
Use V2
bernardjkim Dec 7, 2024
8cef186
Merge branch 'bernard/upsert-trusted-cluster-v2' into bernard/operato…
bernardjkim Dec 7, 2024
456a2fe
Implement CreateTrustedClusterV2 and UpdateTrustedClusterV2
bernardjkim Dec 10, 2024
d3118e2
Address feedback
bernardjkim Dec 10, 2024
aa82d22
Minor fixes
bernardjkim Dec 10, 2024
96eea47
Merge branch 'master' into bernard/upsert-trusted-cluster-v2
bernardjkim Dec 10, 2024
8f7f07f
Merge branch 'bernard/upsert-trusted-cluster-v2' into bernard/operato…
bernardjkim Dec 10, 2024
f2bce6b
Use Create/Update instead of Upsert
bernardjkim Dec 10, 2024
6bdd505
Update crdgen
bernardjkim Dec 11, 2024
cef0e90
Update trusted_cluster tests
bernardjkim Dec 11, 2024
258bed4
Move V2 RPCs to the trust service
bernardjkim Dec 11, 2024
c110cc5
Merge branch 'bernard/upsert-trusted-cluster-v2' into bernard/operato…
bernardjkim Dec 12, 2024
b484559
Merge branch 'master' into bernard/operator-trusted-cluster
bernardjkim Dec 12, 2024
f208a74
Merge branch 'master' into bernard/operator-trusted-cluster
bernardjkim Jan 6, 2025
5b76e91
crdgen
bernardjkim Jan 6, 2025
86365e0
Remove V2 suffix
bernardjkim Jan 6, 2025
b9ecc1b
2024 -> 2025
bernardjkim Jan 9, 2025
97a97ad
Merge branch 'master' into bernard/operator-trusted-cluster
bernardjkim Jan 9, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ of the Teleport Kubernetes operator CRs.
Some Teleport resources might contain sensitive values. Select CR fields can reference an existing
Kubernetes secret and the operator will retrieve the value from the secret when reconciling.

Currently only the GithubConnector and OIDCConnector `client_secret` field support secret lookup.
Currently supported fields for secret lookup:
- GithubConnector `client_secret`
- OIDCConnector `client_secret`
- TrustedClusterV2 `token`

## Prerequisites

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,21 @@ could cause instability and non-deterministic behaviour.
</Admonition>

Currently supported Teleport resources are:
- users (`TeleportUser`)
- roles
- Users (`TeleportUser`)
- Roles
- `TeleportRole` creates role v5
- `TeleportRoleV6` creates role v6
- `TeleportRoleV7` creates role v7
- OIDC connectors (`TeleportOIDCConnector`)
- SAML connectors (`TeleportSAMLConnector`)
- GitHub connectors (`TeleportGithubConnector`)
- provision tokens (`TeleportProvisionToken`)
- Login Rules (`TeleportLoginRules`)
- OIDC Connectors (`TeleportOIDCConnector`)
- SAML Connectors (`TeleportSAMLConnector`)
- GitHub Connectors (`TeleportGithubConnector`)
- Provision Tokens (`TeleportProvisionToken`)
- Login Rules (`TeleportLoginRule`)
- Access Lists (`TeleportAccessList`)
- Okta Import Rules (`TeleportOktaImportRule`)
- OpenSSHEICE Servers (`TeleportOpenSSHEICEServerV2`)
- OpenSSH Servers (`TeleportOpenSSHServerV2`)
- Trusted Clusters (`TeleportTrustedClusterV2`)

### Setting up the operator

Expand Down
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|

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
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ rules:
- teleportopensshserversv2/status
- teleportopenssheiceserversv2
- teleportopenssheiceserversv2/status
- teleporttrustedclustersv2
- teleporttrustedclustersv2/status
verbs:
- get
- list
Expand Down
8 changes: 8 additions & 0 deletions examples/chart/teleport-cluster/templates/auth/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,14 @@ data:
- read
- update
- delete
- resources:
- trusted_cluster
verbs:
- list
- create
- read
- update
- delete
deny: {}
version: v7
---
Expand Down
4 changes: 4 additions & 0 deletions integrations/operator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ The operator supports reconciling the following Kubernetes CRs:
- TeleportRoleV7 (creates role v7)
- TeleportProvisionToken
- TeleportGithubConnector
- TeleportAccessList
- TeleportOpenSSHEICEServerV2
- TeleportOpenSSHServerV2
- TeleportTrustedClusterV2
- TeleportSAMLConnector [1]
- TeleportOIDCConnector [1]
- TeleportLoginRule [1]
Expand Down
96 changes: 96 additions & 0 deletions integrations/operator/apis/resources/v1/trusted_cluster_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
/*
* Teleport
* Copyright (C) 2024 Gravitational, Inc.
bernardjkim marked this conversation as resolved.
Show resolved Hide resolved
*
* 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 {
Comment on lines +35 to +36
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need the V2 suffix?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
}
Loading
Loading