Skip to content

Commit

Permalink
feat(k8s/amour): speedtest exporter
Browse files Browse the repository at this point in the history
  • Loading branch information
uhthomas committed Jan 24, 2024
1 parent 1365dd3 commit 8fc5513
Show file tree
Hide file tree
Showing 9 changed files with 182 additions and 0 deletions.
1 change: 1 addition & 0 deletions k8s/amour/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ cue_export(
"//k8s/amour/scrutiny:cue_scrutiny_library",
"//k8s/amour/smartctl_exporter:cue_smartctl_exporter_library",
"//k8s/amour/snapshot_controller:cue_snapshot_controller_library",
"//k8s/amour/speedtest_exporter:cue_speedtest_exporter_library",
"//k8s/amour/tailscale:cue_tailscale_library",
"//k8s/amour/thomas:cue_thomas_library",
"//k8s/amour/vm:cue_vm_library",
Expand Down
2 changes: 2 additions & 0 deletions k8s/amour/list.cue
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"github.com/uhthomas/automata/k8s/amour/scrutiny"
"github.com/uhthomas/automata/k8s/amour/smartctl_exporter"
"github.com/uhthomas/automata/k8s/amour/snapshot_controller"
"github.com/uhthomas/automata/k8s/amour/speedtest_exporter"
"github.com/uhthomas/automata/k8s/amour/tailscale"
"github.com/uhthomas/automata/k8s/amour/thomas"
"github.com/uhthomas/automata/k8s/amour/vm_operator"
Expand Down Expand Up @@ -77,6 +78,7 @@ _items: [
scrutiny.#List.items,
smartctl_exporter.#List.items,
snapshot_controller.#List.items,
speedtest_exporter.#List.items,
tailscale.#List.items,
thomas.#List.items,
vm_operator.#List.items,
Expand Down
19 changes: 19 additions & 0 deletions k8s/amour/speedtest_exporter/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
load("@com_github_tnarg_rules_cue//cue:cue.bzl", "cue_library")

cue_library(
name = "cue_speedtest_exporter_library",
srcs = [
"deployment_list.cue",
"list.cue",
"namespace_list.cue",
"service_list.cue",
"vm_service_scrape_list.cue",
],
importpath = "github.com/uhthomas/automata/k8s/amour/speedtest_exporter",
visibility = ["//visibility:public"],
deps = [
"//cue.mod/gen/github.com/VictoriaMetrics/operator/api/victoriametrics/v1beta1:cue_v1beta1_library",
"//cue.mod/gen/k8s.io/api/apps/v1:cue_v1_library",
"//cue.mod/gen/k8s.io/api/core/v1:cue_v1_library",
],
)
7 changes: 7 additions & 0 deletions k8s/amour/speedtest_exporter/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Speedtest Exporter

[https://github.com/MiguelNdeCarvalho/speedtest-exporter](https://github.com/MiguelNdeCarvalho/speedtest-exporter)

[https://docs.miguelndecarvalho.pt/projects/speedtest-exporter/](https://docs.miguelndecarvalho.pt/projects/speedtest-exporter/)

[Grafana Dashboard](https://grafana.com/grafana/dashboards/13665)
57 changes: 57 additions & 0 deletions k8s/amour/speedtest_exporter/deployment_list.cue
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package speedtest_exporter

import (
appsv1 "k8s.io/api/apps/v1"
"k8s.io/api/core/v1"
)

#DeploymentList: appsv1.#DeploymentList & {
apiVersion: "apps/v1"
kind: "DeploymentList"
items: [...{
apiVersion: "apps/v1"
kind: "Deployment"
}]
}

#DeploymentList: items: [{
spec: {
selector: matchLabels: "app.kubernetes.io/name": #Name
template: {
metadata: labels: "app.kubernetes.io/name": #Name
spec: {
containers: [{
name: "speedtest-exporter"
image: "miguelndecarvalho/speedtest-exporter:v\(#Version)"
ports: [{
name: "http-metrics"
containerPort: 9798
}]
resources: requests: {
(v1.#ResourceCPU): "100m"
(v1.#ResourceMemory): "200Mi"
}

let probe = {httpGet: port: "http-metrics"}

livenessProbe: probe
readinessProbe: probe

imagePullPolicy: v1.#PullIfNotPresent
securityContext: {
capabilities: drop: ["ALL"]
readOnlyRootFilesystem: true
allowPrivilegeEscalation: false
}
}]
securityContext: {
runAsUser: 1000
runAsGroup: 3000
runAsNonRoot: true
fsGroup: 2000
seccompProfile: type: v1.#SeccompProfileTypeRuntimeDefault
}
}
}
}
}]
37 changes: 37 additions & 0 deletions k8s/amour/speedtest_exporter/list.cue
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package speedtest_exporter

import (
"list"

"k8s.io/api/core/v1"
)

#Name: "speedtest-exporter"
#Namespace: #Name

// renovate: datasource=github-releases depName=MiguelNdeCarvalho/speedtest-exporter extractVersion=^v(?<version>.*)$
#Version: "3.5.4"

#List: v1.#List & {
apiVersion: "v1"
kind: "List"
items: [...{
metadata: {
name: #Name
namespace: #Namespace
labels: {
"app.kubernetes.io/name": #Name
"app.kubernetes.io/version": #Version
}
}
}]
}

#List: items: list.Concat(_items)

_items: [
#DeploymentList.items,
#NamespaceList.items,
#ServiceList.items,
#VMServiceScrapeList.items,
]
14 changes: 14 additions & 0 deletions k8s/amour/speedtest_exporter/namespace_list.cue
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package speedtest_exporter

import "k8s.io/api/core/v1"

#NamespaceList: v1.#NamespaceList & {
apiVersion: "v1"
kind: "NamespaceList"
items: [...{
apiVersion: "v1"
kind: "Namespace"
}]
}

#NamespaceList: items: [{}]
23 changes: 23 additions & 0 deletions k8s/amour/speedtest_exporter/service_list.cue
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package speedtest_exporter

import "k8s.io/api/core/v1"

#ServiceList: v1.#ServiceList & {
apiVersion: "v1"
kind: "ServiceList"
items: [...{
apiVersion: "v1"
kind: "Service"
}]
}

#ServiceList: items: [{
spec: {
ports: [{
name: "http-metrics"
port: 80
targetPort: "http-metrics"
}]
selector: "app.kubernetes.io/name": #Name
}
}]
22 changes: 22 additions & 0 deletions k8s/amour/speedtest_exporter/vm_service_scrape_list.cue
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package speedtest_exporter

import victoriametricsv1beta1 "github.com/VictoriaMetrics/operator/api/victoriametrics/v1beta1"

#VMServiceScrapeList: victoriametricsv1beta1.#VMServiceScrapeList & {
apiVersion: "operator.victoriametrics.com/v1beta1"
kind: "VMServiceScrapeList"
items: [...{
apiVersion: "operator.victoriametrics.com/v1beta1"
kind: "VMServiceScrape"
}]
}

#VMServiceScrapeList: items: [{
spec: {
endpoints: [{
port: "http-metrics"
scrape_interval: "1h"
}]
selector: matchLabels: "app.kubernetes.io/name": #Name
}
}]

0 comments on commit 8fc5513

Please sign in to comment.