diff --git a/helm/templates/service_metrics.yaml b/helm/templates/service_metrics.yaml deleted file mode 100644 index 046043b..0000000 --- a/helm/templates/service_metrics.yaml +++ /dev/null @@ -1,18 +0,0 @@ -{{- if .Values.deploy -}} -apiVersion: v1 -kind: Service -metadata: - name: {{ include "poolboy.name" . }}-metrics - namespace: {{ include "poolboy.namespaceName" . }} - labels: - {{- include "poolboy.labels" . | nindent 4 }} -spec: - type: {{ .Values.serviceMetrics.type }} - {{- with .Values.serviceMetrics.ports }} - ports: - {{- toYaml . | nindent 2 }} - {{- end }} - selector: - {{- include "poolboy.selectorLabels" . | nindent 4 }} - sessionAffinity: None -{{- end -}} diff --git a/helm/templates/service_monitor.yaml b/helm/templates/service_monitor.yaml index 914de9f..8914658 100644 --- a/helm/templates/service_monitor.yaml +++ b/helm/templates/service_monitor.yaml @@ -1,3 +1,4 @@ +{{- if .Values.serviceMonitor.create }} apiVersion: monitoring.coreos.com/v1 kind: ServiceMonitor metadata: @@ -7,12 +8,15 @@ metadata: {{- include "poolboy.labels" . | nindent 4 }} spec: endpoints: - - interval: 30s - path: /metrics - port: {{ .Values.serviceMetrics.name}} + - interval: {{ .Values.serviceMonitor.interval }} + path: {{ .Values.serviceMonitor.path }} + port: {{ .Values.serviceMonitor.portName }} + scrapeTimeout: {{ .Values.serviceMonitor.scrapeTimeout }} + jobLabel: {{ include "poolboy.name" . }} namespaceSelector: matchNames: - {{ include "poolboy.namespaceName" . }} selector: matchLabels: - app.kubernetes.io/name: {{ include "poolboy.name" . }} + {{- include "poolboy.selectorLabels" . | nindent 6 }} +{{- end }} diff --git a/helm/values.yaml b/helm/values.yaml index 8ab51ff..a4ce1f0 100644 --- a/helm/values.yaml +++ b/helm/values.yaml @@ -51,27 +51,31 @@ serviceAccount: # If not set and create is true, a name is generated using the fullname template name: +serviceMonitor: + # ServiceMonitor requires prometheus-operator installed in the cluster + create: true + # The port name of the service monitor to use. + portName: metrics + # The path to scrape metrics from + path: /metrics + # How often Prometheus should scrape + interval: 30s + # How long Prometheus should wait for a scrape to complete + scrapeTimeout: 15s + service: type: ClusterIP port: 8080 ports: - - name: health-check + - name: healthz port: 8080 protocol: TCP targetPort: 8080 - -serviceMetrics: - type: ClusterIP - port: 80 - name: metrics - ports: - name: metrics port: 80 protocol: TCP targetPort: 8000 - path: /metrics - - + resources: {} # We usually recommend not to specify default resources and to leave this as a conscious # choice for the user. This also increases chances charts run on environments with little