-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MLRun] Alerts deployment and service (#1041)
- Loading branch information
Showing
10 changed files
with
350 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,205 @@ | ||
{{ if .Values.api.microservices.enabled}} | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: {{ include "mlrun.api.microservices.alerts.fullname" . }} | ||
labels: | ||
{{- include "mlrun.api.microservices.alerts.labels" . | nindent 4 }} | ||
spec: | ||
replicas: {{ .Values.api.microservices.alerts.minReplicas }} | ||
strategy: | ||
type: Recreate | ||
selector: | ||
matchLabels: | ||
{{- include "mlrun.api.microservices.alerts.selectorLabels" . | nindent 6 }} | ||
template: | ||
metadata: | ||
labels: | ||
{{- include "mlrun.api.microservices.alerts.selectorLabels" . | nindent 8 }} | ||
annotations: | ||
kubectl.kubernetes.io/default-container: {{ template "mlrun.name" . }}-{{ .Values.api.name }} | ||
spec: | ||
{{- with .Values.api.image.pullSecrets }} | ||
imagePullSecrets: | ||
{{- toYaml . | nindent 8 }} | ||
{{- end }} | ||
{{- if .Values.serviceAccounts.serviceAccountName}} | ||
serviceAccountName: {{ .Values.serviceAccounts.serviceAccountName }} | ||
{{- else }} | ||
serviceAccountName: {{ include "mlrun.serviceAccountName.api" . }} | ||
{{- end }} | ||
securityContext: | ||
{{- toYaml .Values.api.podSecurityContext | nindent 8 }} | ||
{{- if .Values.api.extraInitContainers }} | ||
initContainers: | ||
{{- toYaml .Values.api.extraInitContainers | nindent 8 }} | ||
{{- end }} | ||
containers: | ||
- name: {{ template "mlrun.name" . }}-{{ .Values.api.name }} | ||
securityContext: | ||
{{- toYaml .Values.api.securityContext | nindent 12 }} | ||
image: "{{ .Values.api.image.repository }}:{{ .Values.api.image.tag }}" | ||
imagePullPolicy: {{ .Values.api.image.pullPolicy }} | ||
ports: | ||
- name: http | ||
containerPort: 8080 | ||
protocol: TCP | ||
env: | ||
- name: MLRUN_NAMESPACE | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: metadata.namespace | ||
- name: MLRUN_SERVICES__SERVICE_NAME | ||
value: alerts | ||
- name: MLRUN_HTTPDB__CLUSTERIZATION__ROLE | ||
value: "worker" | ||
- name: MLRUN_LOG_LEVEL | ||
value: {{ .Values.api.logLevel }} | ||
- name: MLRUN_HTTPDB__DB_TYPE | ||
{{- if or (eq .Values.httpDB.dbType "mysql") (eq .Values.httpDB.dbType "sqlite") }} | ||
value: "sqldb" | ||
{{- else }} | ||
value: "filedb" | ||
{{- end }} | ||
- name: MLRUN_HTTPDB__API_URL | ||
value: http://{{ include "mlrun.api.fullname" . }}:{{ .Values.api.service.port }} | ||
- name: MLRUN_HTTPDB__DIRPATH | ||
value: {{ .Values.httpDB.dirPath }} | ||
- name: MLRUN_HTTPDB__BUILDER__DOCKER_REGISTRY | ||
value: {{ template "mlrun.defaultDockerRegistry.url" . }} | ||
{{- if or .Values.defaultDockerRegistrySecretName .Values.global.registry.secretName }} | ||
- name: MLRUN_HTTPDB__BUILDER__DOCKER_REGISTRY_SECRET | ||
value: {{ template "mlrun.defaultDockerRegistry.builderSecretName" . }} | ||
{{- end }} | ||
{{- if or .Values.api.function.spec.image_pull_secret.default .Values.global.registry.secretName }} | ||
- name: MLRUN_FUNCTION__SPEC__IMAGE_PULL_SECRET__DEFAULT | ||
value: {{ template "mlrun.defaultDockerRegistry.imagePullSecretName" . }} | ||
{{- end }} | ||
- name: MLRUN_HTTPDB__DSN | ||
value: {{ .Values.httpDB.dsn }} | ||
- name: MLRUN_HTTPDB__OLD_DSN | ||
value: {{ .Values.httpDB.oldDsn }} | ||
{{- if .Values.v3io.enabled }} | ||
- name: V3IO_ACCESS_KEY | ||
valueFrom: | ||
secretKeyRef: | ||
name: {{ .Release.Name }}-v3io-fuse | ||
key: accessKey | ||
- name: V3IO_USERNAME | ||
valueFrom: | ||
secretKeyRef: | ||
name: {{ .Release.Name }}-v3io-fuse | ||
key: username | ||
{{- end }} | ||
- name: MLRUN_NUCLIO_MODE | ||
value: {{ .Values.nuclio.mode }} | ||
{{- if eq .Values.nuclio.mode "enabled" }} | ||
- name: MLRUN_NUCLIO_DASHBOARD_URL | ||
value: {{ template "mlrun.nuclio.apiURL" . }} | ||
{{- end }} | ||
{{- if .Values.api.extraEnv }} | ||
{{- range .Values.api.extraEnv }} | ||
{{- if not (hasKey $.Values.api.extraEnvKeyValue .name) }} | ||
- name: {{ .name }} | ||
value: {{ .value }} | ||
{{- end }} | ||
{{- end }} | ||
{{- end }} | ||
{{- if .Values.api.extraEnvKeyValue }} | ||
{{- range $name, $value := .Values.api.extraEnvKeyValue }} | ||
- name: {{ $name }} | ||
value: {{ $value | quote }} | ||
{{- end }} | ||
{{- end }} | ||
{{- if .Values.api.envFrom }} | ||
envFrom: | ||
{{ toYaml .Values.api.envFrom | nindent 10 }} | ||
{{- end }} | ||
{{- if .Values.api.microservices.alerts.livenessProbe }} | ||
livenessProbe: | ||
{{ toYaml .Values.api.microservices.alerts.livenessProbe | nindent 12 }} | ||
{{- end }} | ||
{{- if .Values.api.microservices.alerts.readinessProbe }} | ||
readinessProbe: | ||
{{ toYaml .Values.api.microservices.alerts.readinessProbe | nindent 12 }} | ||
{{- end }} | ||
resources: | ||
{{- toYaml .Values.api.resources | nindent 12 }} | ||
volumeMounts: | ||
{{- range .Values.api.extraPersistentVolumeMounts }} | ||
- name: {{ .name }} | ||
mountPath: {{ .mountPath }} | ||
subPath: {{ .subPath | default "" }} | ||
readOnly: {{ .readOnly }} | ||
{{- end }} | ||
{{- if .Values.api.opa.enabled }} | ||
- name: {{ template "mlrun.name" . }}-{{ .Values.api.opa.name }} | ||
securityContext: | ||
{{- toYaml .Values.api.opa.securityContext | nindent 12 }} | ||
image: "{{ .Values.api.opa.image.repository }}:{{ .Values.api.opa.image.tag }}" | ||
imagePullPolicy: {{ .Values.api.opa.image.pullPolicy }} | ||
ports: | ||
- name: http | ||
containerPort: 8181 | ||
{{- if .Values.api.opa.livenessProbe }} | ||
livenessProbe: | ||
{{ toYaml .Values.api.opa.livenessProbe | nindent 12 }} | ||
{{- end }} | ||
{{- if .Values.api.opa.readinessProbe }} | ||
readinessProbe: | ||
{{ toYaml .Values.api.opa.readinessProbe | nindent 12 }} | ||
{{- end }} | ||
resources: | ||
{{- toYaml .Values.api.opa.resources | nindent 12 }} | ||
args: | ||
- "run" | ||
- "--server" | ||
- "--config-file=/config/config.yaml" | ||
- "--log-level={{ .Values.api.opa.logLevel }}" | ||
- "--log-format={{ .Values.api.opa.logFormat }}" | ||
- "--ignore=.*" | ||
volumeMounts: | ||
- readOnly: true | ||
mountPath: /config | ||
name: config | ||
{{- end }} | ||
volumes: | ||
{{- range .Values.api.extraPersistentVolumeMounts }} | ||
- name: {{ .name }} | ||
persistentVolumeClaim: | ||
claimName: {{ .existingClaim }} | ||
{{- end }} | ||
{{- if .Values.api.opa.enabled }} | ||
- name: config | ||
secret: | ||
secretName: {{ template "mlrun.api.opa.fullname" . }} | ||
{{- end }} | ||
{{- with .Values.api.nodeSelector }} | ||
nodeSelector: | ||
{{- toYaml . | nindent 8 }} | ||
{{- end }} | ||
{{- if .Values.api.microservices.alerts.affinity }} | ||
affinity: | ||
{{- toYaml .Values.api.microservices.alerts.affinity | nindent 8 }} | ||
{{- else if .Values.api.affinity }} | ||
affinity: | ||
{{- toYaml .Values.api.affinity | nindent 8 }} | ||
{{- else }} | ||
affinity: | ||
podAntiAffinity: | ||
preferredDuringSchedulingIgnoredDuringExecution: | ||
- weight: 1 | ||
podAffinityTerm: | ||
labelSelector: | ||
matchLabels: | ||
{{- include "mlrun.api.selectorLabels" . | nindent 20 }} | ||
topologyKey: "kubernetes.io/hostname" | ||
{{- end }} | ||
{{- with .Values.api.tolerations }} | ||
tolerations: | ||
{{- toYaml . | nindent 8 }} | ||
{{- end }} | ||
{{- if .Values.api.priorityClassName }} | ||
priorityClassName: {{ .Values.api.priorityClassName | quote }} | ||
{{- end }} | ||
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
{{ if .Values.api.microservices.enabled}} | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: {{ include "mlrun.api.microservices.alerts.fullname" . }} | ||
spec: | ||
{{- if (or (eq .Values.api.microservices.alerts.service.type "ClusterIP") (empty .Values.api.microservices.alerts.service.type)) }} | ||
type: ClusterIP | ||
{{- if .Values.api.microservices.alerts.service.clusterIP }} | ||
clusterIP: {{ .Values.api.microservices.alerts.service.clusterIP }} | ||
{{end}} | ||
{{- else if eq .Values.api.microservices.alerts.service.type "LoadBalancer" }} | ||
type: {{ .Values.api.microservices.alerts.service.type }} | ||
{{- if .Values.api.microservices.alerts.service.loadBalancerIP }} | ||
loadBalancerIP: {{ .Values.api.microservices.alerts.service.loadBalancerIP }} | ||
{{- end }} | ||
{{- if .Values.api.microservices.alerts.service.loadBalancerSourceRanges }} | ||
loadBalancerSourceRanges: | ||
{{ toYaml .Values.api.microservices.alerts.service.loadBalancerSourceRanges | indent 4 }} | ||
{{- end -}} | ||
{{- else }} | ||
type: {{ .Values.api.microservices.alerts.service.type }} | ||
{{- end }} | ||
{{- if .Values.api.microservices.alerts.service.externalIPs }} | ||
externalIPs: | ||
{{ toYaml .Values.api.microservices.alerts.service.externalIPs | indent 4 }} | ||
{{- end }} | ||
ports: | ||
- name: http | ||
port: {{ .Values.api.microservices.alerts.service.port }} | ||
protocol: TCP | ||
targetPort: http | ||
{{ if (and (eq .Values.api.microservices.alerts.service.type "NodePort") (not (empty .Values.api.microservices.alerts.service.nodePort))) }} | ||
nodePort: {{.Values.api.microservices.alerts.service.nodePort}} | ||
{{ end }} | ||
selector: | ||
{{- include "mlrun.api.microservices.alerts.selectorLabels" . | nindent 4 }} | ||
{{- end -}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.