Commit Graph
8 Commits
Author SHA1 Message Date
Tiago Silva 4d09eea9b0 Add gRPC Kubernetes Service (#21103)
This PR introduces a gRPC service to retrieve the pods available using the `search_as_roles` configured in the user's roles.

This gRPC service receives a TLS identity and manipulates it to access the Teleport Kubernetes Proxy and retrieve the pods available for a hypothetical user that has the `search_as_roles` defined for its roles.
The response does not leak the certificate nor the pod details other than `name`, `namespace` and `labels`.

```mermaid
sequenceDiagram
    participant User as User
    participant gRPC as grpc Server
    participant Auth as Auth Server
    participant KubeProxy as Kube Proxy
    participant KubeSVC as Kube Service
    User->>+gRPC: ListKubeResources(cluster,namespace)
    Note left of gRPC: Includes search_as_roles <br/> and preview_as_roles <br/>into identity!
    gRPC-->>+Auth: Sign cert with ProcessKubeCSR
    Auth-->>-gRPC: Signed certificate
    gRPC->>+KubeProxy: list pods "v1.../namespaces/{namespace}/pods"
    KubeProxy-->>+KubeSVC: list pods "v1.../namespaces/{namespace}/pods"
    KubeSVC-->>-KubeProxy: filtered response
    Note left of KubeSVC: Applies Pod RBAC filtering!
    KubeProxy-->>-gRPC: response
    gRPC->>-User:Return name, namespace and labels
```

Part of #21107 and #19573
2023-02-06 22:45:31 +00:00
Tiago Silva df05a9385c Fix forwarding of impersonated headers for kubectl exec/portforward (#21102)
This PR fixes the impersonation headers propagation when using the SPDY
roundtrip. SPDY roundtrip creates a new http request and loses the
impersonation headers received from the client. When this happens for
users that define multiple `kubernetes_users`, the requests are denied
because Teleport forces you to select a user.

With the changes introduced we conserve the headers received from the
client.

Fixes #21088
2023-02-02 15:21:20 +00:00
Tiago Silva c3fe7c092f Update Kubernetes Dependencies (#19695)
This PR replaces the following PRs opened by dependabot:
- #19678 
- #19677 

It also bumps:

- Bump k8s.io/api from v0.25.4 to v0.26.0
- Bump k8s.io/apiextensions-apiserver from v0.25.4 to v0.26.0
- Bump k8s.io/apimachinery from v0.25.4 to v0.26.0
- Bump k8s.io/apiserver from v0.25.4 to v0.26.0
- Bump k8s.io/cli-runtime from v0.25.4 to v0.26.0
- Bump k8s.io/kubectl from v0.25.4 to v0.26.0
- Bump k8s.io/utils v0.0.0-20220728103510-ee6ede2d64ed to v0.0.0-20221128185143-99ec85e7a448
- Bump sigs.k8s.io/controller-runtime from v0.13.1 to v0.14.1
2022-12-29 22:49:22 +00:00
Tiago Silva 1c1b6b076b Kubernetes Portforward via Websockets (#18791)
This PR extends the Kubernetes Service to support the WebSocket
protocol in Kubernetes Porforward calls.

The Websocket protocol is required so that Kubernetes clients
like C#, Python, and Javascript can create portforward requests
to Kubernetes PODs. Although Teleport supports clients using WebSocket
protocol, it still uses SPDY protocol when connecting to upstreams -
Teleport Services or Kubernetes API.

Contrary to requests through SPDY, WebSocket requests do not support any
concurrency or multiplexing. This is a protocol limitation since
it only creates a single stream pair per port. When using it
concurrently, the requests will be mixed and fail.

Fixes #18783
2022-12-08 10:27:49 +00:00
Tiago Silva 7aab11b073 Terminate sessions when peers disconnect (#18552)
When any peer disconnects from a session without closing it, Teleport marks it as active and does not publish the session recordings. 

This PR closes the session once every peer disconnects to avoid leaving zombie sessions when a user intentionally blocks traffic or when a VPN disconnects.

It also waits until all events are pushed before closing the recorder.

Fixes #17848
Fixes #18194
2022-11-22 16:12:48 +00:00
Jakub Nyckowski 0ee91f6c37 Enable GCI linter (#17894) 2022-10-28 20:20:28 +00:00
Tiago Silva 45c065acee Adds kube_cluster watcher for kubernetes service (#16281)
This PR presents a watcher for dynamic `kube_cluster` resources. The cluster credentials can be set using a `kubeconfig` whose payload is defined in `KubernertesClusterV3.Spec.Kubeconfig`. These credentials are used to connect to the Kubernetes API server and if invalid, the cluster is not served and returns an error.

Currently, `kube_cluster` resources created via the API with a kubeconfig payload can be dynamically served by the `kubernetes_service` by enabling dynamic resources.

```yaml
kubernetes_service:
   enabled: true

   resources:
       labels:
           '*': '*'
```

# Future work
- The discovery service will have to create these resources. 
- Support Azure and AWS dynamic authentication

Part of #16135, #13376  
Related to  #12048, #16276
2022-09-23 17:07:13 +00:00
Tiago Silva 31a2e84c31 Kubernetes Exec via Websockets (#15475)
This PR extends the Kubernetes Service to support the WebSocket protocol in Kubernetes Exec calls.
The Websocket protocol is required so that Kubernetes clients like C#, Python, and Javascript can call the `exec` and `attach` methods.

File `remotecommand_websocket.go` was vendored from [kubernetes repo](https://github.com/kubernetes/kubernetes/blob/d5fdf3135e7c99e5f81e67986ae930f6a2ffb047/pkg/kubelet/cri/streaming/remotecommand/websocket.go).

Fixes #15463

Future work:
- Extend support for  `port-forward`
- Extend support for  `cp`
2022-09-09 16:55:11 +00:00