Skip to content

feat(t8s-cluster): enable audit logging#1440

Merged
cwrau merged 1 commit intomainfrom
feat/t8s-cluster/enable-audit-logging
Apr 22, 2025
Merged

feat(t8s-cluster): enable audit logging#1440
cwrau merged 1 commit intomainfrom
feat/t8s-cluster/enable-audit-logging

Conversation

@cwrau
Copy link
Copy Markdown
Member

@cwrau cwrau commented Apr 16, 2025

Summary by CodeRabbit

  • New Features
    • Introduced audit logging support for the API server, including a default audit policy that captures metadata for all requests.
  • Bug Fixes
    • Corrected context handling in the authentication configuration to ensure proper propagation.

Copilot AI review requested due to automatic review settings April 16, 2025 12:46
@cwrau cwrau enabled auto-merge April 16, 2025 12:46
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 16, 2025

Walkthrough

A new Kubernetes audit policy configuration file, audit-config.yaml, has been added to the project. Helm template helpers have been updated to support this audit configuration, including new template definitions for the audit config file name and path. The API server argument list is extended to reference the audit policy file and set the audit log path. The static files dictionary now incorporates the audit config file, and a minor fix is made to the context passed to the authentication config content template.

Changes

File(s) Change Summary
charts/t8s-cluster/files/audit-config.yaml Added a Kubernetes audit policy configuration file specifying Metadata level logging for all requests, omitting the RequestReceived stage.
charts/t8s-cluster/templates/management-cluster/clusterClass/_helpers.tpl Added templates for audit config file name and path; updated API server args and static files to include audit config; fixed context passing in dynamic files.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant HelmTemplates
    participant K8sAPIServer

    User->>HelmTemplates: Deploy cluster with Helm
    HelmTemplates->>K8sAPIServer: Configure API server with audit-policy-file and audit-log-path
    K8sAPIServer->>K8sAPIServer: Load audit-config.yaml for audit logging
    K8sAPIServer-->>User: API server runs with audit logging enabled
Loading

Poem

In the cluster’s warren, a new file appears,
Audit-config hops in, allaying our fears.
Now every request leaves a metadata trace,
With helpers and paths all falling in place.
The API server logs with a thump and a cheer—
More secure and aware, as rabbits draw near! 🐇


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 1 out of 2 changed files in this pull request and generated no comments.

Files not reviewed (1)
  • charts/t8s-cluster/templates/management-cluster/clusterClass/_helpers.tpl: Language not supported

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
charts/t8s-cluster/files/audit-config.yaml (1)

1-10: Good baseline audit policy for Kubernetes API Server.

This introduces a basic Kubernetes audit policy that logs metadata for all API requests, omitting only the RequestReceived stage. The Metadata logging level captures request details like user, timestamp, resource, and verb, which is a good starting point for audit compliance.

For future enhancements, consider implementing a more granular audit policy with different audit levels for sensitive operations. For example:

 apiVersion: audit.k8s.io/v1
 kind: Policy
 # Long-running requests like watches will not generate an audit event in RequestReceived.
 omitStages:
   - "RequestReceived"
 rules:
+  # Log RequestResponse level for sensitive resources like secrets
+  - level: RequestResponse
+    resources:
+    - group: ""
+      resources: ["secrets"]
+  # Log Request level for configmaps and service accounts operations
+  - level: Request
+    resources:
+    - group: ""
+      resources: ["configmaps", "serviceaccounts"]
   - level: Metadata
     verbs: [] # All verbs
     resources: [] # All resources
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5b273aa and 95b7532.

📒 Files selected for processing (2)
  • charts/t8s-cluster/files/audit-config.yaml (1 hunks)
  • charts/t8s-cluster/templates/management-cluster/clusterClass/_helpers.tpl (5 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: generateDiffCommentBody
  • GitHub Check: lint helm chart (t8s-cluster)
  • GitHub Check: wait-for-checks
🔇 Additional comments (5)
charts/t8s-cluster/templates/management-cluster/clusterClass/_helpers.tpl (5)

170-172: LGTM. Added audit config path template.

This template helper correctly constructs the full path to the audit configuration file by combining the base Kubernetes config path with the audit config filename.


186-188: LGTM. Added audit config filename template.

This template helper defines the filename of the audit configuration file as "audit-config.yaml", matching the newly added file in the chart.


202-203: LGTM. API server arguments for audit logging configured.

These changes correctly configure the API server to use the audit policy file and to send audit logs to standard output (indicated by "-"). This is the recommended approach for container environments where logs are typically collected from stdout.


213-220: LGTM. Added audit configuration to API server static files.

The audit configuration file is now properly included in the static files dictionary for the API server, ensuring it's included in the rendered manifests.


231-234: Fixed context propagation to authentication config template.

This fixes the context being passed to the authentication config content template, ensuring the correct context is used.

@teutonet-bot
Copy link
Copy Markdown
Contributor

🤖 I have diffed this beep boop

"/$namespace/$kind/$name.yaml" for normal resources
"/$namespace/HelmRelease/$name/$namespace/$kind/$name.yaml" for HelmReleases <- this is recursive
'null' means it's either cluster-scoped or it's in the default namespace for the HelmRelease

charts/t8s-cluster/ci/artifacthub-values.yaml

[charts/t8s-cluster/ci/cidrs-values.yaml](

<title>Something went wrong :-(</title>

<style>
body {
font-family: Helvetica, Arial, sans-serif;
width: 500px;
margin-left: auto;
margin-right: auto;
margin-top: 20px;
}
.for-site-owner {
font-size: smaller;
}
</style>

<body>
    <div class="main">
        <div class="header">
            <h1>Something went wrong :-(</h1>

            <p>
                Something went wrong while trying to load this site;
                please try again later.
            </p>

            <div class="for-site-owner">
                <h2>Debugging tips</h2>
                <p>
                    If this is your site, and you just reloaded
                    it, then the problem might simply be that it hasn't loaded up yet.
                    Try refreshing this page and see if this message disappears.
                </p>
                <p>
                    If you keep getting this message, you should check your site's
                    server and error logs for any messages.
                </p>
           </div>

            <p>
                Error code: 502-backend
            </p>
        </div>
    </div>
</body>
)

[charts/t8s-cluster/ci/injectedCertificateAuthorities-values.yaml](

<title>Something went wrong :-(</title>

<style>
body {
font-family: Helvetica, Arial, sans-serif;
width: 500px;
margin-left: auto;
margin-right: auto;
margin-top: 20px;
}
.for-site-owner {
font-size: smaller;
}
</style>

<body>
    <div class="main">
        <div class="header">
            <h1>Something went wrong :-(</h1>

            <p>
                Something went wrong while trying to load this site;
                please try again later.
            </p>

            <div class="for-site-owner">
                <h2>Debugging tips</h2>
                <p>
                    If this is your site, and you just reloaded
                    it, then the problem might simply be that it hasn't loaded up yet.
                    Try refreshing this page and see if this message disappears.
                </p>
                <p>
                    If you keep getting this message, you should check your site's
                    server and error logs for any messages.
                </p>
           </div>

            <p>
                Error code: 502-backend
            </p>
        </div>
    </div>
</body>
)

[charts/t8s-cluster/ci/hcp-values.yaml](

<title>Something went wrong :-(</title>

<style>
body {
font-family: Helvetica, Arial, sans-serif;
width: 500px;
margin-left: auto;
margin-right: auto;
margin-top: 20px;
}
.for-site-owner {
font-size: smaller;
}
</style>

<body>
    <div class="main">
        <div class="header">
            <h1>Something went wrong :-(</h1>

            <p>
                Something went wrong while trying to load this site;
                please try again later.
            </p>

            <div class="for-site-owner">
                <h2>Debugging tips</h2>
                <p>
                    If this is your site, and you just reloaded
                    it, then the problem might simply be that it hasn't loaded up yet.
                    Try refreshing this page and see if this message disappears.
                </p>
                <p>
                    If you keep getting this message, you should check your site's
                    server and error logs for any messages.
                </p>
           </div>

            <p>
                Error code: 502-backend
            </p>
        </div>
    </div>
</body>
)

charts/t8s-cluster/ci/securityGroups-values.yaml

[charts/t8s-cluster/ci/calico-values.yaml](

<title>Something went wrong :-(</title>

<style>
body {
font-family: Helvetica, Arial, sans-serif;
width: 500px;
margin-left: auto;
margin-right: auto;
margin-top: 20px;
}
.for-site-owner {
font-size: smaller;
}
</style>

<body>
    <div class="main">
        <div class="header">
            <h1>Something went wrong :-(</h1>

            <p>
                Something went wrong while trying to load this site;
                please try again later.
            </p>

            <div class="for-site-owner">
                <h2>Debugging tips</h2>
                <p>
                    If this is your site, and you just reloaded
                    it, then the problem might simply be that it hasn't loaded up yet.
                    Try refreshing this page and see if this message disappears.
                </p>
                <p>
                    If you keep getting this message, you should check your site's
                    server and error logs for any messages.
                </p>
           </div>

            <p>
                Error code: 502-backend
            </p>
        </div>
    </div>
</body>
)

[charts/t8s-cluster/ci/securityGroupRules-values.yaml](

<title>Something went wrong :-(</title>

<style>
body {
font-family: Helvetica, Arial, sans-serif;
width: 500px;
margin-left: auto;
margin-right: auto;
margin-top: 20px;
}
.for-site-owner {
font-size: smaller;
}
</style>

<body>
    <div class="main">
        <div class="header">
            <h1>Something went wrong :-(</h1>

            <p>
                Something went wrong while trying to load this site;
                please try again later.
            </p>

            <div class="for-site-owner">
                <h2>Debugging tips</h2>
                <p>
                    If this is your site, and you just reloaded
                    it, then the problem might simply be that it hasn't loaded up yet.
                    Try refreshing this page and see if this message disappears.
                </p>
                <p>
                    If you keep getting this message, you should check your site's
                    server and error logs for any messages.
                </p>
           </div>

            <p>
                Error code: 502-backend
            </p>
        </div>
    </div>
</body>
)

[charts/t8s-cluster/ci/bastion-values.yaml](

<title>Something went wrong :-(</title>

<style>
body {
font-family: Helvetica, Arial, sans-serif;
width: 500px;
margin-left: auto;
margin-right: auto;
margin-top: 20px;
}
.for-site-owner {
font-size: smaller;
}
</style>

<body>
    <div class="main">
        <div class="header">
            <h1>Something went wrong :-(</h1>

            <p>
                Something went wrong while trying to load this site;
                please try again later.
            </p>

            <div class="for-site-owner">
                <h2>Debugging tips</h2>
                <p>
                    If this is your site, and you just reloaded
                    it, then the problem might simply be that it hasn't loaded up yet.
                    Try refreshing this page and see if this message disappears.
                </p>
                <p>
                    If you keep getting this message, you should check your site's
                    server and error logs for any messages.
                </p>
           </div>

            <p>
                Error code: 502-backend
            </p>
        </div>
    </div>
</body>
)

charts/t8s-cluster/values.yaml

[charts/t8s-cluster/ci/gpu-flavor-values.yaml](

<title>Something went wrong :-(</title>

<style>
body {
font-family: Helvetica, Arial, sans-serif;
width: 500px;
margin-left: auto;
margin-right: auto;
margin-top: 20px;
}
.for-site-owner {
font-size: smaller;
}
</style>

<body>
    <div class="main">
        <div class="header">
            <h1>Something went wrong :-(</h1>

            <p>
                Something went wrong while trying to load this site;
                please try again later.
            </p>

            <div class="for-site-owner">
                <h2>Debugging tips</h2>
                <p>
                    If this is your site, and you just reloaded
                    it, then the problem might simply be that it hasn't loaded up yet.
                    Try refreshing this page and see if this message disappears.
                </p>
                <p>
                    If you keep getting this message, you should check your site's
                    server and error logs for any messages.
                </p>
           </div>

            <p>
                Error code: 502-backend
            </p>
        </div>
    </div>
</body>
)

@cwrau cwrau added this pull request to the merge queue Apr 22, 2025
Merged via the queue into main with commit dcb28ca Apr 22, 2025
34 of 35 checks passed
@cwrau cwrau deleted the feat/t8s-cluster/enable-audit-logging branch April 22, 2025 07:43
github-merge-queue Bot pushed a commit that referenced this pull request Jun 6, 2025
🤖 I have created a release *beep* *boop*
---


##
[9.3.0](t8s-cluster-v9.2.1...t8s-cluster-v9.3.0)
(2025-06-06)


### Features

* **t8s-cluster:** add rbac for teuto staff
([#1498](#1498))
([9e0a9e2](9e0a9e2))
* **t8s-cluster:** enable audit logging
([#1440](#1440))
([dcb28ca](dcb28ca))
* **t8s-cluster:** make apiserver resources configurable
([#1485](#1485))
([3126661](3126661))
* **t8s-cluster:** use new pullPolicy template
([#1383](#1383))
([6b253bd](6b253bd))


### Miscellaneous Chores

* **t8s-cluster:** pin versions
([#1482](#1482))
([372c92b](372c92b))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **New Features**
  - Added RBAC for Teuto staff.
  - Enabled audit logging.
  - Made apiserver resource configurations customizable.
  - Adopted a new pullPolicy template.

- **Enhancements**
- Updated OpenStack Cinder CSI plugin and related CSI component images
to newer versions.
- Improved documentation for control plane resource configuration and
security group rule options.

- **Chores**
  - Updated chart version to 9.3.0 and pinned image versions.
- Switched CSI image references and license entries from k8s.gcr.io to
registry.k8s.io.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Chris Werner Rau <cwr@teuto.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants