Skip to content
This repository was archived by the owner on Jul 28, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions example/k3d/smoke/main.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ local smoke = {
],
) +
gragent.withVolumeMountsMixin([volumeMount.new('agent-wal', '/var/lib/agent')]) +
gragent.withService({}) +
gragent.withService() +
gragent.withAgentConfig({
server: { log_level: 'debug' },

Expand Down Expand Up @@ -189,7 +189,7 @@ local smoke = {
],
) +
gragent.withVolumeMountsMixin([volumeMount.new('agent-cluster-wal', '/var/lib/agent')]) +
gragent.withService({}) +
gragent.withService() +
gragent.withAgentConfig({
server: { log_level: 'debug' },

Expand Down
4 changes: 3 additions & 1 deletion production/tanka/grafana-agent/smoke/crow/main.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ local volume = k.core.v1.volume;

_config+:: {
image: 'us.gcr.io/kubernetes-dev/grafana/agent-crow:main',
args: {},
args: {
'server.http.address': '0.0.0.0:80',
},
pull_secret: '',
} + config,

Expand Down
12 changes: 7 additions & 5 deletions production/tanka/grafana-agent/v2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ scraping service config management API.
## General

- `withAgentConfig(config)`: Provide a custom Agent config.
- `withArgsMixin(config)`: Pass a map of additional flags to set.
- `withMetricsPort(port)`: Value for the `http-metrics` port (default 80)
- `withImagesMixin(images)`: Use custom images instead of the defaults.
- `withConfigHash(include=true)`: Whether to include a config hash annotation.
- `withPortsMixin(ports=[])`: Mixin ports from `k.core.v1.containerPort` against
Expand All @@ -66,15 +68,15 @@ scraping service config management API.

## Helpers

- `newKubernetesMetrics(config)`: Creates a set of metrics scrape_configs for
- `newKubernetesMetrics(config={})`: Creates a set of metrics scrape_configs for
collecting metrics from Kubernetes pods.
- `newKubernetesLogs(config)`: Creates a set of logs scrape_configs for
- `newKubernetesLogs(config={})`: Creates a set of logs scrape_configs for
collecting logs from Kubernetes pods.
- `newKubernetesTraces(config)`: Creates a set of traces scrape_configs for
- `newKubernetesTraces(config={})`: Creates a set of traces scrape_configs for
associating spans with metadata from discovered Kubernetes pods.
- `withLogVolumeMounts()`: Adds volume mounts to the controller for collecting
- `withLogVolumeMounts(config={})`: Adds volume mounts to the controller for collecting
logs.
- `withLogPermissions()`: Runs the container as privileged and as the root user
- `withLogPermissions(config={})`: Runs the container as privileged and as the root user
so logs can be collected properly.
- `withService(config)`: Add a service for the deployment, statefulset, or daemonset.
Note that this must be called after any ports are added via `withPortsMixin`.
Expand Down
11 changes: 7 additions & 4 deletions production/tanka/grafana-agent/v2/internal/base.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ function(name='grafana-agent', namespace='') {
namespace: namespace,
config_hash: true,
agent_config: '',
agent_port: 80,
agent_args: {
'config.file': '/etc/agent/agent.yaml',
'server.http.address': '0.0.0.0:80',
},
},

rbac: k.util.rbac(name, [
Expand All @@ -40,9 +45,7 @@ function(name='grafana-agent', namespace='') {

container::
container.new(name, this._images.agent) +
container.withPorts(containerPort.new('http-metrics', 80)) +
container.withPorts(containerPort.new('http-metrics', this._config.agent_port)) +
container.withCommand('/bin/agent') +
container.withArgsMixin(k.util.mapToFlags({
'config.file': '/etc/agent/agent.yaml',
})),
container.withArgsMixin(k.util.mapToFlags(this._config.agent_args)),
}
20 changes: 11 additions & 9 deletions production/tanka/grafana-agent/v2/main.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -20,29 +20,31 @@ local podTemplateSpec = k.core.v1.podTemplateSpec.spec;

// General
withAgentConfig(config):: { _config+: { agent_config: config } },
withMetricsPort(port):: { _config+: { agent_port: port } },
withArgsMixin(args):: { _config+: { agent_args+: args } },
withImagesMixin(images):: { _images+: images },
withConfigHash(include=true):: { _config+: { config_hash: include } },
withPortsMixin(ports=[]):: { container+:: container.withPortsMixin(ports) },
withVolumeMountsMixin(mounts=[]):: { container+:: container.withVolumeMountsMixin(mounts) },
withVolumesMixin(volumes=[]):: {
controller+: {
spec+: {
template+: podTemplateSpec.withVolumesMixin(volumes)
},
spec+: {
template+: podTemplateSpec.withVolumesMixin(volumes),
},
},
},

// Helpers
newKubernetesMetrics(config)::
newKubernetesMetrics(config={})::
(import './internal/helpers/k8s.libsonnet').metrics(config),
newKubernetesLogs(config)::
newKubernetesLogs(config={})::
(import './internal/helpers/k8s.libsonnet').logs(config),
newKubernetesTraces(config)::
newKubernetesTraces(config={})::
(import './internal/helpers/k8s.libsonnet').traces(config),
withLogVolumeMounts(config)::
withLogVolumeMounts(config={})::
(import './internal/helpers/logs.libsonnet').volumeMounts(config),
withLogPermissions(config)::
withLogPermissions(config={})::
(import './internal/helpers/logs.libsonnet').permissions(config),
withService(config)::
withService(config={})::
(import './internal/helpers/service.libsonnet').service(config),
}
4 changes: 2 additions & 2 deletions tools/crow/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ func main() {
var (
fs = flag.NewFlagSet(os.Args[0], flag.ExitOnError)

serverCfg server.Config
crowCfg crow.Config
serverCfg = server.DefaultConfig
crowCfg = crow.DefaultConfig
Comment on lines +31 to +32

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.

This is the main fix, but I'm also updating the jsonnet to be defensive

showVersion bool
)

Expand Down