Skip to content

Commit

Permalink
feat(k8s/amour/grafana): add victoria metrics plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
uhthomas committed May 8, 2024
1 parent 367217d commit dc5cb5d
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 9 deletions.
8 changes: 7 additions & 1 deletion k8s/amour/grafana/config_map_list.cue
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ import (
type: "victorialogs-datasource"
access: "proxy"
url: "http://victoria-logs.victoria-logs"
}, {
name: "VictoriaMetrics (ds)"
type: "victoriametrics-datasource"
access: "proxy"
url: "http://vmsingle-vm.vm:8429"
}]
})
"grafana.ini": """
Expand Down Expand Up @@ -66,8 +71,9 @@ import (
mode = console
# https://github.com/VictoriaMetrics/victorialogs-datasource/blob/058bd8d81a8119511abdc35398459a1094381b5c/README.md
# https://github.com/VictoriaMetrics/grafana-datasource/blob/5b8a0ba190e116bdebfdb51d11b4e0d03d86d766/README.md
[plugins]
allow_loading_unsigned_plugins = victorialogs-datasource
allow_loading_unsigned_plugins = victorialogs-datasource,victoriametrics-datasource
"""
}
}]
36 changes: 33 additions & 3 deletions k8s/amour/grafana/stateful_set_list.cue
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@ let downloadVictoriaLogsPluginScript = """
rm /var/lib/grafana/plugins/plugin.tar.gz
"""

let downloadVictoriaMetricsPluginScript = """
set -ex
mkdir -p /var/lib/grafana/plugins/
ver=$(curl -s https://api.github.com/repos/VictoriaMetrics/grafana-datasource/releases/latest | grep -oE 'v[0-9]+\\.[0-9]+\\.[0-9]+' | head -1)
curl -L https://github.com/VictoriaMetrics/grafana-datasource/releases/download/$ver/victoriametrics-datasource-$ver.tar.gz -o /var/lib/grafana/plugins/plugin.tar.gz
tar -xf /var/lib/grafana/plugins/plugin.tar.gz -C /var/lib/grafana/plugins/
rm /var/lib/grafana/plugins/plugin.tar.gz
"""

#StatefulSetList: items: [{
spec: {
selector: matchLabels: "app.kubernetes.io/name": #Name
Expand Down Expand Up @@ -57,6 +66,27 @@ let downloadVictoriaLogsPluginScript = """
readOnlyRootFilesystem: true
allowPrivilegeEscalation: false
}
}, {
// https://github.com/VictoriaMetrics/grafana-datasource/blob/5b8a0ba190e116bdebfdb51d11b4e0d03d86d766/README.md
name: "download-victoria-metrics-plugin"
image: "curlimages/curl:8.7.1"
command: ["/bin/sh"]
args: ["-c", downloadVictoriaMetricsPluginScript]
workingDir: "/var/lib/grafana"
resources: limits: {
(v1.#ResourceCPU): "1"
(v1.#ResourceMemory): "1Gi"
}
volumeMounts: [{
name: "data"
mountPath: "/var/lib/grafana"
}]
imagePullPolicy: v1.#PullIfNotPresent
securityContext: {
capabilities: drop: ["ALL"]
readOnlyRootFilesystem: true
allowPrivilegeEscalation: false
}
}]
containers: [{
name: "grafana"
Expand Down Expand Up @@ -115,9 +145,9 @@ let downloadVictoriaLogsPluginScript = """
}
}]
securityContext: {
runAsUser: 1000
runAsGroup: 3000
runAsNonRoot: true
runAsUser: 1000
runAsGroup: 3000
runAsNonRoot: true
fsGroup: 2000
fsGroupChangePolicy: v1.#FSGroupChangeOnRootMismatch
seccompProfile: type: v1.#SeccompProfileTypeRuntimeDefault
Expand Down
6 changes: 1 addition & 5 deletions k8s/amour/thomas/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,10 @@ load("@com_github_tnarg_rules_cue//cue:cue.bzl", "cue_library")
cue_library(
name = "cue_thomas_library",
srcs = [
"job_list.cue",
"list.cue",
"namespace_list.cue",
],
importpath = "github.com/uhthomas/automata/k8s/amour/thomas",
visibility = ["//visibility:public"],
deps = [
"//cue.mod/gen/k8s.io/api/batch/v1:cue_v1_library",
"//cue.mod/gen/k8s.io/api/core/v1:cue_v1_library",
],
deps = ["//cue.mod/gen/k8s.io/api/core/v1:cue_v1_library"],
)

0 comments on commit dc5cb5d

Please sign in to comment.