Skip to content

Commit

Permalink
Add service and servicemonitor objects. Add port to connector to depl…
Browse files Browse the repository at this point in the history
…oyment
  • Loading branch information
qoeveleie21 committed Nov 13, 2024
1 parent a4065f9 commit f39e186
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 0 deletions.
6 changes: 6 additions & 0 deletions charts/opencti/templates/connector/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@ spec:
{{- toYaml .securityContext | nindent 12 }}
image: "{{- if and .image (hasKey .image "repository") }}{{ .image.repository }}{{- else if $.Values.global.imageRegistry }}{{ printf "%s/opencti/%s" $.Values.global.imageRegistry .name }}{{- else }}{{ printf "opencti/%s" .name }}{{- end }}:{{ if and .image (hasKey .image "tag") }}{{ .image.tag | default $.Chart.AppVersion }}{{ else }}{{ $.Chart.AppVersion }}{{ end }}"
imagePullPolicy: {{ if and .image (hasKey .image "pullPolicy") }}{{ .image.pullPolicy }}{{ else }}IfNotPresent{{ end }}
ports:
{{- if ((.serviceMonitor).enabled) }}
- name: metrics
containerPort: {{ .env.CONNECTOR_METRICS_PORT | default 9095 }}
protocol: TCP
{{- end }}
lifecycle:
{{- with .lifecycle }}
{{- toYaml . | nindent 12 }}
Expand Down
28 changes: 28 additions & 0 deletions charts/opencti/templates/connector/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{{- $connectorsGlobal := .Values.connectorsGlobal }}
{{- $serviceType := .Values.service.type }}

{{- range .Values.connectors }}
{{- $connectorName := .name }}
{{- if and .enabled .env.CONNECTOR_EXPOSE_METRICS }}
---
apiVersion: v1
kind: Service
metadata:
name: {{ $connectorName }}-service-{{ include "opencti.fullname" $ }}
labels:
opencti.connector: {{ $connectorName }}
{{- include "opencti.labels" $ | nindent 4 }}
spec:
type: {{ $serviceType }}
ports:
{{- if .env.CONNECTOR_EXPOSE_METRICS }}
- name: metrics
port: {{ .env.CONNECTOR_METRICS_PORT | default 9095 }}
targetPort: {{ .env.CONNECTOR_METRICS_PORT | default 9095 }}
protocol: TCP
{{- end }}
selector:
opencti.connector: {{ $connectorName }}
{{- include "opencti.selectorLabels" $ | nindent 4 }}
{{- end }}
{{- end }}
32 changes: 32 additions & 0 deletions charts/opencti/templates/connector/servicemonitor.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{{- $connectorsGlobal := .Values.connectorsGlobal }}
{{- range .Values.connectors }}
{{- $connectorName := .name }}

{{- if and ((.serviceMonitor).enabled) .env.CONNECTOR_EXPOSE_METRICS }}
---
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: {{ $connectorName }}
labels:
opencti.connector: {{ $connectorName }}
{{- include "opencti.labels" $ | nindent 4 }}
spec:
selector:
matchLabels:
opencti.connector: {{ $connectorName }}
{{- include "opencti.selectorLabels" $ | nindent 6 }}
endpoints:
- port: metrics
interval: {{ default "30s" .serviceMonitor.interval | quote }}
scrapeTimeout: {{ default "10s" .serviceMonitor.scrapeTimeout | quote }}
{{- if .serviceMonitor.metricRelabelings }}
metricRelabelings:
{{- toYaml .serviceMonitor.metricRelabelings | nindent 4 }}
{{- end }}
{{- if .serviceMonitor.relabelings }}
relabelings:
{{- toYaml .serviceMonitor.relabelings | nindent 4 }}
{{- end }}
{{- end -}}
{{- end }}

0 comments on commit f39e186

Please sign in to comment.