Commit Graph
62 Commits
Author SHA1 Message Date
Noah Stride 47ec6d7222 Operator support for WorkloadIdentity resource (#53484)
* Generate CRDs

* Update snapshots

* Add apis impl for WorkloadIdentity

* Add WorkloadIdentityReconciler

* Add test for WorkloadIdentityReconciler

* Update RBAC

* Update to include version in kind

* Fix license header

* Fix handling of well-known Struct type

* Ignore revsiion
2025-04-09 14:18:31 +00:00
Noah Stride 63e269a756 Operator support for Bot resource (#53453)
* Add `Bot` manifests

* Update protos

* Add Bot API resource impl

* Add reconciler

* Fix bot CRD "versions" name

* Fix Unmarshal/Marshal panic for 153 resources

* Fix update test

* Mispell Marshalling

* Generate docs page

* Update role.yaml

* Add TeleportBot to resource list

* Update contributing

* Try to update the versions per RFD160

* Update k8s rbac for new resource name

* Use proto binary encoding for Marshal/Unmarshal

* Clear out unversioned crd

* More efficient deepcopyinto

* Fix license

* Add unmarshal options for protojson

* Update golden

* Fix RBAC
2025-04-01 15:31:48 +00:00
rosstimothy ef859498bc Vendor gravitational/trace/trail in api (#51032)
* Vendor gravitational/trace/trail in api

Pulling in the trail package directly in api will allow the trace
module to shed the grpc-go dependency. This needs to land prior
to https://github.com/gravitational/trace/pull/112 being included
in a new version of trace.

There should be no noticable change in the api depdency tree since
it already depends on grpc-go. Some additional items from the
trace/internal package were also vendored within trail as needed.
Additionally, some of the public api of trail that was not being
consumed has been made private.

* fix: appease linters
2025-01-14 21:04:01 +00:00
Hugo Shakaandrosstimothy 4883a184cd Remove direct zap dependecy in operator and kube-agent-updater (#50960)
* Remove direct zap dependecy

* fixup! Remove direct zap dependecy

* Apply suggestions from code review

Co-authored-by: rosstimothy <39066650+rosstimothy@users.noreply.github.com>

---------

Co-authored-by: rosstimothy <39066650+rosstimothy@users.noreply.github.com>
2025-01-14 15:38:38 +00:00
Bernard Kim 646329da7d 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
2025-01-13 17:21:09 +00:00
rosstimothy 2c764e14b5 Reduce reliance on servicecfg.Config logrus logger (#50817)
Converts most items to use servicecfg.Config.Logger instead of
servicecfg.Config.Log. The deprecated logrus logger unfortunately
cannot be removed yet as it's still used in e. Additionally all
logging within the config package was converted to use slog.
2025-01-07 20:09:30 +00:00
Edoardo Spadolini bcbfa8192e Get rid of math/rand in favor of math/rand/v2 (#49294)
* Get rid of math/rand in favor of math/rand/v2

* Update retryutils to use rand.N

* Update e ref
2024-11-21 12:57:32 +00:00
Hugo Shaka 3e74e6dd40 operator: fix oidc conenctor max age (#48316) 2024-11-04 17:59:36 +00:00
Marek Smoliński a9adc59ba3 Fix TeleportOktaImportRule (#48197) 2024-10-31 10:20:33 +00:00
Maxim Dietz 9383c38bf0 fix: Provide membershipKind fields for owners/members in tests (#48191) 2024-10-31 02:43:46 +00:00
Steven Martinandrosstimothy d724cf229b logging spell fixes (#47450)
* logging spell fixes

* remove space in log message

Co-authored-by: rosstimothy <39066650+rosstimothy@users.noreply.github.com>

---------

Co-authored-by: rosstimothy <39066650+rosstimothy@users.noreply.github.com>
2024-10-10 17:30:48 +00:00
2ba79b2dcd operator: support storing SSO connector client secret in a Kubernetes Secret (#46699)
* Allow operator secret lookup

* Document which fields can lookup secrets

* operator: support secret lookup

* fixup! operator: support secret lookup

* Apply suggestions from code review

Co-authored-by: Paul Gottschling <paul.gottschling@goteleport.com>
Co-authored-by: Roman Tkachenko <roman@goteleport.com>

* lint

* add link to operator docs

* address feedback

* Revert "add link to operator docs"

This reverts commit cd812eb453.

---------

Co-authored-by: Paul Gottschling <paul.gottschling@goteleport.com>
Co-authored-by: Roman Tkachenko <roman@goteleport.com>
2024-09-20 21:44:22 +00:00
Marek Smoliński ee8a673560 Move OKTA TF tests to TerraformSuiteEnterprise (#46669) 2024-09-17 15:47:36 +00:00
Hugo Shaka b31523c123 operator: Add secretlookup library (#46570)
* operator: Add secretlookup lib

* fixup! operator: Add secretlookup lib

* fix tests + address feedback
2024-09-13 20:19:29 +00:00
Hugo Shaka 3e6b952338 operator: Simpler and more powerful Mutate function (#46566)
* operator: Simpler and more powerful Mutate function

* lint
2024-09-13 15:23:41 +00:00
Tiago Silva c0df3dc421 Update k8s.io deps to 1.31 (#46307) 2024-09-06 13:23:12 +00:00
Michelle Bergquist c97533ed22 Surface entitlements to auth (#42932) 2024-07-09 16:04:48 +00:00
Michelle Bergquist 70b95e385d Surface Cloud Entitlements (#42394)
- Cloud entitlements are now available on Features
- Legacy logic applies if entitlements are not present
2024-06-28 00:22:13 +00:00
Forrest 171758f6e8 remote Metadata.ID and Lease.ID fields (#41732) 2024-05-23 15:08:46 +00:00
Trent Clarke 1ba6e939df Removes the entire notion of a DynamicAccessList from Teleport (#39222)
* Removes the entire notion of a DynamicAccessList from Teleport

Insurmountable security issues were found with the notion of dynamic
AccessList ownership and membership, so the entire concept is being
removed.

This PR removes all internal usage of the Dynamic access list
concept. The corresponding protobuf updates are coming in a later
PR.

Changelog: Removed Dynamic AccessList

* Fix API tests

* More API test fixes

* Fix integrations tests
2024-03-14 07:51:11 +00:00
Hugo ShakaandNoah Stride 29e1e5bc14 Refactor operator to support several types of resources + propagate labels (#38992)
* Refactor operator resource reconciler to support resource153 + add label propagation

I initially just wanted to add label propagation (which is required for
OpenSSH and OpenSSHEICE servers).

However I ran into an issue: not all Teleport resources implement the
`ResourceWithLabels` interface.  Basically we have 4 cases:
- resources implementing `ResourceWithLabels` (e.g. User, Role, ...)
- resources implementing `ResourceWithOrigin` but not
  `ResourceWithLabels` (e.g. GitHub connector, ProvisionToken, ...)
- resources that have been tweaked to implement only the operator
  `TeleportResource` interface (`LoginRule`)
- resources implementing `Resource153`

To support all those resoucres, we can either:
- edit each resource so they expose the same methods (e.g.
  ProvisionToken exposes `GetLabels` instead of `GetStaticLabels`)
- wrap each ressource in a wrapper that implements the operator
  TeleportResource interface
- add multiple reconcilers, one for each resource kind

I don't think it's sane for the operator to force changes on Teleport
resources. Especially as those are known to be non consistent. I also
don't want the operator to maintain a copy of each resource, this is not
viable on the long term.

For those reasons I chose the 3rd approach and built 3 reconcilers. Then
I deducplicated the code to end up with a generic reconciler that can be
tuned by passing an adapter. The adapter is an empty struct that has all
the methods to extract the information the operator requires from the
resource.

The resulting PR is large and heavily uses generics but the amount of
logical changes is quite low (the only diff is that we now copy labels).
I can walk you through the PR if needed.

With this PR, the operator supports properly any resource implementing
`types.Resource153`, this will be useful to add `TeleportBotV1` support.

* Update integrations/operator/controllers/reconcilers/base.go

Co-authored-by: Noah Stride <noah.stride@goteleport.com>

* use structured logging

---------

Co-authored-by: Noah Stride <noah.stride@goteleport.com>
2024-03-07 21:17:13 +00:00
Michael Wilson 0b526b50fe Ignore the status field in access list operator tests. (#38776)
The operator tests will now skip the access list status field.
2024-02-29 17:36:24 +00:00
Hugo ShakaandMarco André Dinis 288f87af1b integrations/operator: Add openSSH and openSSHEICE servers (#37651)
* integrations/operator: Add openSSH and openSSHEICE servers

* lint

* Update integrations/operator/controllers/resources/openssheiceserverv2_controller.go

Co-authored-by: Marco André Dinis <marco.dinis@goteleport.com>

* rename Openssh to OpenSSH and fix comments

* hide cmdlabels

---------

Co-authored-by: Marco André Dinis <marco.dinis@goteleport.com>
2024-02-20 23:07:26 +00:00
Hugo Shaka f95d1d9092 integrations/operator: Fix the operator deleting unowned resources (#37655)
* integrations/operator: Fix the operator deleting unowned resources

* Update integrations/operator/controllers/resources/teleport_reconciler.go

* add license
2024-02-03 02:09:51 +00:00
Hugo Shaka 3ffb95f984 fix operator role controller (#37275) 2024-01-25 19:42:25 +00:00
Hugo Shaka 9b45ebd1d4 Add role v6 and role v7 controllers (#36840)
* Add role v6 and role v7 controllers

* lint
2024-01-25 15:12:58 +00:00
Hugo Shaka fb97a39bde integrations/operator: add ignore and keep flags for CRs (#37182)
* integrations/operator: add ignore and keep flags for CRs

* lint + address feedback
2024-01-24 22:32:27 +00:00
Hugo Shaka 7b02cada13 integrations/operator: support multiple versions of the same resource in crdgen (#36715)
The commit contains the following changes:

- add multi-version support by creating new kinds. This is currently done via an override to maintain compatibility. At some point, we might migrate unversioned kinds (TeleportRole) to versioned kinds (TeleportRoleV5) and remove the override
- unify all resource statuses in a single struct. This simplifies the CRD building because we are not trying to guess which package is correct anymore when parsing go's AST
- update crdgen snapshots

This PR does not update the base CRDs in the operator or the Hlem chart. This will happen in the next PR, adding go types and controller support.

Note for reviewers: the changeset might seem large, but the changes are split into commits that are much more reviewable. You only need to review the first two commits.
2024-01-24 01:33:29 +00:00
Hugo Shaka ac7dff07ff Move role controller to standard Teleport controller (#36836) 2024-01-22 19:45:43 +00:00
Hugo Shaka b16513bc67 operator: fix access lists step by step mutation tests (#36897) 2024-01-18 23:57:26 +00:00
Hugo Shaka 4dfc23442f integrations/operator: use unstructured objects for all controllers (#36142)
This commit prepares everything for us to switch to a single reconciler for all resources. Part of https://github.com/gravitational/teleport/issues/21416

This commit does the following changes:
- setup controllers for the unstructured objects instead of the structured ones (like `Role` was doing). This is due to the bad behaviour of `utils.Strings` of serializing as a single string if the list contains a single element.
- use a single scheme for everything instead of multiple ones. We suffered from drifts between main and tests in the past.
- fetch the GVK for the unstructure objects from the scheme. This operation can fail and now a bunch of builder/init functions can return errors
- Introduce a new `Reconciler` interface to hide the controller internals
- unify how controllers are started in main and tests. This is not directly related to the PR goal (preparing the ground for a unified controller) but I was drawn into this when I made the constructors return errors.
2024-01-17 15:43:26 +00:00
Andrew Burke 840af310db Convert insecure-drop to drop for unsupported clients (#35803)
This change converts the insecure-drop host user creation mode
to drop for clients that don't support it.
2024-01-11 01:06:18 +00:00
Hugo Shaka c9b1ab013a Use cmp and cmpots properly in operator tests (#36215)
This commit creates a standard set of compare options for all tests that
handles the common use cases:
- ignore ID, labels and other dynamic metadata
- apply sane time comparison by default
- equates nil maps and empty maps (caused by proto serialization)

This solves a couple of comparison issues I faced in another PR.
2024-01-03 14:59:35 +00:00
Hugo Shaka 619f900e1c integrations/operator: Add AccessList support (#31771)
* integrations/operator: add support for access lists

* fixup! integrations/operator: add support for access lists
2023-12-18 19:36:39 +00:00
Hugo Shaka 856bb39ea9 Add a version server in the proxy + use it in agent chart (#35150)
This PR adds an embedded [version server](https://goteleport.com/docs/architecture/agent-update-management/#version-server-and-source-of-truth) in the proxy to address: https://github.com/gravitational/cloud/issues/6773

The version server can be configured through `teleport.yaml`:

```yaml
proxy_service:
  enabled: "yes"
  automatic_upgrades_channels:
    stable/cloud:
      forward_url: https://updates.releases.teleport.dev/v1/stable/cloud
    preview/cloud:
      static_version: v12.5.4
```

The forwarded call results are cached for a minute.
2023-12-12 01:03:45 +00:00
Andrew Burke 56e6ace218 Remove drop host user creation mode (#35524)
This change removes the drop host user creation mode.
2023-12-11 19:07:29 +00:00
rosstimothy 85c29d1cf4 Implement and use UpsertOIDCConnectorV2 (#35144)
While the api client already had support for the new upsert method
it was unimplemented server side and would always fallback to the
legacy UpsertOIDCConnector RPC. This implements the RPC handler
and updates the signature of UpsertOIDCConnector to return the
upserted connector in the same manner that Create and Update do.
2023-12-01 19:22:41 +00:00
fheinecke b178b8b732 Updated Teleport codebase to AGPL3 license (#35259)
Signed-off-by: Fred Heinecke <fred.heinecke@goteleport.com>
2023-12-01 17:48:14 +00:00
rosstimothy 88bb9cfd96 Implement and use UpsertSAMLConnectorV2 (#35208)
While the api client already had support for the new upsert method
it was unimplemented server side and would always fallback to the
legacy UpsertSAMLConnector RPC. This implements the RPC handler
and updates the signature of UpsertSAMLConnector to return the
upserted connector in the same manner that Create and Update do.
2023-11-30 19:09:44 +00:00
rosstimothy b2bc325703 Implement and use UpsertGithubConnectorV2 (#35132)
While the api client already had support for the new upsert method
it was unimplemented server side and would always fallback to the
legeacy UpsertGithubConnector RPC. This implements the RPC handler
and updates the signature of UpsertGithubConnector to return the
upserted connector in the same manner that Create and Update do.
2023-11-30 15:01:40 +00:00
Hugo ShakaandTiago Silva f31a90d4a4 integrations/operator: Standalone operator with reusable client (#34482)
* Standalone operator using tbot

* Update integrations/operator/embeddedtbot/bot.go

Co-authored-by: Tiago Silva <tiago.silva@goteleport.com>

* make teleportClient private

* lint

---------

Co-authored-by: Tiago Silva <tiago.silva@goteleport.com>
2023-11-23 17:23:18 +00:00
Hugo Shaka f67478dd9d integrations/operator: split mutator interface in two (#34728)
- MutateExisting for resource update
- Mutate for resource creation
2023-11-22 18:38:05 +00:00
Hugo Shaka df257bed9c integrations/operator: re-use the teleport client instead of creating a new one (#34050)
* integrations/operator: re-use the teleport client instead of creating a new one

* fix race condition

* address feedback + add godocs
2023-11-07 22:05:42 +00:00
Hugo Shaka 0a51fa01b9 integrations/operator: remove require checks from Eventually funcs (#34270)
* use eventuallyWithT

* integrations/operator: remove require checks from Eventually funcs

* fixup! integrations/operator: remove require checks from Eventually funcs
2023-11-07 20:40:02 +00:00
Hugo Shaka 3a8a07f158 integrations/operator: propagate revision + fix tests (#34265)
* operator: propagate revision info + fix tests

* fixup! operator: propagate revision info + fix tests
2023-11-07 17:48:20 +00:00
rosstimothy d5a796c056 Enable testify lint (#34222)
Updates our golangci-lint configuration to enable testifylint and
fixes all issues found.

Bump e ref to include gravitational/teleport.e#2567
2023-11-06 20:38:38 +00:00
Tiago Silva 9750a455e5 Fix Teleport update reconciliation on status updates (#34063)
* Fix Teleport update reconciliation on `status` updates

This pull request addresses the issue where the Teleport operator reconciliation runs every time the operator updates the `status` subresource.
This continuous reconciliation has led to an infinite loop, causing millions of reconciliations per minute.
When an error occurs, such as having invalid role properties, the Operator updates the status and returns an error, which should trigger a rescheduled reconciliation with exponential backoff. The problem arises because the operator failed to enforce a resource generation change, resulting in an immediate trigger of a new reconciliation when the `status` field is updated.

This pull request modifies the operator to avoid updating subresources and only trigger updates when there is a change in resource generation.

Special thanks to @strideynet for confirming my hypothesis and giving
the solution!

Signed-off-by: Tiago Silva <tiago.silva@goteleport.com>

* return proper status conditions on failures

* enforce condition update on silentUpdateStatus

---------

Signed-off-by: Tiago Silva <tiago.silva@goteleport.com>
2023-11-02 22:27:23 +00:00
rosstimothy 2087a2fda8 Implement Create/UpdateRole on the auth server (#33491)
In addition to adding server and backend handling for create and
update roles, the services.Access interface was updated to return
a role from the existing Create/UpsertRole methods. Bumps the e
ref to incorporate the associated changes needed there to prevent
breaking the build.
2023-10-18 17:06:50 +00:00
rosstimothy b60ea81d54 Update users interface (#32987)
services.UsersService now takes a context and returns the user
from write operations as shown in the diff below. The bulk of the
changes are from modifying code to account for the additional
parameter and/or return value. Functional changes to better make
use of the new API will come in follow up PRs.

```diff
// UserGetter is responsible for getting users
type UserGetter interface {
	// GetUser returns a user by name
-	GetUser(user string, withSecrets bool) (types.User, error)
+	GetUser(ctx context.Context, user string, withSecrets bool) (types.User, error)
}

// UsersService is responsible for basic user management
type UsersService interface {
	UserGetter
	// CreateUser creates user, only if the user entry does not exist
-	CreateUser(user types.User) error
+	CreateUser(ctx context.Context, user types.User) (types.User, error)
	// UpdateUser updates an existing user.
-	UpdateUser(ctx context.Context, user types.User) error
+	UpdateUser(ctx context.Context, user types.User) (types.User, error)
	// UpdateAndSwapUser reads an existing user, runs `fn` against it and writes
	// the result to storage. Return `false` from `fn` to avoid storage changes.
	// Roughly equivalent to [GetUser] followed by [CompareAndSwapUser].
	// Returns the storage user.
	UpdateAndSwapUser(ctx context.Context, user string, withSecrets bool, fn func(types.User) (changed bool, err error)) (types.User, error)
	// UpsertUser updates parameters about user
-	UpsertUser(user types.User) error
+	UpsertUser(ctx context.Context, user types.User) (types.User, error)
	// CompareAndSwapUser updates an existing user, but fails if the user does
	// not match an expected backend value.
	CompareAndSwapUser(ctx context.Context, new, existing types.User) error
	// DeleteUser deletes a user with all the keys from the backend
	DeleteUser(ctx context.Context, user string) error
	// GetUsers returns a list of users registered with the local auth server
-	GetUsers(withSecrets bool) ([]types.User, error)
+	GetUsers(ctx context.Context, withSecrets bool) ([]types.User, error)
	// DeleteAllUsers deletes all users
-	DeleteAllUsers() error
+	DeleteAllUsers(ctx context.Context) error
}
```

Depends on gravitational/teleport.e#2346
Implements step 3 of #32949
2023-10-10 14:07:46 +00:00
Tiago Silva 9a556d8ab1 Add support for Protobuf Enums into Operator CRDs (#32469)
* Add support for Protobuf Enums into Operator CRDs

This PR marks the Teleport enum fields as integer or string values. The
integer option is to ensure we are backwards compatibile with
previously installed CRDs.

Users can now represent their roles in Kubernetes custom resources and
refer enum fields as strings while their protobuf wire type is int32.

Fixes #29686

* add tests

* fix unit test
2023-09-26 13:43:50 +00:00