Skip to content

Commit

Permalink
feat(k8s/amour): ping exporter
Browse files Browse the repository at this point in the history
  • Loading branch information
uhthomas committed Jan 24, 2024
1 parent 305add3 commit 1365dd3
Show file tree
Hide file tree
Showing 10 changed files with 223 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 @@ -39,6 +39,7 @@ cue_export(
"//k8s/amour/node_problem_detector:cue_node_problem_detector_library",
"//k8s/amour/nvidia_device_plugin:cue_nvidia_device_plugin_library",
"//k8s/amour/onepassword_connect:cue_onepassword_connect_library",
"//k8s/amour/ping_exporter:cue_ping_exporter_library",
"//k8s/amour/rook_ceph:cue_rook_ceph_library",
"//k8s/amour/scrutiny:cue_scrutiny_library",
"//k8s/amour/smartctl_exporter:cue_smartctl_exporter_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 @@ -19,6 +19,7 @@ import (
"github.com/uhthomas/automata/k8s/amour/node_problem_detector"
"github.com/uhthomas/automata/k8s/amour/nvidia_device_plugin"
"github.com/uhthomas/automata/k8s/amour/onepassword_connect"
"github.com/uhthomas/automata/k8s/amour/ping_exporter"
"github.com/uhthomas/automata/k8s/amour/rook_ceph"
"github.com/uhthomas/automata/k8s/amour/scrutiny"
"github.com/uhthomas/automata/k8s/amour/smartctl_exporter"
Expand Down Expand Up @@ -71,6 +72,7 @@ _items: [
node_problem_detector.#List.items,
nvidia_device_plugin.#List.items,
onepassword_connect.#List.items,
ping_exporter.#List.items,
rook_ceph.#List.items,
scrutiny.#List.items,
smartctl_exporter.#List.items,
Expand Down
20 changes: 20 additions & 0 deletions k8s/amour/ping_exporter/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
load("@com_github_tnarg_rules_cue//cue:cue.bzl", "cue_library")

cue_library(
name = "cue_ping_exporter_library",
srcs = [
"config_map_list.cue",
"deployment_list.cue",
"list.cue",
"namespace_list.cue",
"service_list.cue",
"vm_service_scrape_list.cue",
],
importpath = "github.com/uhthomas/automata/k8s/amour/ping_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",
],
)
5 changes: 5 additions & 0 deletions k8s/amour/ping_exporter/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# ping_exporter

[https://github.com/czerwonk/ping_exporter](https://github.com/czerwonk/ping_exporter)

[Grafana Dashboard](https://grafana.com/grafana/dashboards/19761-pingexporter/)
32 changes: 32 additions & 0 deletions k8s/amour/ping_exporter/config_map_list.cue
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package ping_exporter

import (
"encoding/yaml"

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

#ConfigMapList: v1.#ConfigMapList & {
apiVersion: "v1"
kind: "ConfigMapList"
items: [...{
apiVersion: "v1"
kind: "ConfigMap"
}]
}

#ConfigMapList: items: [{
data: "config.yaml": yaml.Marshal({
targets: ["1.1.1.1", "1.0.0.1", "8.8.8.8", "8.8.4.4"]
dns: {
refresh: "2m15s"
nameserver: "1.1.1.1"
}
ping: {
interval: "2s"
timeout: "3s"
"history-size": 42
"payload-size": 120
}
})
}]
69 changes: 69 additions & 0 deletions k8s/amour/ping_exporter/deployment_list.cue
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
package ping_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: {
volumes: [{
name: "config"
configMap: name: #Name
}]
containers: [{
name: "ping-exporter"
image: "czerwonk/ping_exporter:v\(#Version)"
command: ["/app/ping_exporter"]
args: ["--config.path=/var/ping-exporter/config.yaml"]
ports: [{
name: "http-metrics"
containerPort: 9427
}]
resources: requests: {
(v1.#ResourceCPU): "100m"
(v1.#ResourceMemory): "200Mi"
}
volumeMounts: [{
name: "config"
mountPath: "/var/ping-exporter/config.yaml"
subPath: "config.yaml"
}]

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

livenessProbe: probe
readinessProbe: probe

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

import (
"list"

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

#Name: "ping-exporter"
#Namespace: #Name

// renovate: datasource=github-releases depName=czerwonk/ping_exporter
#Version: "1.1.0"

#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: [
#ConfigMapList.items,
#DeploymentList.items,
#NamespaceList.items,
#ServiceList.items,
#VMServiceScrapeList.items,
]
14 changes: 14 additions & 0 deletions k8s/amour/ping_exporter/namespace_list.cue
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package ping_exporter

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

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

#NamespaceList: items: [{metadata: labels: "pod-security.kubernetes.io/enforce": "privileged"}]
23 changes: 23 additions & 0 deletions k8s/amour/ping_exporter/service_list.cue
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package ping_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
}
}]
19 changes: 19 additions & 0 deletions k8s/amour/ping_exporter/vm_service_scrape_list.cue
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package ping_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"}]
selector: matchLabels: "app.kubernetes.io/name": #Name
}
}]

0 comments on commit 1365dd3

Please sign in to comment.