diff --git a/charts/kor/templates/deployment.yaml b/charts/kor/templates/deployment.yaml new file mode 100644 index 00000000..3abf505b --- /dev/null +++ b/charts/kor/templates/deployment.yaml @@ -0,0 +1,66 @@ +{{- if .Values.prometheusExporter.enabled -}} +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ .Values.prometheusExporter.name }} + labels: + app: {{ .Values.prometheusExporter.name }} +spec: + {{- with .Values.prometheusExporter.deployment.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent }} + {{- end }} + replicas: {{ .Values.prometheusExporter.deployment.replicaCount | default 1 }} + selector: + matchLabels: + app: {{ .Values.prometheusExporter.name }} + template: + metadata: + labels: + app: {{ .Values.prometheusExporter.name }} + spec: + serviceAccountName: {{ include "kor.serviceAccountName" . }} + containers: + - name: "{{ .Values.prometheusExporter.name }}-container" + {{- with .Values.prometheusExporter.deployment.securityContext }} + securityContext: + {{ toYaml . | nindent 12 }} + {{- end }} + image: "{{ .Values.prometheusExporter.deployment.image.repository }}:{{ .Values.prometheusExporter.deployment.image.tag }}" + command: ["/bin/sh", "-c"] + args: ["{{ .Values.prometheusExporter.deployment.command }}"] + ports: + - containerPort: 8080 + name: http + protocol: TCP + {{- with .Values.prometheusExporter.deployment.resources }} + resources: + {{- toYaml . | nindent 12 }} + {{- end }} + {{- if .Values.prometheusExporter.exporterInterval }} + env: + - name: EXPORTER_INTERVAL + value: {{ .Values.prometheusExporter.exporterInterval }} + {{- end}} + {{- with .Values.prometheusExporter.deployment.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.prometheusExporter.deployment.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.prometheusExporter.deployment.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} + terminationMessagePath: "/dev/termination-log" + imagePullPolicy: {{ .Values.prometheusExporter.deployment.imagePullPolicy }} + restartPolicy: {{ .Values.prometheusExporter.deployment.restartPolicy }} + terminationGracePeriodSeconds: 30 + dnsPolicy: ClusterFirst + {{- with .Values.prometheusExporter.deployment.podSecurityContext }} + securityContext: + {{- toYaml . | nindent 8}} + {{- end }} +{{- end }} \ No newline at end of file diff --git a/charts/kor/templates/service.yaml b/charts/kor/templates/service.yaml new file mode 100644 index 00000000..d8b58272 --- /dev/null +++ b/charts/kor/templates/service.yaml @@ -0,0 +1,20 @@ +{{- if .Values.prometheusExporter.enabled -}} +apiVersion: v1 +kind: Service +metadata: + name: {{ .Values.prometheusExporter.name }} + annotations: + prometheus.io/scrape: "true" + prometheus.io/path: /metrics + prometheus.io/port: "8080" + labels: + app: {{ .Values.prometheusExporter.name }} +spec: + type: {{ .Values.prometheusExporter.service.type }} + selector: + app: {{ .Values.prometheusExporter.name }} + ports: + - name: metrics + port: {{ .Values.prometheusExporter.service.port }} + targetPort: http +{{- end }} \ No newline at end of file diff --git a/charts/kor/templates/servicemonitor.yaml b/charts/kor/templates/servicemonitor.yaml new file mode 100644 index 00000000..28247bf3 --- /dev/null +++ b/charts/kor/templates/servicemonitor.yaml @@ -0,0 +1,44 @@ +{{- if and ( .Capabilities.APIVersions.Has "monitoring.coreos.com/v1" ) ( .Values.prometheusExporter.serviceMonitor.enabled ) }} +apiVersion: monitoring.coreos.com/v1 +kind: ServiceMonitor +metadata: + labels: + app: {{ .Values.prometheusExporter.name }} + name: {{ .Values.prometheusExporter.name }} +{{- if .Values.prometheusExporter.serviceMonitor.namespace }} + namespace: {{ .Values.prometheusExporter.serviceMonitor.namespace }} +{{- end }} +spec: + endpoints: + - targetPort: 8080 +{{- if .Values.prometheusExporter.serviceMonitor.interval }} + interval: {{ .Values.prometheusExporter.serviceMonitor.interval }} +{{- end }} +{{- if .Values.prometheusExporter.serviceMonitor.telemetryPath }} + path: {{ .Values.prometheusExporter.serviceMonitor.telemetryPath }} +{{- end }} +{{- if .Values.prometheusExporter.serviceMonitor.timeout }} + scrapeTimeout: {{ .Values.prometheusExporter.serviceMonitor.timeout }} +{{- end }} +{{- if .Values.prometheusExporter.serviceMonitor.metricRelabelings }} + metricRelabelings: +{{ toYaml .Values.prometheusExporter.serviceMonitor.metricRelabelings | indent 4 }} +{{- end }} +{{- if .Values.prometheusExporter.serviceMonitor.relabelings }} + relabelings: +{{ toYaml .Values.prometheusExporter.serviceMonitor.relabelings | indent 4 }} +{{- end }} + jobLabel: {{ .Values.prometheusExporter.name }} + namespaceSelector: + matchNames: + - {{ .Release.Namespace }} + selector: + matchLabels: + app: {{ .Values.prometheusExporter.name }} +{{- if .Values.prometheusExporter.serviceMonitor.targetLabels }} + targetLabels: +{{- range .Values.prometheusExporter.serviceMonitor.targetLabels }} + - {{ . }} +{{- end }} +{{- end }} +{{- end }} diff --git a/charts/kor/values.yaml b/charts/kor/values.yaml index d3077b22..771638db 100644 --- a/charts/kor/values.yaml +++ b/charts/kor/values.yaml @@ -1,5 +1,5 @@ cronJob: - enabled: true + enabled: false name: kor schedule: "0 1 * * 1" image: @@ -14,6 +14,61 @@ cronJob: successfulJobsHistoryLimit: 3 failedJobsHistoryLimit: 2 +prometheusExporter: + enabled: true + name: kor-exporter + # time in minutes, default is 10 minutes + exporterInterval: "" + deployment: + image: + repository: yonahdissen/kor + tag: latest + command: kor exporter + restartPolicy: Always + imagePullPolicy: Always + imagePullSecrets: [] + podSecurityContext: {} + replicaCount: 1 + resources: {} + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + + securityContext: {} + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + + nodeSelector: {} + tolerations: [] + affinity: {} + + service: + type: ClusterIP + port: 8080 + + serviceMonitor: + enabled: true + # Set the namespace the ServiceMonitor should be deployed, if empty namespace will be .Release.Namespace + namespace: "" + # Service monitor labels + labels: {} + # Set how frequently Prometheus should scrape + interval: 30s + telemetryPath: /metrics + # Set timeout for scrape + timeout: 10s + relabelings: [] + # Set of labels to transfer on the Kubernetes Service onto the target. + targetLabels: [] + metricRelabelings: [] + serviceAccount: # Specifies whether a service account should be created create: true