2024-11-25 10:53:09 +00:00
|
|
|
chart:
|
|
|
|
appVersion: 0.1.0
|
|
|
|
version: 0.1.0
|
|
|
|
suite: Deployment template (basic)
|
|
|
|
release:
|
|
|
|
name: prometheus-postgres-exporter-unittest
|
|
|
|
namespace: testing
|
|
|
|
templates:
|
|
|
|
- templates/prometheus-postgres-exporter/deployment.yaml
|
|
|
|
tests:
|
|
|
|
- it: Rendering default
|
|
|
|
asserts:
|
|
|
|
- hasDocuments:
|
|
|
|
count: 1
|
|
|
|
- containsDocument:
|
|
|
|
apiVersion: apps/v1
|
|
|
|
kind: Deployment
|
|
|
|
name: prometheus-postgres-exporter-unittest
|
|
|
|
namespace: testing
|
|
|
|
- notExists:
|
|
|
|
path: metadata.annotations
|
|
|
|
- equal:
|
|
|
|
path: metadata.labels
|
|
|
|
value:
|
|
|
|
app.kubernetes.io/instance: prometheus-postgres-exporter-unittest
|
|
|
|
app.kubernetes.io/managed-by: Helm
|
|
|
|
app.kubernetes.io/name: prometheus-postgres-exporter
|
|
|
|
app.kubernetes.io/version: 0.1.0
|
|
|
|
helm.sh/chart: prometheus-postgres-exporter-0.1.0
|
|
|
|
- contains:
|
|
|
|
path: spec.template.spec.containers[0].envFrom
|
|
|
|
content:
|
|
|
|
secretRef:
|
|
|
|
name: prometheus-postgres-exporter-unittest-database-env
|
2024-11-26 17:32:24 +00:00
|
|
|
- equal:
|
|
|
|
path: spec.template.spec.containers[0].args
|
|
|
|
value:
|
|
|
|
- --config.file=/etc/prometheus-postgres-exporter/config.d/exporterConfig.yaml
|
|
|
|
- --web.config.file=/etc/prometheus-postgres-exporter/config.d/web-config.yaml
|
|
|
|
- --web.listen-address=:9187
|
2024-11-26 17:49:46 +00:00
|
|
|
- equal:
|
|
|
|
path: spec.template.spec.containers[0].volumeMounts
|
|
|
|
value:
|
|
|
|
- mountPath: /etc/prometheus-postgres-exporter/config.d
|
|
|
|
name: config.d
|
|
|
|
- equal:
|
|
|
|
path: spec.template.spec.volumes
|
|
|
|
value:
|
|
|
|
- name: config.d
|
|
|
|
projected:
|
|
|
|
defaultMode: "0444"
|
|
|
|
sources:
|
|
|
|
- secret:
|
|
|
|
name: prometheus-postgres-exporter-unittest-exporter-config
|
|
|
|
- secret:
|
|
|
|
name: prometheus-postgres-exporter-unittest-web-config
|
2024-11-26 18:03:20 +00:00
|
|
|
- equal:
|
|
|
|
path: spec.template.spec.containers[0].image
|
|
|
|
value: quay.io/prometheuscommunity/postgres-exporter:v0.1.0
|
|
|
|
- equal:
|
|
|
|
path: spec.template.spec.containers[0].imagePullPolicy
|
|
|
|
value: IfNotPresent
|
2024-11-26 18:08:40 +00:00
|
|
|
- notExists:
|
|
|
|
path: spec.template.spec.containers[0].resources
|
2024-11-26 18:21:39 +00:00
|
|
|
- notExists:
|
|
|
|
path: spec.template.spec.containers[0].securityContext
|
2024-11-26 18:36:44 +00:00
|
|
|
- notExists:
|
|
|
|
path: spec.template.spec.dnsConfig
|
2024-11-26 18:37:56 +00:00
|
|
|
- notExists:
|
|
|
|
path: spec.template.spec.dnsPolicy
|
2024-11-26 18:41:40 +00:00
|
|
|
- notExists:
|
|
|
|
path: spec.template.spec.hostname
|
|
|
|
- equal:
|
|
|
|
path: spec.template.spec.hostNetwork
|
|
|
|
value: false
|
2024-11-26 18:44:34 +00:00
|
|
|
- notExists:
|
|
|
|
path: spec.template.spec.imagePullSecrets
|
2024-11-26 18:32:04 +00:00
|
|
|
- notExists:
|
|
|
|
path: spec.template.spec.nodeSelector
|
2024-11-26 18:34:48 +00:00
|
|
|
- notExists:
|
|
|
|
path: spec.template.spec.priorityClassName
|
2024-11-26 18:48:20 +00:00
|
|
|
- notExists:
|
|
|
|
path: spec.template.spec.restartPolicy
|
2024-11-26 18:41:40 +00:00
|
|
|
- notExists:
|
|
|
|
path: spec.template.spec.subdomain
|
2024-11-26 18:50:08 +00:00
|
|
|
- equal:
|
|
|
|
path: spec.template.spec.terminationGracePeriodSeconds
|
|
|
|
value: 60
|
2024-11-26 17:32:24 +00:00
|
|
|
|
|
|
|
- it: Test additional arguments
|
|
|
|
set:
|
|
|
|
deployment.postgresExporter.args:
|
|
|
|
- "--foo=bar"
|
|
|
|
- "--bar=foo"
|
|
|
|
asserts:
|
|
|
|
- equal:
|
|
|
|
path: spec.template.spec.containers[0].args
|
|
|
|
value:
|
|
|
|
- --config.file=/etc/prometheus-postgres-exporter/config.d/exporterConfig.yaml
|
|
|
|
- --web.config.file=/etc/prometheus-postgres-exporter/config.d/web-config.yaml
|
|
|
|
- --web.listen-address=:9187
|
|
|
|
- --foo=bar
|
|
|
|
- --bar=foo
|
2024-11-25 10:53:09 +00:00
|
|
|
|
2024-11-26 18:03:20 +00:00
|
|
|
- it: Test custom imageRegistry and imageRepository
|
|
|
|
set:
|
|
|
|
deployment.postgresExporter.image.registry: registry.example.local
|
|
|
|
deployment.postgresExporter.image.repository: path/special/prometheus-postgres-exporter
|
|
|
|
asserts:
|
|
|
|
- equal:
|
|
|
|
path: spec.template.spec.containers[0].image
|
|
|
|
value: registry.example.local/path/special/prometheus-postgres-exporter:v0.1.0
|
|
|
|
|
|
|
|
- it: Test custom imagePullPolicy
|
|
|
|
set:
|
|
|
|
deployment.postgresExporter.image.pullPolicy: Always
|
|
|
|
asserts:
|
|
|
|
- equal:
|
|
|
|
path: spec.template.spec.containers[0].imagePullPolicy
|
|
|
|
value: Always
|
|
|
|
|
|
|
|
- it: Test config.database.existingSecret
|
2024-11-25 10:53:09 +00:00
|
|
|
set:
|
|
|
|
config.database.existingSecret.enabled: true
|
|
|
|
config.database.existingSecret.secretName: custom-database-secret
|
|
|
|
asserts:
|
|
|
|
- contains:
|
|
|
|
path: spec.template.spec.containers[0].envFrom
|
|
|
|
content:
|
|
|
|
secretRef:
|
|
|
|
name: custom-database-secret
|
2024-11-26 17:49:46 +00:00
|
|
|
|
2024-11-26 18:03:44 +00:00
|
|
|
- it: Test config.exporterConfig.existingSecret
|
2024-11-26 17:49:46 +00:00
|
|
|
set:
|
|
|
|
config.exporterConfig.existingSecret.enabled: true
|
|
|
|
config.exporterConfig.existingSecret.secretName: exporter-config-secret
|
|
|
|
asserts:
|
|
|
|
- equal:
|
|
|
|
path: spec.template.spec.containers[0].volumeMounts
|
|
|
|
value:
|
|
|
|
- mountPath: /etc/prometheus-postgres-exporter/config.d
|
|
|
|
name: config.d
|
|
|
|
- equal:
|
|
|
|
path: spec.template.spec.volumes
|
|
|
|
value:
|
|
|
|
- name: config.d
|
|
|
|
projected:
|
|
|
|
defaultMode: "0444"
|
|
|
|
sources:
|
|
|
|
- secret:
|
|
|
|
name: exporter-config-secret
|
|
|
|
- secret:
|
|
|
|
name: prometheus-postgres-exporter-unittest-web-config
|
|
|
|
|
2024-11-26 18:03:44 +00:00
|
|
|
- it: Test config.webConfig.existingSecret
|
2024-11-26 17:49:46 +00:00
|
|
|
set:
|
|
|
|
config.webConfig.existingSecret.enabled: true
|
|
|
|
config.webConfig.existingSecret.secretName: web-config-secret
|
|
|
|
asserts:
|
|
|
|
- equal:
|
|
|
|
path: spec.template.spec.containers[0].volumeMounts
|
|
|
|
value:
|
|
|
|
- mountPath: /etc/prometheus-postgres-exporter/config.d
|
|
|
|
name: config.d
|
|
|
|
- equal:
|
|
|
|
path: spec.template.spec.volumes
|
|
|
|
value:
|
|
|
|
- name: config.d
|
|
|
|
projected:
|
|
|
|
defaultMode: "0444"
|
|
|
|
sources:
|
|
|
|
- secret:
|
|
|
|
name: prometheus-postgres-exporter-unittest-exporter-config
|
|
|
|
- secret:
|
|
|
|
name: web-config-secret
|
2024-11-26 18:03:44 +00:00
|
|
|
|
2024-11-26 18:08:40 +00:00
|
|
|
- it: Test custom resource limits and requests
|
|
|
|
set:
|
|
|
|
deployment.postgresExporter.resources:
|
|
|
|
limits:
|
|
|
|
cpu: 100m
|
|
|
|
memory: 250MB
|
|
|
|
requests:
|
|
|
|
cpu: 25m
|
|
|
|
memory: 100MB
|
|
|
|
asserts:
|
|
|
|
- equal:
|
|
|
|
path: spec.template.spec.containers[0].resources
|
|
|
|
value:
|
|
|
|
limits:
|
|
|
|
cpu: 100m
|
|
|
|
memory: 250MB
|
|
|
|
requests:
|
|
|
|
cpu: 25m
|
|
|
|
memory: 100MB
|
|
|
|
|
2024-11-26 18:21:39 +00:00
|
|
|
- it: Test custom securityContext
|
|
|
|
set:
|
|
|
|
deployment.postgresExporter.securityContext:
|
|
|
|
capabilities:
|
|
|
|
add:
|
|
|
|
- NET_RAW
|
|
|
|
drop:
|
|
|
|
- ALL
|
|
|
|
privileged: false
|
|
|
|
readOnlyRootFilesystem: true
|
|
|
|
runAsNonRoot: true
|
|
|
|
runAsUser: 1000
|
|
|
|
asserts:
|
|
|
|
- equal:
|
|
|
|
path: spec.template.spec.containers[0].securityContext
|
|
|
|
value:
|
|
|
|
capabilities:
|
|
|
|
add:
|
|
|
|
- NET_RAW
|
|
|
|
drop:
|
|
|
|
- ALL
|
|
|
|
privileged: false
|
|
|
|
readOnlyRootFilesystem: true
|
|
|
|
runAsNonRoot: true
|
|
|
|
runAsUser: 1000
|
|
|
|
|
2024-11-26 18:36:44 +00:00
|
|
|
- it: Test dnsConfig
|
|
|
|
set:
|
|
|
|
deployment.dnsConfig:
|
|
|
|
nameservers:
|
|
|
|
- "8.8.8.8"
|
|
|
|
- "8.8.4.4"
|
|
|
|
asserts:
|
|
|
|
- equal:
|
|
|
|
path: spec.template.spec.dnsConfig
|
|
|
|
value:
|
|
|
|
nameservers:
|
|
|
|
- "8.8.8.8"
|
|
|
|
- "8.8.4.4"
|
|
|
|
|
2024-11-26 18:37:56 +00:00
|
|
|
- it: Test dnsPolicy
|
|
|
|
set:
|
|
|
|
deployment.dnsPolicy: ClusterFirst
|
|
|
|
asserts:
|
|
|
|
- equal:
|
|
|
|
path: spec.template.spec.dnsPolicy
|
|
|
|
value: ClusterFirst
|
|
|
|
|
2024-11-26 18:41:40 +00:00
|
|
|
- it: Test hostNetwork, hostname, subdomain
|
|
|
|
set:
|
|
|
|
deployment.hostNetwork: true
|
|
|
|
deployment.hostname: pg-exporter
|
|
|
|
deployment.subdomain: exporters.internal
|
|
|
|
asserts:
|
|
|
|
- equal:
|
|
|
|
path: spec.template.spec.hostNetwork
|
|
|
|
value: true
|
|
|
|
- equal:
|
|
|
|
path: spec.template.spec.hostname
|
|
|
|
value: pg-exporter
|
|
|
|
- equal:
|
|
|
|
path: spec.template.spec.subdomain
|
|
|
|
value: exporters.internal
|
|
|
|
|
2024-11-26 18:44:34 +00:00
|
|
|
- it: Test imagePullSecrets
|
|
|
|
set:
|
|
|
|
deployment.imagePullSecrets:
|
|
|
|
- name: my-pull-secret
|
|
|
|
- name: my-special-secret
|
|
|
|
asserts:
|
|
|
|
- equal:
|
|
|
|
path: spec.template.spec.imagePullSecrets
|
|
|
|
value:
|
|
|
|
- name: my-pull-secret
|
|
|
|
- name: my-special-secret
|
|
|
|
|
2024-11-26 18:32:04 +00:00
|
|
|
- it: Test nodeSelector
|
|
|
|
set:
|
|
|
|
deployment.nodeSelector:
|
|
|
|
foo: bar
|
|
|
|
asserts:
|
|
|
|
- equal:
|
|
|
|
path: spec.template.spec.nodeSelector
|
|
|
|
value:
|
|
|
|
foo: bar
|
|
|
|
|
2024-11-26 18:34:48 +00:00
|
|
|
- it: Test priorityClassName
|
|
|
|
set:
|
|
|
|
deployment.priorityClassName: my-priority
|
|
|
|
asserts:
|
|
|
|
- equal:
|
|
|
|
path: spec.template.spec.priorityClassName
|
|
|
|
value: my-priority
|
|
|
|
|
2024-11-26 18:48:20 +00:00
|
|
|
- it: Test restartPolicy
|
|
|
|
set:
|
|
|
|
deployment.restartPolicy: Always
|
|
|
|
asserts:
|
|
|
|
- equal:
|
|
|
|
path: spec.template.spec.restartPolicy
|
|
|
|
value: Always
|
|
|
|
|
2024-11-26 18:50:08 +00:00
|
|
|
- it: Test terminationGracePeriodSeconds
|
|
|
|
set:
|
|
|
|
deployment.terminationGracePeriodSeconds: 120
|
|
|
|
asserts:
|
|
|
|
- equal:
|
|
|
|
path: spec.template.spec.terminationGracePeriodSeconds
|
|
|
|
value: 120
|
|
|
|
|
2024-11-26 18:03:44 +00:00
|
|
|
- it: Test additional volumeMounts and volumes
|
|
|
|
set:
|
|
|
|
deployment.postgresExporter.volumeMounts:
|
|
|
|
- name: data
|
|
|
|
mountPath: /usr/lib/prometheus-postgres-exporter/data
|
|
|
|
deployment.volumes:
|
|
|
|
- name: data
|
|
|
|
hostPath:
|
|
|
|
path: /usr/lib/prometheus-postgres-exporter/data
|
|
|
|
asserts:
|
|
|
|
- contains:
|
|
|
|
path: spec.template.spec.containers[0].volumeMounts
|
|
|
|
content:
|
|
|
|
name: data
|
|
|
|
mountPath: /usr/lib/prometheus-postgres-exporter/data
|
|
|
|
- contains:
|
|
|
|
path: spec.template.spec.volumes
|
|
|
|
content:
|
|
|
|
name: data
|
|
|
|
hostPath:
|
|
|
|
path: /usr/lib/prometheus-postgres-exporter/data
|