Skip to content

Conversation

@naptalie
Copy link

Summary

This enhancement addresses issue #443 by allowing users to mount Grafana Alloy configuration from Kubernetes Secrets instead of only from ConfigMaps. This provides better security for configurations containing sensitive credentials.

Changes

New Features

  • Added alloy.secret configuration option in values.yaml with the following fields:
    • alloy.secret.create: Create a new Secret for the config file
    • alloy.secret.content: Content to assign to the Secret (supports templating via tpl)
    • alloy.secret.name: Name of existing Secret to use
    • alloy.secret.key: Key in Secret to get config from

Implementation Details

  • Secret takes precedence over ConfigMap when both are configured
  • ConfigMap is not created when using Secret (prevents resource duplication)
  • Support for both creating new Secrets and referencing existing ones
  • Added helper templates in _config.tpl for Secret name and key resolution
  • Updated pod template to conditionally mount Secret or ConfigMap
  • Added checksum annotation support for Secret content to trigger pod restarts on config changes

Testing

Documentation

  • Updated README.md with new alloy.secret section
  • Updated README.md.gotmpl template
  • Added values table entries for all new secret configuration options
  • Updated CHANGELOG.md

Backward Compatibility

The implementation maintains full backward compatibility with existing ConfigMap-based configurations. Users can continue using ConfigMaps without any changes.

Test Plan

  1. Default behavior (ConfigMap) continues to work:

    helm template test . --values ci/default-values-values.yaml
  2. New Secret creation works:

    helm template test . --values ci/custom-secret-config-values.yaml
  3. Referencing existing Secret works:

    helm template test . --values ci/existing-secret-values.yaml

Usage Example

To use a Secret for your Alloy configuration:

alloy:
  secret:
    create: true
    content: |
      prometheus.remote_write "default" {
        endpoint {
          url = "https://prometheus.example.com/api/v1/write"
          basic_auth {
            username = "my-username"
            password = "my-secret-password"
          }
        }
      }

Or to reference an existing Secret:

alloy:
  secret:
    create: false
    name: my-existing-secret
    key: config.alloy

Fixes #443

🤖 Generated with Claude Code

Co-Authored-By: Claude [email protected]

naptalie and others added 2 commits November 15, 2025 21:52
The Helm chart would fail to render when rbac.rules or
rbac.clusterRules were set to empty arrays, producing invalid YAML.

This change adds conditional checks to output valid YAML (empty array
syntax) when the rule arrays are empty, allowing users to explicitly
disable custom RBAC rules while maintaining valid configuration.

Fixes grafana#4778

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
This enhancement addresses issue grafana#443 by allowing users to mount
Grafana Alloy configuration from Kubernetes Secrets instead of
only from ConfigMaps. This provides better security for configurations
containing sensitive credentials.

Key changes:
- Added `alloy.secret` configuration option in values.yaml
- Secret takes precedence over ConfigMap when both are configured
- ConfigMap is not created when using Secret
- Support for both creating new Secrets and referencing existing ones
- Added helper templates for Secret name and key resolution
- Updated pod template to conditionally mount Secret or ConfigMap
- Added CI test configurations for Secret-based config
- Updated documentation in README and README.gotmpl

The implementation maintains full backward compatibility with existing
ConfigMap-based configurations.

Fixes grafana#443

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@naptalie naptalie requested a review from a team as a code owner November 16, 2025 03:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow mounting the config via a secret instead of a configmap or provide an easier way to override default

1 participant