Improve monitoring config

Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
This commit is contained in:
Stefan Prodan
2023-09-23 09:25:25 +03:00
parent a1b112f4e1
commit 6316e213d1
6 changed files with 47 additions and 8 deletions
+4 -4
View File
@@ -118,10 +118,10 @@ values: {
### Monitoring values
| Key | Type | Default | Description |
|-------------------------|----------|---------|-------------------------------------------------------------------------------|
| `monitoring: enabled:` | `bool` | `false` | Enable [Prometheus ServiceMonitor](https://prometheus-operator.dev/) creation |
| `monitoring: interval:` | `string` | `15s` | Prometheus scrape interval |
| Key | Type | Default | Description |
|-------------------------|--------|---------|-------------------------------------------------------------------------------|
| `monitoring: enabled:` | `bool` | `false` | Enable [Prometheus ServiceMonitor](https://prometheus-operator.dev/) creation |
| `monitoring: interval:` | `int` | `15` | Prometheus scrape interval in seconds |
### Cashing values
+8 -3
View File
@@ -16,7 +16,7 @@ import (
metadata: version: moduleVersion
// Deployment
replicas: *1 | int & >0
replicas: *1 | int & >=0
// Pod
podAnnotations?: {[ string]: string}
@@ -33,7 +33,11 @@ import (
securityContext?: corev1.#SecurityContext
// Service
service: port: *80 | int & >0 & <=65535
service: {
port: *80 | int & >0 & <=65535
annotations?: {[ string]: string}
labels?: {[ string]: string}
}
// HorizontalPodAutoscaler (optional)
autoscaling: {
@@ -50,13 +54,14 @@ import (
tls: *false | bool
host: *"podinfo.local" | string
annotations?: {[ string]: string}
labels?: {[ string]: string}
className?: string
}
// ServiceMonitor (optional)
monitoring: {
enabled: *false | bool
interval: *"15s" | string
interval: *15 | int & >=5 & <=3600
}
// Caching (optional)
+17
View File
@@ -21,6 +21,10 @@ import (
if !_config.autoscaling.enabled {
replicas: _config.replicas
}
strategy: {
type: "RollingUpdate"
rollingUpdate: maxUnavailable: "50%"
}
selector: matchLabels: _config.metadata.labelSelector
template: {
metadata: {
@@ -28,6 +32,12 @@ import (
if _config.podAnnotations != _|_ {
annotations: _config.podAnnotations
}
if !_config.monitoring.enabled {
annotations: {
"prometheus.io/scrape": "true"
"prometheus.io/port": "9797"
}
}
}
spec: corev1.#PodSpec & {
serviceAccountName: _config.metadata.name
@@ -42,6 +52,11 @@ import (
containerPort: 9898
protocol: "TCP"
},
{
name: "http-metrics"
containerPort: 9797
protocol: "TCP"
},
]
livenessProbe: {
httpGet: {
@@ -64,6 +79,8 @@ import (
command: [
"./podinfo",
"--level=info",
"--port=9898",
"--port-metrics=9797",
if _config.caching.enabled {
"--cache-server=\(_config.caching.redisURL)"
},
+3
View File
@@ -12,6 +12,9 @@ import (
name: _config.metadata.name
namespace: _config.metadata.namespace
labels: _config.metadata.labels
if _config.ingress.labels != _|_ {
labels: _config.ingress.labels
}
if _config.metadata.annotations != _|_ {
annotations: _config.metadata.annotations
}
+14
View File
@@ -12,9 +12,15 @@ import (
name: _config.metadata.name
namespace: _config.metadata.namespace
labels: _config.metadata.labels
if _config.service.labels != _|_ {
labels: _config.service.labels
}
if _config.metadata.annotations != _|_ {
annotations: _config.metadata.annotations
}
if _config.service.annotations != _|_ {
annotations: _config.service.annotations
}
}
spec: corev1.#ServiceSpec & {
type: corev1.#ServiceTypeClusterIP
@@ -26,6 +32,14 @@ import (
targetPort: "\(name)"
protocol: "TCP"
},
if _config.monitoring.enabled {
{
name: "http-metrics"
port: 9797
targetPort: "http-metrics"
protocol: "TCP"
}
},
]
}
}
+1 -1
View File
@@ -18,7 +18,7 @@ import (
endpoints: [{
path: "/metrics"
port: "http-metrics"
interval: _config.monitoring.interval
interval: "\(_config.monitoring.interval)s"
}]
namespaceSelector: matchNames: [_config.metadata.namespace]
selector: matchLabels: _config.metadata.labelSelector