Commit Graph
31 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
Maxim Dietz 9383c38bf0 fix: Provide membershipKind fields for owners/members in tests (#48191) 2024-10-31 02:43:46 +00:00
Tiago Silva c0df3dc421 Update k8s.io deps to 1.31 (#46307) 2024-09-06 13:23:12 +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 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
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
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
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 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
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
Michael Wilson 46f8fbe0c8 k8s operator supports Okta import rules. (#28158)
* k8s operator supports Okta import rules.

The k8s operator now supports Okta import rules, which will allow users to
use native k8s CRDs to provision Okta import rules in k8s environments.

* Fix helm test.

* Remove unneeded proto files.

* Use additionalProperties in the okta import rules CRD instead of properties.
2023-06-27 14:16:53 +00:00
Zac Bergquist 80707cd328 Remove duplicate imports (#27886) 2023-06-15 17:06:18 +00:00
Hugo Shaka e710b012c1 integrations/operator: Use a dedicated scheme in tests (#26782)
* integrations/operator: Use a dedicated scheme in tests

Relying on a global scheme can cause race-conditions when registering
schema in multiple tests. This commit does two things in an attempt to
fix https://github.com/gravitational/teleport/issues/26753:

- use a separate Scheme for tests to avoid being affected by what others
  might be doing with the scheme
- initiate the Scheme only once during import

* unexport scheme
2023-05-25 09:26:01 +00:00
Hugo Shaka 37aa916859 operator: ProvisionToken support (#18718)
* crdgen: properly index nested types

* integrations/operator: Add ProvisionTokenV2 CRD

* integrations/operator: regenerate CRDs

* integrations/operator: Add provisiontoken controller

* helm: update snapshots to include provisiontoken crs
2023-05-19 15:56:25 +00:00
Zac Bergquist 8d0769ef5f Remove duplicate imports (#24736) 2023-04-18 19:08:26 +00:00
Nic Klaassen a7ba75e511 chore: refactor k8s operator test helpers (#23552)
* refactor controller tests

* move envtest installation into envtest.mk for use in teleport.e
2023-03-28 14:43:27 +00:00