Skip to content

Commit

Permalink
Merge pull request #96 from diebietse/daemon-set
Browse files Browse the repository at this point in the history
Add DaemonSet support
  • Loading branch information
joe-elliott authored Oct 12, 2021
2 parents 9ea1f30 + 5edad1b commit 29ca7fe
Show file tree
Hide file tree
Showing 10 changed files with 228 additions and 260 deletions.
2 changes: 1 addition & 1 deletion helm/cert-exporter/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ name: cert-exporter
description: Monitors and exposes PKI information as Prometheus metrics

type: application
version: 2.7.4
version: 3.0.0
appVersion: v2.7.0
66 changes: 17 additions & 49 deletions helm/cert-exporter/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Create chart name and version as used by the chart label.
{{- end -}}

{{/*
Labels for a generic resource not belonging to the Deployment or Daemonsets
Labels for a generic resource not belonging to the Deployment or DaemonSet
*/}}
{{- define "cert-exporter.genericLabels" -}}
helm.sh/chart: {{ include "cert-exporter.chart" . }}
Expand All @@ -44,74 +44,33 @@ app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end -}}

{{/*
Selector labels for a generic resource not belonging to the Deployment or Daemonsets
Selector labels for a generic resource not belonging to the Deployment or DaemonSet
*/}}
{{- define "cert-exporter.genericSelectorLabels" -}}
app.kubernetes.io/name: {{ include "cert-exporter.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end -}}

{{/*
Labels for the Deployment monitoring the cert-manager Deployment
Labels for the Deployment and DaemonSet
*/}}
{{- define "cert-exporter.certManagerDeploymentLabels" -}}
{{- define "cert-exporter.certManagerLabels" -}}
helm.sh/chart: {{ include "cert-exporter.chart" . }}
{{ include "cert-exporter.certManagerDeploymentSelectorLabels" . }}
{{ include "cert-exporter.certManagerSelectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end -}}

{{/*
Selector labels for the Deployment monitoring the cert-manager Deployment
Selector labels for the Deployment and DaemonSet
*/}}
{{- define "cert-exporter.certManagerDeploymentSelectorLabels" -}}
{{- define "cert-exporter.certManagerSelectorLabels" -}}
{{ include "cert-exporter.genericSelectorLabels" . }}
cert-exporter.io/type: deployment
cert-exporter.io/type: {{ kebabcase .Values.certManager.kind }}
{{- end -}}

{{/*
Labels for the Deployment monitoring the cert-manager Deployment
*/}}
{{- define "cert-exporter.daemonsetMasterLabels" -}}
helm.sh/chart: {{ include "cert-exporter.chart" . }}
{{ include "cert-exporter.daemonsetMasterSelectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end -}}

{{/*
Selector labels for Master DaemonSet
*/}}
{{- define "cert-exporter.daemonsetMasterSelectorLabels" -}}
{{ include "cert-exporter.genericSelectorLabels" . }}
cert-exporter.io/type: daemonset-master
{{- end -}}

{{/*
Labels for the Deployment monitoring the cert-manager Deployment
*/}}
{{- define "cert-exporter.daemonsetWorkerLabels" -}}
helm.sh/chart: {{ include "cert-exporter.chart" . }}
{{ include "cert-exporter.daemonsetWorkerSelectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end -}}

{{/*
Selector labels for Worker DaemonSet
*/}}
{{- define "cert-exporter.daemonsetWorkerSelectorLabels" -}}
{{ include "cert-exporter.genericSelectorLabels" . }}
cert-exporter.io/type: daemonset-worker
{{- end -}}


{{/*
Create the name of the service account to use
*/}}
Expand All @@ -122,3 +81,12 @@ Create the name of the service account to use
{{ default "default" .Values.rbac.serviceAccount.name }}
{{- end -}}
{{- end -}}

{{/*
Check the exporter kind is Deployment or DaemonSet
*/}}
{{- define "certManager.assertValidKind" -}}
{{- if not (or (eq .Values.certManager.kind "DaemonSet") (eq .Values.certManager.kind "Deployment")) -}}
{{- fail "certManager.kind should be one of either Deployment or DaemonSet" -}}
{{- end -}}
{{- end -}}
64 changes: 64 additions & 0 deletions helm/cert-exporter/templates/cert-manager/cert-manager.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
{{- include "certManager.assertValidKind" . }}
apiVersion: apps/v1
kind: {{ .Values.certManager.kind }}
metadata:
name: "{{- include "cert-exporter.fullname" . -}}-cert-manager"
labels:
{{- include "cert-exporter.certManagerLabels" . | nindent 4 }}
spec:
{{- if eq .Values.certManager.kind "Deployment" }}
replicas: {{ .Values.certManager.replicaCount }}
{{- end }}
selector:
matchLabels:
{{- include "cert-exporter.certManagerSelectorLabels" . | nindent 6 }}
template:
metadata:
labels:
{{- include "cert-exporter.certManagerSelectorLabels" . | nindent 8 }}
annotations:
{{- toYaml .Values.certManager.podAnnotations | nindent 8 }}
spec:
{{- with .Values.certManager.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "cert-exporter.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.certManager.podSecurityContext | nindent 8 }}
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.certManager.securityContext | nindent 12 }}
image: "{{ .Values.certManager.image.repository }}:{{ .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.certManager.image.pullPolicy }}
{{- with .Values.certManager.image.command }}
command:
{{- toYaml . | nindent 12}}
{{- end}}
{{- with .Values.certManager.image.args }}
args:
{{- toYaml . | nindent 12}}
{{- end}}
ports:
- name: http
containerPort: 8080
protocol: TCP
resources:
{{- toYaml .Values.certManager.resources | nindent 12 }}
volumeMounts:
{{- toYaml .Values.certManager.volumeMounts | nindent 12 }}
{{- with .Values.certManager.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.certManager.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.certManager.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
volumes:
{{- toYaml .Values.certManager.volumes | nindent 8 }}
18 changes: 18 additions & 0 deletions helm/cert-exporter/templates/cert-manager/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "cert-exporter.fullname" . }}
labels:
{{- include "cert-exporter.certManagerLabels" . | nindent 4 }}
{{- with .Values.service.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.port }}
name: {{ .Values.service.portName }}
targetPort: 8080
selector:
{{ include "cert-exporter.certManagerSelectorLabels" . | nindent 6 }}
30 changes: 30 additions & 0 deletions helm/cert-exporter/templates/cert-manager/servicemonitor.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{{- if .Values.service.serviceMonitor.create -}}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: {{ template "cert-exporter.fullname" . }}-cert-manager
labels:
{{- toYaml .Values.service.serviceMonitor.additionalLabels | nindent 4 }}
{{- include "cert-exporter.certManagerLabels" . | nindent 4 }}
spec:
jobLabel: jobLabel
selector:
matchLabels:
{{- include "cert-exporter.certManagerSelectorLabels" . | nindent 6 }}
namespaceSelector:
matchNames:
- {{ .Release.Namespace | quote }}
endpoints:
- port: {{ .Values.service.portName }}
{{- if .Values.service.serviceMonitor.interval}}
interval: {{ .Values.service.serviceMonitor.interval }}
{{- end }}
{{- if .Values.service.serviceMonitor.metricRelabelings }}
metricRelabelings:
{{ toYaml .Values.service.serviceMonitor.metricRelabelings | nindent 6 }}
{{- end }}
{{- if .Values.service.serviceMonitor.relabelings }}
relabelings:
{{ toYaml .Values.service.serviceMonitor.relabelings | nindent 6 }}
{{- end }}
{{- end }}
4 changes: 2 additions & 2 deletions helm/cert-exporter/templates/dashboards/dashboard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ metadata:
name: "{{ include "cert-exporter.fullname" . }}-default-dashboard"
namespace: {{ .Values.dashboards.namespace }}
labels:
{{ toYaml .Values.dashboards.additionalLabels | nindent 4 }}
{{ include "cert-exporter.genericLabels" . | nindent 4 }}
{{- toYaml .Values.dashboards.additionalLabels | nindent 4 }}
{{- include "cert-exporter.genericLabels" . | nindent 4 }}
data:
cert-exporter-default-dashboard.json: |-
{
Expand Down
61 changes: 0 additions & 61 deletions helm/cert-exporter/templates/deployment/deployment.yaml

This file was deleted.

18 changes: 0 additions & 18 deletions helm/cert-exporter/templates/deployment/service.yaml

This file was deleted.

30 changes: 0 additions & 30 deletions helm/cert-exporter/templates/deployment/servicemonitor.yaml

This file was deleted.

Loading

0 comments on commit 29ca7fe

Please sign in to comment.