Skip to content

proto/accessgraph: Add RPC for sending k8s audit logs to Access Graph#59566

Merged
camscale merged 2 commits intomasterfrom
camh/tag/kube-audit-log-grpc
Oct 16, 2025
Merged

proto/accessgraph: Add RPC for sending k8s audit logs to Access Graph#59566
camscale merged 2 commits intomasterfrom
camh/tag/kube-audit-log-grpc

Conversation

@camscale
Copy link
Copy Markdown
Contributor

@camscale camscale commented Sep 25, 2025

Add a KubeAuditLogsStream() rpc to the AccessGraphService for
streaming Kubernetes apiserver audit logs from the Teleport discovery
service to access graph. This is intended for EKS audit logs which are
made available via CloudWatch, but can accommodate other k8s services.

The audit log messages are represented as a google.protobuf.Struct so
as to not depend on the k8s.io .proto files, but also as k8s typically
uses protos internally only - the expectation is that we'll receive the
apiserver audit logs as json-encoded strings. This encodes easily as a
google.protobuf.Struct.

Link: https://github.com/kubernetes/kubernetes/blob/master/staging/src/k8s.io/apiserver/pkg/apis/audit/v1/generated.proto
Issue: https://github.com/gravitational/access-graph/issues/1589

// effective configuration.
// 3. Server sends second response providing the starting `resume_state` (possilby empty).
// 4. Client sends subsequent `KubeAuditLogStreamRequest` messages.
rpc KubeAuditLogStream(stream KubeAuditLogStreamRequest) returns (stream KubeAuditLogStreamResponse);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

A client that wants to push logs for multi clusters should create one or the same stream can be used for multiple kubernetes logs?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

One stream for multiple clusters is the intended use, but I haven't really considered scalability. The server side loops over the stream in a single goroutine currently which might be a bottleneck if many clusters are providing their log over the same stream. However that's a detail not necessarily relevant to this grpc spec.

I'll add another point to the doc comment:

  // - Logs for multiple clusters can be streamed across the one stream, but
  //   they must be all for the same KubeAuditLogSource. Multiple streams may
  //   be used for the same log source if needed for scalability.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I have revised this further after adding dynamic behaviour to the fetcher (detecting clusters coming and going and handling discovery_config resources) - you can still stream multiple log streams over the one grpc stream, but each stream is explicitly started so that the resumption cursor is sent when the log stream starts and not when the grpc connection is created.

@camscale camscale force-pushed the camh/tag/kube-audit-log-grpc branch from 98ad7de to 1891ce0 Compare October 14, 2025 07:47
@camscale camscale marked this pull request as ready for review October 15, 2025 03:21
@github-actions github-actions bot requested a review from smallinsky October 15, 2025 03:22
@camscale
Copy link
Copy Markdown
Contributor Author

camscale commented Oct 15, 2025

reviewers - this is now ready for review, with a revision after adding dynamic behaviour to the code.

@camscale camscale added the no-changelog Indicates that a PR does not require a changelog entry label Oct 15, 2025
Add a `KubeAuditLogsStream()` rpc to the `AccessGraphService` for
streaming Kubernetes apiserver audit logs from the Teleport discovery
service to access graph. This is intended for EKS audit logs which are
made available via CloudWatch, but can accommodate other k8s services.

The audit log messages are represented as a `google.protobuf.Struct` so
as to not depend on the k8s.io .proto files, but also as k8s typically
uses protos internally only - the expectation is that we'll receive the
apiserver audit logs as json-encoded strings. This encode easily as a
`google.protobuf.Struct`.
Generate proto and grpc code for changes to accessgraph/v1alpha1:

    make grpc/host

These changes add the `KubeAuditLogsStream()` rpc and associated types.
@camscale camscale force-pushed the camh/tag/kube-audit-log-grpc branch from 1891ce0 to 5a16dbd Compare October 15, 2025 23:28
@camscale camscale added this pull request to the merge queue Oct 15, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Oct 16, 2025
@camscale camscale added this pull request to the merge queue Oct 16, 2025
Merged via the queue into master with commit e06e2e7 Oct 16, 2025
41 checks passed
@camscale camscale deleted the camh/tag/kube-audit-log-grpc branch October 16, 2025 00:54
mmcallister pushed a commit that referenced this pull request Nov 6, 2025
…#59566)

* proto/accessgraph: Add RPC for sending k8s audit logs to Access Graph

Add a `KubeAuditLogsStream()` rpc to the `AccessGraphService` for
streaming Kubernetes apiserver audit logs from the Teleport discovery
service to access graph. This is intended for EKS audit logs which are
made available via CloudWatch, but can accommodate other k8s services.

The audit log messages are represented as a `google.protobuf.Struct` so
as to not depend on the k8s.io .proto files, but also as k8s typically
uses protos internally only - the expectation is that we'll receive the
apiserver audit logs as json-encoded strings. This encode easily as a
`google.protobuf.Struct`.

* proto: Generate protos for accessgraph

Generate proto and grpc code for changes to accessgraph/v1alpha1:

    make grpc/host

These changes add the `KubeAuditLogsStream()` rpc and associated types.
mmcallister pushed a commit that referenced this pull request Nov 19, 2025
…#59566)

* proto/accessgraph: Add RPC for sending k8s audit logs to Access Graph

Add a `KubeAuditLogsStream()` rpc to the `AccessGraphService` for
streaming Kubernetes apiserver audit logs from the Teleport discovery
service to access graph. This is intended for EKS audit logs which are
made available via CloudWatch, but can accommodate other k8s services.

The audit log messages are represented as a `google.protobuf.Struct` so
as to not depend on the k8s.io .proto files, but also as k8s typically
uses protos internally only - the expectation is that we'll receive the
apiserver audit logs as json-encoded strings. This encode easily as a
`google.protobuf.Struct`.

* proto: Generate protos for accessgraph

Generate proto and grpc code for changes to accessgraph/v1alpha1:

    make grpc/host

These changes add the `KubeAuditLogsStream()` rpc and associated types.
mmcallister pushed a commit that referenced this pull request Nov 20, 2025
…#59566)

* proto/accessgraph: Add RPC for sending k8s audit logs to Access Graph

Add a `KubeAuditLogsStream()` rpc to the `AccessGraphService` for
streaming Kubernetes apiserver audit logs from the Teleport discovery
service to access graph. This is intended for EKS audit logs which are
made available via CloudWatch, but can accommodate other k8s services.

The audit log messages are represented as a `google.protobuf.Struct` so
as to not depend on the k8s.io .proto files, but also as k8s typically
uses protos internally only - the expectation is that we'll receive the
apiserver audit logs as json-encoded strings. This encode easily as a
`google.protobuf.Struct`.

* proto: Generate protos for accessgraph

Generate proto and grpc code for changes to accessgraph/v1alpha1:

    make grpc/host

These changes add the `KubeAuditLogsStream()` rpc and associated types.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-changelog Indicates that a PR does not require a changelog entry size/md

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants