Hi,
Solves issue #1
I've added a helm chart definition and updated the readme accordingly.
Compared to a standard template that you get with helm create
I've removed ingress.
I had some trouble getting the ServiceMonitor
to work if I install the monitor in the same namespace as the helm release - maybe you can figure it out?
An example of the rendered manifest is shown here:
$ helm template cert-checker deploy/charts/cert-checker --namespace cert-checker
---
# Source: cert-checker/templates/serviceaccount.yaml
apiVersion: v1
kind: ServiceAccount
metadata:
name: cert-checker
labels:
helm.sh/chart: cert-checker-0.0.1
app.kubernetes.io/name: cert-checker
app.kubernetes.io/instance: cert-checker
app.kubernetes.io/version: "0.0.1"
app.kubernetes.io/managed-by: Helm
---
# Source: cert-checker/templates/configmap.yaml
apiVersion: v1
kind: ConfigMap
metadata:
name: cert-checker
labels:
helm.sh/chart: cert-checker-0.0.1
app.kubernetes.io/name: cert-checker
app.kubernetes.io/instance: cert-checker
app.kubernetes.io/version: "0.0.1"
app.kubernetes.io/managed-by: Helm
data:
config.yaml: |
certificates:
- dns: google.com
- dns: example.com
- dns: expired.badssl.com
- dns: wrong.host.badssl.com
- dns: untrusted-root.badssl.com
- dns: self-signed.badssl.com
- dns: revoked.badssl.com
- dns: dh480.badssl.com
- dns: dh512.badssl.com
- dns: null.badssl.com
- dns: rc4-md5.badssl.com
- dns: rc4.badssl.com
intervalminutes: 1
loglevel: info
---
# Source: cert-checker/templates/grafana-dashboard-cm.yaml
apiVersion: v1
kind: ConfigMap
metadata:
name: cert-checker-grafana-dashboard
labels:
grafana_dashboard: "1"
helm.sh/chart: cert-checker-0.0.1
app.kubernetes.io/name: cert-checker
app.kubernetes.io/instance: cert-checker
app.kubernetes.io/version: "0.0.1"
app.kubernetes.io/managed-by: Helm
data:
cert-checker.json: |-
{
"annotations": {
"list": [
{
"builtIn": 1,
"datasource": "Prometheus",
"enable": true,
"hide": true,
"iconColor": "rgba(0, 211, 255, 1)",
"limit": 100,
"name": "Annotations & Alerts",
"showIn": 0,
"type": "dashboard"
}
]
},
"description": "Dashboard for viewing the status of production certificates. To be used with the cert-checker project.https://github.com/mogensen/cert-checker",
"editable": true,
"gnetId": 12833,
"graphTooltip": 0,
"links": [],
"panels": [
{
"datasource": null,
"fieldConfig": {
"defaults": {
"custom": {},
"mappings": [],
"min": 0,
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 1
}
]
}
},
"overrides": []
},
"gridPos": {
"h": 5,
"w": 8,
"x": 0,
"y": 0
},
"id": 4,
"options": {
"colorMode": "background",
"graphMode": "area",
"justifyMode": "auto",
"orientation": "auto",
"reduceOptions": {
"calcs": [
"lastNotNull"
],
"fields": "",
"values": false
},
"textMode": "auto"
},
"pluginVersion": "7.3.5",
"targets": [
{
"expr": "count(cert_checker_is_valid == 0)",
"interval": "",
"legendFormat": "",
"refId": "A"
}
],
"timeFrom": null,
"timeShift": null,
"title": "Broken Certificates",
"type": "stat"
},
{
"datasource": null,
"description": "Certificates with a lifetime < 30 days",
"fieldConfig": {
"defaults": {
"custom": {},
"mappings": [],
"min": 0,
"noValue": "0",
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
}
]
}
},
"overrides": []
},
"gridPos": {
"h": 5,
"w": 8,
"x": 8,
"y": 0
},
"id": 9,
"options": {
"colorMode": "background",
"graphMode": "area",
"justifyMode": "auto",
"orientation": "auto",
"reduceOptions": {
"calcs": [
"last"
],
"fields": "",
"values": false
},
"textMode": "auto"
},
"pluginVersion": "7.3.5",
"targets": [
{
"expr": "count( ((cert_checker_expire_time{} - time()) / 86400 >= 0) < 30)",
"interval": "",
"legendFormat": "",
"refId": "A"
}
],
"timeFrom": null,
"timeShift": null,
"title": "Certificates about to expire",
"type": "stat"
},
{
"datasource": null,
"fieldConfig": {
"defaults": {
"custom": {},
"mappings": [],
"min": 0,
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
}
]
}
},
"overrides": []
},
"gridPos": {
"h": 5,
"w": 8,
"x": 16,
"y": 0
},
"id": 5,
"options": {
"colorMode": "background",
"graphMode": "area",
"justifyMode": "auto",
"orientation": "auto",
"reduceOptions": {
"calcs": [
"lastNotNull"
],
"fields": "",
"values": false
},
"textMode": "auto"
},
"pluginVersion": "7.3.5",
"targets": [
{
"expr": "count(cert_checker_is_valid > 0)",
"interval": "",
"legendFormat": "",
"refId": "A"
}
],
"timeFrom": null,
"timeShift": null,
"title": "Good Certificates",
"type": "stat"
},
{
"datasource": "Prometheus",
"description": "",
"fieldConfig": {
"defaults": {
"color": {
"fixedColor": "red",
"mode": "fixed"
},
"custom": {
"align": null,
"displayMode": "color-text",
"filterable": false
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 80
}
]
}
},
"overrides": [
{
"matcher": {
"id": "byName",
"options": "Is Latest"
},
"properties": [
{
"id": "mappings",
"value": [
{
"from": "",
"id": 0,
"text": "No",
"to": "",
"type": 1,
"value": "0"
},
{
"from": "1",
"id": 1,
"text": "Yes",
"to": "999999999",
"type": 2,
"value": "1"
}
]
},
{
"id": "custom.align",
"value": "left"
}
]
},
{
"matcher": {
"id": "byName",
"options": "not_after"
},
"properties": [
{
"id": "custom.width",
"value": 225
}
]
},
{
"matcher": {
"id": "byName",
"options": "not_before"
},
"properties": [
{
"id": "custom.width",
"value": 234
}
]
},
{
"matcher": {
"id": "byName",
"options": "issuer"
},
"properties": [
{
"id": "custom.width",
"value": 395
}
]
},
{
"matcher": {
"id": "byName",
"options": "cert_error"
},
"properties": [
{
"id": "custom.width",
"value": 640
}
]
}
]
},
"gridPos": {
"h": 9,
"w": 24,
"x": 0,
"y": 5
},
"id": 2,
"options": {
"showHeader": true,
"sortBy": [
{
"desc": true,
"displayName": "not_after"
}
]
},
"pluginVersion": "7.3.5",
"targets": [
{
"expr": "sum by(dns, issuer, not_before, not_after, cert_error) (cert_checker_is_valid) == 0",
"format": "time_series",
"instant": true,
"interval": "",
"legendFormat": "",
"refId": "A"
}
],
"timeFrom": null,
"timeShift": null,
"title": "Certificates with errors",
"transformations": [
{
"id": "labelsToFields",
"options": {}
},
{
"id": "organize",
"options": {
"excludeByName": {
"Time": true,
"Value": true,
"container": false
},
"indexByName": {
"Time": 0,
"Value": 6,
"cert_error": 5,
"dns": 1,
"issuer": 2,
"not_after": 4,
"not_before": 3
},
"renameByName": {
"Value": "Is Valid",
"cert_error": "",
"current_version": "Current Version",
"dns": "",
"image": "Image",
"latest_version": "Latest Version",
"not_after": ""
}
}
}
],
"type": "table"
},
{
"datasource": "Prometheus",
"description": "",
"fieldConfig": {
"defaults": {
"color": {
"mode": "thresholds"
},
"custom": {
"align": null,
"displayMode": "color-text",
"filterable": true
},
"decimals": 1,
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "rgb(249, 249, 249)",
"value": null
},
{
"color": "red",
"value": 0
},
{
"color": "yellow",
"value": 15
},
{
"color": "green",
"value": 30
}
]
},
"unit": "d"
},
"overrides": [
{
"matcher": {
"id": "byName",
"options": "Is Latest"
},
"properties": [
{
"id": "mappings",
"value": [
{
"from": "",
"id": 0,
"text": "No",
"to": "",
"type": 1,
"value": "0"
},
{
"from": "1",
"id": 1,
"text": "Yes",
"to": "999999999",
"type": 2,
"value": "1"
}
]
},
{
"id": "custom.align",
"value": "left"
}
]
}
]
},
"gridPos": {
"h": 9,
"w": 24,
"x": 0,
"y": 14
},
"id": 8,
"options": {
"showHeader": true,
"sortBy": [
{
"desc": false,
"displayName": "Value"
}
]
},
"pluginVersion": "7.3.5",
"targets": [
{
"expr": "(cert_checker_expire_time{} - time()) / 60/60/24",
"format": "table",
"instant": true,
"interval": "",
"legendFormat": "",
"refId": "A"
}
],
"timeFrom": null,
"timeShift": null,
"title": "Certification Expirations",
"transformations": [
{
"id": "labelsToFields",
"options": {}
},
{
"id": "organize",
"options": {
"excludeByName": {
"Time": true,
"Value": false,
"__name__": true,
"container": true,
"endpoint": true,
"instance": true,
"job": true,
"namespace": true,
"pod": true,
"service": true
},
"indexByName": {
"Time": 0,
"Value": 6,
"cert_error": 5,
"dns": 1,
"issuer": 2,
"not_after": 4,
"not_before": 3
},
"renameByName": {
"Value": "",
"cert_error": "",
"current_version": "Current Version",
"dns": "",
"image": "Image",
"latest_version": "Latest Version",
"not_after": ""
}
}
}
],
"type": "table"
}
],
"refresh": "5m",
"schemaVersion": 26,
"style": "dark",
"tags": [],
"templating": {
"list": []
},
"time": {
"from": "now-30m",
"to": "now"
},
"timepicker": {
"refresh_intervals": [
"10s",
"30s",
"1m",
"5m",
"15m",
"30m",
"1h",
"2h",
"1d"
]
},
"timezone": "",
"title": "Certificate Checker",
"uid": "cert-checker",
"version": 1
}
---
# Source: cert-checker/templates/service.yaml
apiVersion: v1
kind: Service
metadata:
name: cert-checker
labels:
helm.sh/chart: cert-checker-0.0.1
app.kubernetes.io/name: cert-checker
app.kubernetes.io/instance: cert-checker
app.kubernetes.io/version: "0.0.1"
app.kubernetes.io/managed-by: Helm
spec:
type: ClusterIP
ports:
- port: 8080
targetPort: http
protocol: TCP
name: http
selector:
app.kubernetes.io/name: cert-checker
app.kubernetes.io/instance: cert-checker
---
# Source: cert-checker/templates/deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: cert-checker
labels:
helm.sh/chart: cert-checker-0.0.1
app.kubernetes.io/name: cert-checker
app.kubernetes.io/instance: cert-checker
app.kubernetes.io/version: "0.0.1"
app.kubernetes.io/managed-by: Helm
spec:
replicas: 1
selector:
matchLabels:
app.kubernetes.io/name: cert-checker
app.kubernetes.io/instance: cert-checker
template:
metadata:
annotations:
checksum/config: acdfcef4913d7e7cbb5b4adb47ba00a7e7d44b27e4d5b673f73ad29a539722a5
enable.cert-checker.io/cert-checker: "true"
prometheus.io/path: /metrics
prometheus.io/port: "8080"
prometheus.io/scrape: "true"
labels:
app.kubernetes.io/name: cert-checker
app.kubernetes.io/instance: cert-checker
spec:
serviceAccountName: cert-checker
securityContext:
fsGroup: 2000
volumes:
- name: config-volume
configMap:
name: cert-checker
containers:
- name: cert-checker
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop:
- ALL
readOnlyRootFilesystem: true
runAsNonRoot: true
runAsUser: 1000
image: "mogensen/cert-checker:v0.0.1"
command: ["/app/cert-checker", "-c", "/data/config.yaml"]
imagePullPolicy: IfNotPresent
volumeMounts:
- name: config-volume
mountPath: /data/
ports:
- name: http
containerPort: 8080
protocol: TCP
resources:
{}
---
# Source: cert-checker/templates/servicemonitor.yaml
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: cert-checker
labels:
helm.sh/chart: cert-checker-0.0.1
app.kubernetes.io/name: cert-checker
app.kubernetes.io/instance: cert-checker
app.kubernetes.io/version: "0.0.1"
app.kubernetes.io/managed-by: Helm
spec:
selector:
matchLabels:
app.kubernetes.io/name: cert-checker
endpoints:
- port: http
---
# Source: cert-checker/templates/tests/test-connection.yaml
apiVersion: v1
kind: Pod
metadata:
name: "cert-checker-test-connection"
labels:
helm.sh/chart: cert-checker-0.0.1
app.kubernetes.io/name: cert-checker
app.kubernetes.io/instance: cert-checker
app.kubernetes.io/version: "0.0.1"
app.kubernetes.io/managed-by: Helm
annotations:
"helm.sh/hook": test
spec:
containers:
- name: wget
image: busybox
command: ['wget']
args: ['cert-checker:8080/metrics']
restartPolicy: Never