Skip to content

Commit

Permalink
added metric-exporter
Browse files Browse the repository at this point in the history
  • Loading branch information
rkrmr33 committed Mar 17, 2024
1 parent b3dfa6d commit f8d4d65
Show file tree
Hide file tree
Showing 8 changed files with 338 additions and 11 deletions.
15 changes: 15 additions & 0 deletions charts/ocean-kubernetes-controller/templates/auto-update/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,19 @@ rules:
resourceNames: [ {{ include "ocean-network-client.fullname" . }} ]
verbs: [ "get", "patch" ]
{{- end }}

# Metric Exporter requires
{{- if index .Values "ocean-metric-exporter" "deployChart" -}}
{{- $values := index .Values "ocean-metric-exporter" }}
{{- if $values.service.create }}
- apiGroups: [ "" ]
resources: [ "services" ]
resourceNames: [ {{ include "ocean-metric-exporter.fullname" . }} ]
verbs: [ "get", "patch" ]
{{- end }}
- apiGroups: [ "apps" ]
resources: [ "deployments" ]
resourceNames: [ {{ include "ocean-metric-exporter.fullname" . }} ]
verbs: [ "get", "patch" ]
{{- end }}
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ metadata:
data:
spotinst.cluster-identifier: {{ required "`spotinst.clusterIdentifier` must be specified" .Values.spotinst.clusterIdentifier }}
base-url: {{ default "" .Values.spotinst.baseUrl | quote }}
http-base-url: {{ default "" .Values.spotinst.httpBaseUrl | quote }}
proxy-url: {{ default "" .Values.spotinst.proxyUrl | quote }}
leader-election: {{ gt (int .Values.replicas) 1 | quote }}
disable-auto-update: {{ default "false" .Values.spotinst.disableAutoUpdate | quote }}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "ocean-metric-exporter.name" -}}
{{- $values := (index .Values "ocean-metric-exporter") -}}
{{- default "ocean-metric-exporter" $values.name | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "ocean-metric-exporter.fullname" -}}
{{- $values := (index .Values "ocean-metric-exporter") -}}
{{- if $values.fullnameOverride }}
{{- $values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default (include "ocean-metric-exporter.name" .) $values.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "ocean-metric-exporter.labels" -}}
helm.sh/chart: {{ include "ocean-kubernetes-controller.chart" . }}
{{ include "ocean-metric-exporter.selectorLabels" . }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "ocean-metric-exporter.selectorLabels" -}}
app.kubernetes.io/name: {{ include "ocean-metric-exporter.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Container command.
*/}}
{{- define "ocean-metric-exporter.command" -}}
{{- printf "[ \"java\", \"-Dspring.profiles.active=prod,default\", \"-jar\", \"/app/app.jar\" ]" -}}
{{- end }}

{{/*
probes.
*/}}
{{- define "ocean-metric-exporter.probes" -}}
{{- $values := index .Values "ocean-metric-exporter" }}
{{- if or $values.probes.liveness.enabled $values.probes.enabled }}
livenessProbe:
httpGet:
path: /health/liveness
port: exporter
initialDelaySeconds: {{ $values.probes.liveness.initialDelaySeconds }}
periodSeconds: {{ $values.probes.liveness.periodSeconds }}
failureThreshold: {{ $values.probes.liveness.failureThreshold }}
timeoutSeconds: {{ $values.probes.liveness.timeoutSeconds }}
{{- end}}
{{- if or $values.probes.readiness.enabled $values.probes.enabled }}
readinessProbe:
httpGet:
path: /health/readiness
port: exporter
initialDelaySeconds: {{ $values.probes.readiness.initialDelaySeconds }}
periodSeconds: {{ $values.probes.readiness.periodSeconds }}
failureThreshold: {{ $values.probes.readiness.failureThreshold }}
successThreshold: {{ $values.probes.readiness.successThreshold }}
timeoutSeconds: {{ $values.probes.readiness.timeoutSeconds }}
{{- end}}
{{- end }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
{{- if index .Values "ocean-metric-exporter" "deployChart" -}}
{{- $values := index .Values "ocean-metric-exporter" }}
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "ocean-metric-exporter.fullname" . }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "ocean-metric-exporter.labels" . | nindent 4 }}
spec:
replicas: {{ $values.replicaCount }}
selector:
matchLabels:
{{- include "ocean-metric-exporter.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with $values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "ocean-metric-exporter.selectorLabels" . | nindent 8 }}
spec:
{{- with $values.image.pullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
containers:
- name: spot-ocean-metric-exporter
ports:
- containerPort: 5050
name: exporter
env:
- name: SPOTINST_TOKEN
valueFrom:
secretKeyRef:
name: {{ include "ocean-kubernetes-controller.secretName" . }}
key: token
optional: true
- name: SPOTINST_TOKEN_LEGACY
valueFrom:
configMapKeyRef:
name: {{ include "ocean-kubernetes-controller.configMapName" . }}
key: spotinst.token
optional: true
- name: SPOTINST_ACCOUNT
valueFrom:
secretKeyRef:
name: {{ include "ocean-kubernetes-controller.secretName" . }}
key: account
optional: true
- name: SPOTINST_ACCOUNT_LEGACY
valueFrom:
configMapKeyRef:
name: {{ include "ocean-kubernetes-controller.configMapName" . }}
key: spotinst.account
optional: true
- name: CLUSTER_IDENTIFIER
valueFrom:
configMapKeyRef:
name: {{ include "ocean-kubernetes-controller.configMapName" . }}
key: spotinst.cluster-identifier
- name: BASE_SPOTINST_URL
valueFrom:
configMapKeyRef:
name: {{ include "ocean-kubernetes-controller.configMapName" . }}
key: http-base-url
optional: true
- name: PROXY_URL
valueFrom:
configMapKeyRef:
name: {{ include "ocean-kubernetes-controller.configMapName" . }}
key: proxy-url
optional: true
- name: USER_ENV_CERTIFICATES
valueFrom:
secretKeyRef:
name: {{ include "ocean-kubernetes-controller.caBundleSecretName" . }}
key: {{ .Values.caBundleSecret.key }}
optional: true
{{- with $values.podEnvVariables }}
{{- toYaml . | nindent 8 }}
{{- end }}
image: {{ $values.image.repository }}:{{ $values.image.tag | default .Chart.AppVersion }}
imagePullPolicy: {{ $values.image.pullPolicy }}
command: {{ include "ocean-metric-exporter.command" . }}
args:
- --categories={{ join "," $values.metricsConfiguration.categories }}
- --allow-metrics={{ join "," $values.metricsConfiguration.allowMetrics }}
- --deny-metrics={{ join "," $values.metricsConfiguration.denyMetrics }}
- --allow-labels={{ join "," $values.metricsConfiguration.allowLabels }}
- --deny-labels={{ join "," $values.metricsConfiguration.denyLabels }}
resources:
{{- toYaml $values.resources | nindent 12 }}
{{- include "ocean-metric-exporter.probes" . | nindent 8 }}
{{- with $values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with $values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with $values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{{- if index .Values "ocean-metric-exporter" "deployChart" -}}
{{- $values := index .Values "ocean-metric-exporter" }}
{{- if $values.service.create }}
apiVersion: v1
kind: Service
metadata:
name: {{ include "ocean-metric-exporter.fullname" . }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "ocean-metric-exporter.labels" . | nindent 4 }}
spec:
ports:
- name: exporter
port: 5050
protocol: TCP
targetPort: exporter
selector:
{{- include "ocean-metric-exporter.selectorLabels" . | nindent 4 }}
sessionAffinity: None
type: ClusterIP
{{- end }}
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,12 @@ If release name contains chart name it will be used as a full name.
{{- end }}
{{- end }}

{{/*
DaemonSet labels.
*/}}
{{- define "ocean-network-client.daemon-set.labels" -}}
app: ocean-network-client
{{- end }}

{{/*
Common labels
*/}}
{{- define "ocean-network-client.labels" -}}
helm.sh/chart: {{ include "ocean-kubernetes-controller.chart" . }}
{{ include "ocean-network-client.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{- if index .Values "ocean-network-client" "deployChart" -}}
{{ $values := index .Values "ocean-network-client" }}
{{- $values := index .Values "ocean-network-client" }}
apiVersion: apps/v1
kind: DaemonSet
metadata:
Expand Down
113 changes: 113 additions & 0 deletions charts/ocean-kubernetes-controller/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ spotinst:
clusterIdentifier: ""
# -- Base URL. (Optional)
baseUrl: ""
# -- HTTP Base URL. (Optional)
httpBaseUrl: ""
# -- Proxy URL. (Optional)
proxyUrl: ""
# -- Disable auto update. (Optional)
Expand Down Expand Up @@ -268,3 +270,114 @@ ocean-network-client:
# Ref: https://kubernetes.io/docs/concepts/scheduling-eviction/taint-and-toleration/
tolerations:
- operator: "Exists"

# -- Configurations for Ocean Metric Exporter.
ocean-metric-exporter:
# -- Specifies whether the Ocean Metric Exporter should be deployed. (Optional)
deployChart: true

# -- (Optional) Replicas.
# Ref: https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#replicas
replicaCount: 1

# Image.
# Ref: https://kubernetes.io/docs/concepts/containers/images/
image:
# -- (Optional) Image repository.
repository: gcr.io/spotinst-artifacts/spot-ocean-metric-exporter
# -- (Optional) Image pull policy.
pullPolicy: IfNotPresent
# -- (Optional) Image pull secrets.
pullSecrets: []
# -- (Optional) Image tag. Defaults to `.Chart.AppVersion`.
tag: "1.0.4"

# -- (Optional) Pod annotations.
# Ref: https://kubernetes.io/docs/concepts/overview/working-with-objects/annotations/
podAnnotations: {}

# -- (Optional) Additional environment variables for the exporter container.
podEnvVariables: []
# - name: envName
# value: envValue

# -- (Optional) Resource requests and limits.
# Ref: http://kubernetes.io/docs/user-guide/compute-resources/
resources:
limits:
cpu: 500m
memory: 500Mi
requests:
cpu: 100m
memory: 50Mi

# -- (Optional) Node selector.
nodeSelector: {}

# -- (Optional) Tolerations for nodes that have taints on them.
# Ref: https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/
tolerations:
- key: node-role.kubernetes.io/master
operator: Exists
- key: node-role.kubernetes.io/control-plane
operator: Exists

# -- (Optional) Pod scheduling preferences.
# Ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity
affinity: {}

# Service.
service:
# -- (Optional) Controls whether a service should be created.
create: true

# Probes configuration
probes:
# -- (Bool) Whether to include both liveness and readiness probe, if this is set to true it will ignore the nested enabled booleans.
enabled: true

# Liveness probe configuration.
liveness:
# -- (Bool) Whether to include liveness probe, this will be ignored if probes.enabled was set to true.
enabled: false
# -- (Integer) Liveness probe initial delay.
initialDelaySeconds: 15
# -- (Integer) Liveness probe period.
periodSeconds: 10
# -- (Integer) Liveness probe failure threshold.
failureThreshold: 3
# -- (Integer) Liveness probe timeout.
timeoutSeconds: 1

# Readiness probe configuration.
readiness:
# -- (Bool) Whether to include readiness probe, this will be ignored if probes.enabled was set to true.
enabled: false
# -- (Integer) Readiness probe initial delay.
initialDelaySeconds: 15
# -- (Integer) Readiness probe period.
periodSeconds: 10
# -- (Integer) Readiness probe failure threshold.
failureThreshold: 3
# -- (Integer) Readiness probe success threshold.
successThreshold: 1
# -- (Integer) Readiness probe timeout.
timeoutSeconds: 1

# -- (Optional) Exporter Metrics Configurations
metricsConfiguration:
# -- (Array[string]) List of Categories to enable - if empty will get no metrics. Additional possible values can be found here: https://docs.spot.io/ocean/tools-and-integrations/prometheus/scrape?id=categories
categories:
- scaling

# -- (Array[string]) List of Metrics to allow - if empty will get everything. Shouldn't be used with `denyMetrics`. Possible values can be found here: https://docs.spot.io/ocean/tools-and-integrations/prometheus/scrape?id=metrics
allowMetrics:

# -- (Array[string]) List of Metrics to deny - if empty will get everything. Shouldn't be used with `allowMetrics`. Possible values can be found here: https://docs.spot.io/ocean/tools-and-integrations/prometheus/scrape?id=metrics
denyMetrics:

# -- (Array[string]) List of Labels to allow - if empty will get everything. Shouldn't be used with `denyLabels`. Possible values can be found here: https://docs.spot.io/ocean/tools-and-integrations/prometheus/scrape?id=labels
allowLabels:

# -- (Array[string]) List of Labels to deny - if empty will get everything. Shouldn't be used with `allowLabels`. Possible values can be found here: https://docs.spot.io/ocean/tools-and-integrations/prometheus/scrape?id=labels
denyLabels:

0 comments on commit f8d4d65

Please sign in to comment.