Files
charts/bitnami/milvus/templates/_helpers.tpl
Miguel Ruiz 85a66a22d5 [bitnami/milvus] Update Kafka subchart 24.0.0 (#18186)
* [bitnami/milvus] Update Kafka subchart 24.0.0

Signed-off-by: Miguel Ruiz <miruiz@vmware.com>

* Update README.md with readme-generator-for-helm

Signed-off-by: Bitnami Containers <bitnami-bot@vmware.com>

* Update references to .Values.kafka and refactor externalKafka parameters

Signed-off-by: Miguel Ruiz <miruiz@vmware.com>

* Update README.md with readme-generator-for-helm

Signed-off-by: Bitnami Containers <bitnami-bot@vmware.com>

* Update value description

Signed-off-by: Miguel Ruiz <miruiz@vmware.com>

* Update README.md with readme-generator-for-helm

Signed-off-by: Bitnami Containers <bitnami-bot@vmware.com>

* Fix kafka headless service

Signed-off-by: Miguel Ruiz <miruiz@vmware.com>

* Update Kafka chart to latest

Signed-off-by: Miguel Ruiz <miruiz@vmware.com>

* Update values.yaml

Signed-off-by: Miguel Ruiz <miruiz@vmware.com>

* Update README.md with readme-generator-for-helm

Signed-off-by: Bitnami Containers <bitnami-bot@vmware.com>

* Update deps

Signed-off-by: Miguel Ruiz <miruiz@vmware.com>

* Update README.md

Signed-off-by: Miguel Ruiz <miruiz@vmware.com>

---------

Signed-off-by: Miguel Ruiz <miruiz@vmware.com>
Signed-off-by: Bitnami Containers <bitnami-bot@vmware.com>
Co-authored-by: Bitnami Containers <bitnami-bot@vmware.com>
2023-08-07 13:42:21 +02:00

1064 lines
33 KiB
Smarty

{{/*
Copyright VMware, Inc.
SPDX-License-Identifier: APACHE-2.0
*/}}
{{/*
Return the proper Milvus image name
*/}}
{{- define "milvus.image" -}}
{{- include "common.images.image" (dict "imageRoot" .Values.milvus.image "global" .Values.global) -}}
{{- end -}}
{{/*
Return the proper Attu image name
*/}}
{{- define "milvus.attu.image" -}}
{{- include "common.images.image" (dict "imageRoot" .Values.attu.image "global" .Values.global) -}}
{{- end -}}
{{/*
Return the proper Init job image name
*/}}
{{- define "milvus.init-job.image" -}}
{{- include "common.images.image" (dict "imageRoot" .Values.initJob.image "global" .Values.global) -}}
{{- end -}}
{{/*
Return the proper Wait container image name
*/}}
{{- define "milvus.wait-container.image" -}}
{{- include "common.images.image" (dict "imageRoot" .Values.waitContainer.image "global" .Values.global) -}}
{{- end -}}
{{/*
Return the proper Milvus Data Coordinator fullname
*/}}
{{- define "milvus.data-coordinator.fullname" -}}
{{- printf "%s-%s" (include "common.names.fullname" .) "data-coordinator" | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{/*
Name of the Milvus Data Coordinator service account to use
*/}}
{{- define "milvus.data-coordinator.serviceAccountName" -}}
{{- if .Values.dataCoord.serviceAccount.create -}}
{{ default (printf "%s" (include "milvus.data-coordinator.fullname" .)) .Values.dataCoord.serviceAccount.name }}
{{- else -}}
{{ default "default" .Values.dataCoord.serviceAccount.name }}
{{- end -}}
{{- end -}}
{{/*
Get the configuration configmap for Milvus Data Coordinator
*/}}
{{- define "milvus.data-coordinator.configmapName" -}}
{{- if .Values.dataCoord.existingConfigMap -}}
{{- .Values.dataCoord.existingConfigMap -}}
{{- else }}
{{- include "milvus.data-coordinator.fullname" . -}}
{{- end -}}
{{- end -}}
{{/*
Get the extra configuration configmap for Milvus Data Coordinator
*/}}
{{- define "milvus.data-coordinator.extraConfigmapName" -}}
{{- if .Values.dataCoord.extraConfigExistingConfigMap -}}
{{- include "common.tplvalues.render" (dict "value" .Value.dataCoord.extraConfigExistingConfigMap "context" $) -}}
{{- else -}}
{{- printf "%s-extra" (include "milvus.data-coordinator.fullname" .) -}}
{{- end -}}
{{- end -}}
{{/*
Return the proper Milvus Index Coordinator fullname
*/}}
{{- define "milvus.index-coordinator.fullname" -}}
{{- printf "%s-%s" (include "common.names.fullname" .) "index-coordinator" | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{/*
Name of the Milvus Index Coordinator service account to use
*/}}
{{- define "milvus.index-coordinator.serviceAccountName" -}}
{{- if .Values.indexCoord.serviceAccount.create -}}
{{ default (printf "%s" (include "milvus.index-coordinator.fullname" .)) .Values.indexCoord.serviceAccount.name }}
{{- else -}}
{{ default "default" .Values.indexCoord.serviceAccount.name }}
{{- end -}}
{{- end -}}
{{/*
Get the extra configuration configmap for Milvus Index Coordinator
*/}}
{{- define "milvus.index-coordinator.configmapName" -}}
{{- if .Values.indexCoord.existingConfigMap -}}
{{- .Values.indexCoord.existingConfigMap -}}
{{- else }}
{{- include "milvus.index-coordinator.fullname" . -}}
{{- end -}}
{{- end -}}
{{/*
Get the extra configuration configmap for Milvus Index Coordinator
*/}}
{{- define "milvus.index-coordinator.extraConfigmapName" -}}
{{- if .Values.indexCoord.extraConfigExistingConfigMap -}}
{{- include "common.tplvalues.render" (dict "value" .Value.indexCoord.extraConfigExistingConfigMap "context" $) -}}
{{- else -}}
{{- printf "%s-extra" (include "milvus.index-coordinator.fullname" .) -}}
{{- end -}}
{{- end -}}
{{/*
Return the proper Milvus Query Coordinator fullname
*/}}
{{- define "milvus.query-coordinator.fullname" -}}
{{- printf "%s-%s" (include "common.names.fullname" .) "query-coordinator" | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{/*
Name of the Milvus Query Coordinator service account to use
*/}}
{{- define "milvus.query-coordinator.serviceAccountName" -}}
{{- if .Values.queryCoord.serviceAccount.create -}}
{{ default (printf "%s" (include "milvus.query-coordinator.fullname" .)) .Values.queryCoord.serviceAccount.name }}
{{- else -}}
{{ default "default" .Values.queryCoord.serviceAccount.name }}
{{- end -}}
{{- end -}}
{{/*
Get the configuration configmap for Milvus Query Coordinator
*/}}
{{- define "milvus.query-coordinator.configmapName" -}}
{{- if .Values.queryCoord.existingConfigMap -}}
{{- .Values.queryCoord.existingConfigMap -}}
{{- else }}
{{- include "milvus.query-coordinator.fullname" . -}}
{{- end -}}
{{- end -}}
{{/*
Get the extra configuration configmap for Milvus Query Coordinator
*/}}
{{- define "milvus.query-coordinator.extraConfigmapName" -}}
{{- if .Values.queryCoord.extraConfigExistingConfigMap -}}
{{- include "common.tplvalues.render" (dict "value" .Value.queryCoord.extraConfigExistingConfigMap "context" $) -}}
{{- else -}}
{{- printf "%s-extra" (include "milvus.query-coordinator.fullname" .) -}}
{{- end -}}
{{- end -}}
{{/*
Return the proper Milvus Root Coordinator fullname
*/}}
{{- define "milvus.root-coordinator.fullname" -}}
{{- printf "%s-%s" (include "common.names.fullname" .) "root-coordinator" | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{/*
Name of the Milvus Root Coordinator service account to use
*/}}
{{- define "milvus.root-coordinator.serviceAccountName" -}}
{{- if .Values.rootCoord.serviceAccount.create -}}
{{- default (printf "%s" (include "milvus.root-coordinator.fullname" .)) .Values.rootCoord.serviceAccount.name -}}
{{- else -}}
{{- default "default" .Values.rootCoord.serviceAccount.name -}}
{{- end -}}
{{- end -}}
{{/*
Get the extra configuration configmap for Milvus Root Coordinator
*/}}
{{- define "milvus.root-coordinator.configmapName" -}}
{{- if .Values.rootCoord.existingConfigMap -}}
{{- .Values.rootCoord.existingConfigMap -}}
{{- else }}
{{- include "milvus.root-coordinator.fullname" . -}}
{{- end -}}
{{- end -}}
{{/*
Get the extra configuration configmap for Milvus Root Coordinator
*/}}
{{- define "milvus.root-coordinator.extraConfigmapName" -}}
{{- if .Values.rootCoord.extraConfigExistingConfigMap -}}
{{- include "common.tplvalues.render" (dict "value" .Value.rootCoord.extraConfigExistingConfigMap "context" $) -}}
{{- else -}}
{{- printf "%s-extra" (include "milvus.root-coordinator.fullname" .) -}}
{{- end -}}
{{- end -}}
{{/*
Return the proper Milvus Data Node fullname
*/}}
{{- define "milvus.data-node.fullname" -}}
{{- printf "%s-%s" (include "common.names.fullname" .) "data-node" | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{/*
Name of the Milvus Data Node service account to use
*/}}
{{- define "milvus.data-node.serviceAccountName" -}}
{{- if .Values.dataNode.serviceAccount.create -}}
{{ default (printf "%s" (include "milvus.data-node.fullname" .)) .Values.dataNode.serviceAccount.name }}
{{- else -}}
{{ default "default" .Values.dataNode.serviceAccount.name }}
{{- end -}}
{{- end -}}
{{/*
Get the configuration configmap for Milvus Data Node
*/}}
{{- define "milvus.data-node.configmapName" -}}
{{- if .Values.dataNode.existingConfigMap -}}
{{- .Values.dataNode.existingConfigMap -}}
{{- else }}
{{- include "milvus.data-node.fullname" . -}}
{{- end -}}
{{- end -}}
{{/*
Get the extra configuration configmap for Milvus Data Node
*/}}
{{- define "milvus.data-node.extraConfigmapName" -}}
{{- if .Values.dataNode.extraConfigExistingConfigMap -}}
{{- include "common.tplvalues.render" (dict "value" .Value.dataNode.extraConfigExistingConfigMap "context" $) -}}
{{- else -}}
{{- printf "%s-extra" (include "milvus.data-node.fullname" .) -}}
{{- end -}}
{{- end -}}
{{/*
Return the proper Milvus Index node fullname
*/}}
{{- define "milvus.index-node.fullname" -}}
{{- printf "%s-%s" (include "common.names.fullname" .) "index-node" | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{/*
Name of the Milvus Index Node service account to use
*/}}
{{- define "milvus.index-node.serviceAccountName" -}}
{{- if .Values.indexNode.serviceAccount.create -}}
{{ default (printf "%s" (include "milvus.index-node.fullname" .)) .Values.indexNode.serviceAccount.name }}
{{- else -}}
{{ default "default" .Values.indexNode.serviceAccount.name }}
{{- end -}}
{{- end -}}
{{/*
Get the configuration configmap for Milvus Index Node
*/}}
{{- define "milvus.index-node.configmapName" -}}
{{- if .Values.indexNode.existingConfigMap -}}
{{- .Values.indexNode.existingConfigMap -}}
{{- else }}
{{- include "milvus.index-node.fullname" . -}}
{{- end -}}
{{- end -}}
{{/*
Get the extra configuration configmap for Milvus Index Node
*/}}
{{- define "milvus.index-node.extraConfigmapName" -}}
{{- if .Values.indexNode.extraConfigExistingConfigMap -}}
{{- include "common.tplvalues.render" (dict "value" .Value.indexNode.extraConfigExistingConfigMap "context" $) -}}
{{- else -}}
{{- printf "%s-extra" (include "milvus.index-node.fullname" .) -}}
{{- end -}}
{{- end -}}
{{/*
Return the proper Milvus Query Node fullname
*/}}
{{- define "milvus.query-node.fullname" -}}
{{- printf "%s-%s" (include "common.names.fullname" .) "query-node" | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{/*
Name of the Milvus Query Node service account to use
*/}}
{{- define "milvus.query-node.serviceAccountName" -}}
{{- if .Values.queryNode.serviceAccount.create -}}
{{- default (printf "%s" (include "milvus.query-node.fullname" .)) .Values.queryNode.serviceAccount.name -}}
{{- else -}}
{{- default "default" .Values.queryNode.serviceAccount.name -}}
{{- end -}}
{{- end -}}
{{/*
Get the configuration configmap for Milvus Query Node
*/}}
{{- define "milvus.query-node.configmapName" -}}
{{- if .Values.queryNode.existingConfigMap -}}
{{- .Values.queryNode.existingConfigMap -}}
{{- else }}
{{- include "milvus.query-node.fullname" . -}}
{{- end -}}
{{- end -}}
{{/*
Get the extra configuration configmap for Milvus Query Node
*/}}
{{- define "milvus.query-node.extraConfigmapName" -}}
{{- if .Values.queryNode.extraConfigExistingConfigMap -}}
{{- include "common.tplvalues.render" (dict "value" .Value.queryNode.extraConfigExistingConfigMap "context" $) -}}
{{- else -}}
{{- printf "%s-extra" (include "milvus.query-node.fullname" .) -}}
{{- end -}}
{{- end -}}
{{/*
Return the proper Milvus Proxy fullname
*/}}
{{- define "milvus.proxy.fullname" -}}
{{- printf "%s-%s" (include "common.names.fullname" .) "proxy" | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{/*
Name of the Milvus Proxy service account to use
*/}}
{{- define "milvus.proxy.serviceAccountName" -}}
{{- if .Values.proxy.serviceAccount.create -}}
{{ default (printf "%s" (include "milvus.proxy.fullname" .)) .Values.proxy.serviceAccount.name }}
{{- else -}}
{{ default "default" .Values.proxy.serviceAccount.name }}
{{- end -}}
{{- end -}}
{{/*
Get the configuration configmap for Milvus Proxy
*/}}
{{- define "milvus.proxy.configmapName" -}}
{{- if .Values.proxy.existingConfigMap -}}
{{- .Values.proxy.existingConfigMap -}}
{{- else }}
{{- include "milvus.proxy.fullname" . -}}
{{- end -}}
{{- end -}}
{{/*
Get the extra configuration configmap for Milvus Proxy
*/}}
{{- define "milvus.proxy.extraConfigmapName" -}}
{{- if .Values.proxy.extraConfigExistingConfigMap -}}
{{- include "common.tplvalues.render" (dict "value" .Value.proxy.extraConfigExistingConfigMap "context" $) -}}
{{- else -}}
{{- printf "%s-extra" (include "milvus.proxy.fullname" .) -}}
{{- end -}}
{{- end -}}
{{/*
Return the proper Attu fullname
*/}}
{{- define "milvus.attu.fullname" -}}
{{- printf "%s-%s" (include "common.names.fullname" .) "attu" | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{/*
Name of the Attu service account to use
*/}}
{{- define "milvus.attu.serviceAccountName" -}}
{{- if .Values.attu.serviceAccount.create -}}
{{ default (printf "%s" (include "milvus.attu.fullname" .)) .Values.attu.serviceAccount.name }}
{{- else -}}
{{ default "default" .Values.attu.serviceAccount.name }}
{{- end -}}
{{- end -}}
{{/*
Return the proper Docker Image Registry Secret Names
*/}}
{{- define "milvus.imagePullSecrets" -}}
{{- include "common.images.pullSecrets" (dict "images" (list .Values.milvus.image .Values.waitContainer.image) "global" .Values.global) -}}
{{- end -}}
{{/*
Get the credentials secret
*/}}
{{- define "milvus.secretName" -}}
{{- if .Values.milvus.auth.existingSecret -}}
{{- include "common.tplvalues.render" (dict "value" .Values.milvus.auth.existingSecret "context" $) -}}
{{- else }}
{{- include "common.names.fullname" . -}}
{{- end -}}
{{- end -}}
{{/*
Get the secret password key
*/}}
{{- define "milvus.secretPasswordKey" -}}
{{- if and .Values.milvus.auth.existingSecret .Values.milvus.auth.existingSecretPasswordKey -}}
{{- print .Values.milvus.auth.existingSecretPasswordKey -}}
{{- else }}
{{- print "password" -}}
{{- end -}}
{{- end -}}
{{/*
Get the secret password key
*/}}
{{- define "milvus.secretRootPasswordKey" -}}
{{- if and .Values.milvus.auth.existingSecret .Values.milvus.auth.existingSecretPasswordKey -}}
{{- print .Values.milvus.auth.existingSecretPasswordKey -}}
{{- else }}
{{- print "root-password" -}}
{{- end -}}
{{- end -}}
{{/*
Get the common configuration configmap.
*/}}
{{- define "milvus.configmapName" -}}
{{- if .Values.milvus.existingConfigMap -}}
{{- include "common.tplvalues.render" (dict "value" .Values.milvus.existingConfigMap "context" $) -}}
{{- else }}
{{- include "common.names.fullname" . -}}
{{- end -}}
{{- end -}}
{{/*
Get the common extra configuration configmap.
*/}}
{{- define "milvus.extraConfigmapName" -}}
{{- if .Values.milvus.extraConfigExistingConfigMap -}}
{{- include "common.tplvalues.render" (dict "value" .Value.milvus.extraConfigExistingConfigMap "context" $) -}}
{{- else -}}
{{- printf "%s-extra" (include "common.names.fullname" .) -}}
{{- end -}}
{{- end -}}
{{/*
Create a default fully qualified app name for etcd
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
*/}}
{{- define "milvus.etcd.fullname" -}}
{{- include "common.names.dependency.fullname" (dict "chartName" "etcd" "chartValues" .Values.etcd "context" $) -}}
{{- end -}}
{{/*
Return etcd port
*/}}
{{- define "milvus.etcd.port" -}}
{{- if .Values.etcd.enabled -}}
{{/* We are using the headless service so we need to use the container port */}}
{{- print .Values.etcd.containerPorts.client -}}
{{- else -}}
{{- print .Values.externalEtcd.port -}}
{{- end -}}
{{- end -}}
{{/*
Return the etcd headless service name
*/}}
{{- define "milvus.etcd.headlessServiceName" -}}
{{- printf "%s-headless" (include "milvus.etcd.fullname" .) -}}
{{- end -}}
{{/*
Create a default fully qualified app name for kafka
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
*/}}
{{- define "milvus.kafka.fullname" -}}
{{- include "common.names.dependency.fullname" (dict "chartName" "kafka" "chartValues" .Values.kafka "context" $) -}}
{{- end -}}
{{/*
Return true if Kafka is used by Milvus
*/}}
{{- define "milvus.kafka.deployed" -}}
{{- if or .Values.kafka.enabled .Values.externalKafka.servers -}}
{{- true -}}
{{- end -}}
{{- end -}}
{{/*
Return kafka port
*/}}
{{- define "milvus.kafka.port" -}}
{{- if .Values.kafka.enabled -}}
{{- print .Values.kafka.service.ports.client -}}
{{- else -}}
{{- print .Values.externalKafka.port -}}
{{- end -}}
{{- end -}}
{{/*
Return the kafka broker-only nodes headless service name
*/}}
{{- define "milvus.kafka.broker.headlessServiceName" -}}
{{- printf "%s-broker-headless" (include "milvus.kafka.fullname" .) -}}
{{- end -}}
{{/*
Return the kafka controller-eligible nodes headless service name
*/}}
{{- define "milvus.kafka.controller.headlessServiceName" -}}
{{- printf "%s-controller-headless" (include "milvus.kafka.fullname" .) -}}
{{- end -}}
{{/*
Return true if kafka authentication is enabled
*/}}
{{- define "milvus.kafka.authEnabled" -}}
{{- $protocol := include "milvus.kafka.securityProtocol" . -}}
{{- if contains "SASL" $protocol -}}
{{- true -}}
{{- end -}}
{{- end -}}
{{/*
Return Kafka authentication SASL mechanisms
*/}}
{{- define "milvus.kafka.saslMechanisms" -}}
{{- if .Values.kafka.enabled -}}
{{- print (upper .Values.kafka.sasl.enabledMechanisms) -}}
{{- else -}}
{{- print (upper .Values.externalKafka.sasl.enabledMechanisms) -}}
{{- end -}}
{{- end -}}
{{/*
Return Kafka security protocol
*/}}
{{- define "milvus.kafka.securityProtocol" -}}
{{- if .Values.kafka.enabled -}}
{{- print (upper .Values.kafka.listeners.client.protocol) -}}
{{- else -}}
{{- print (upper .Values.externalKafka.listener.protocol) -}}
{{- end -}}
{{- end -}}
{{/*
Return kafka credential secret name
*/}}
{{- define "milvus.kafka.secretName" -}}
{{- if .Values.kafka.enabled -}}
{{- printf "%s-user-passwords" (include "milvus.kafka.fullname" .) -}}
{{- else if .Values.externalKafka.sasl.existingSecret -}}
{{- print .Values.externalKafka.sasl.existingSecret -}}
{{- else -}}
{{- printf "%s-external-kafka" (include "common.names.fullname" .) | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- end -}}
{{/*
Return kafka secret password key
*/}}
{{- define "milvus.kafka.secretPasswordKey" -}}
{{- if .Values.kafka.enabled -}}
{{- print "system-user-password" -}}
{{- else -}}
{{- print .Values.externalKafka.sasl.existingSecretPasswordKey -}}
{{- end -}}
{{- end -}}
{{/*
Return kafka username
*/}}
{{- define "milvus.kafka.user" -}}
{{- if .Values.kafka.enabled -}}
{{- print (index .Values.kafka.sasl.client.users 0) -}}
{{- else -}}
{{- print .Values.externalKafka.sasl.user -}}
{{- end -}}
{{- end -}}
{{/*
Return MinIO(TM) fullname
*/}}
{{- define "milvus.minio.fullname" -}}
{{- include "common.names.dependency.fullname" (dict "chartName" "minio" "chartValues" .Values.minio "context" $) -}}
{{- end -}}
{{/*
Return the S3 backend host
*/}}
{{- define "milvus.s3.host" -}}
{{- if .Values.minio.enabled -}}
{{- include "milvus.minio.fullname" . -}}
{{- else -}}
{{- print .Values.externalS3.host -}}
{{- end -}}
{{- end -}}
{{/*
Return the S3 bucket
*/}}
{{- define "milvus.s3.bucket" -}}
{{- if .Values.minio.enabled -}}
{{- print .Values.minio.defaultBuckets -}}
{{- else -}}
{{- print .Values.externalS3.bucket -}}
{{- end -}}
{{- end -}}
{{/*
Return the S3 protocol
*/}}
{{- define "milvus.s3.protocol" -}}
{{- if .Values.minio.enabled -}}
{{- ternary "https" "http" .Values.minio.tls.enabled -}}
{{- else -}}
{{- print .Values.externalS3.protocol -}}
{{- end -}}
{{- end -}}
{{/*
Return the S3 root path
*/}}
{{- define "milvus.s3.rootPath" -}}
{{- if .Values.minio.enabled -}}
{{- print "file" -}}
{{- else -}}
{{- print .Values.externalS3.rootPath -}}
{{- end -}}
{{- end -}}
{{/*
Return true if IAM is used (this is for cloud providers)
*/}}
{{- define "milvus.s3.useIAM" -}}
{{- if .Values.minio.enabled -}}
{{- print "false" -}}
{{- else -}}
{{- print .Values.externalS3.useIAM -}}
{{- end -}}
{{- end -}}
{{/*
Return true if TLS is used
*/}}
{{- define "milvus.s3.useSSL" -}}
{{- if .Values.minio.enabled -}}
{{- .Values.minio.tls.enabled -}}
{{- else if (eq .Values.externalS3.protocol "https") -}}
{{- print "true" -}}
{{- else -}}
{{- print "false" -}}
{{- end -}}
{{- end -}}
{{/*
Return the S3 port
*/}}
{{- define "milvus.s3.port" -}}
{{- ternary .Values.minio.service.ports.api .Values.externalS3.port .Values.minio.enabled -}}
{{- end -}}
{{/*
Return the S3 credentials secret name
*/}}
{{- define "milvus.s3.secretName" -}}
{{- if .Values.minio.enabled -}}
{{- if .Values.minio.auth.existingSecret -}}
{{- print .Values.minio.auth.existingSecret -}}
{{- else -}}
{{- print (include "milvus.minio.fullname" .) -}}
{{- end -}}
{{- else if .Values.externalS3.existingSecret -}}
{{- print .Values.externalS3.existingSecret -}}
{{- else -}}
{{- printf "%s-%s" (include "common.names.fullname" .) "externals3" -}}
{{- end -}}
{{- end -}}
{{/*
Return the S3 access key id inside the secret
*/}}
{{- define "milvus.s3.accessKeyIDKey" -}}
{{- if .Values.minio.enabled -}}
{{- print "root-user" -}}
{{- else -}}
{{- print .Values.externalS3.existingSecretAccessKeyIDKey -}}
{{- end -}}
{{- end -}}
{{/*
Return the S3 secret access key inside the secret
*/}}
{{- define "milvus.s3.secretAccessKeyKey" -}}
{{- if .Values.minio.enabled -}}
{{- print "root-password" -}}
{{- else -}}
{{- print .Values.externalS3.existingSecretKeySecretKey -}}
{{- end -}}
{{- end -}}
{{/*
Return the S3 secret access key inside the secret
*/}}
{{- define "milvus.s3.deployed" -}}
{{- if or .Values.minio.enabled .Values.externalS3.host -}}
{{- true -}}
{{- end -}}
{{- end -}}
{{/*
Init container definition for waiting for the database to be ready
*/}}
{{- define "milvus.waitForETCDInitContainer" -}}
- name: wait-for-etcd
image: {{ template "milvus.wait-container.image" . }}
imagePullPolicy: {{ .Values.waitContainer.image.pullPolicy }}
{{- if .Values.waitContainer.containerSecurityContext.enabled }}
securityContext: {{- omit .Values.waitContainer.containerSecurityContext "enabled" | toYaml | nindent 4 }}
{{- end }}
command:
- bash
- -ec
- |
#!/bin/bash
retry_while() {
local -r cmd="${1:?cmd is missing}"
local -r retries="${2:-12}"
local -r sleep_time="${3:-5}"
local return_value=1
read -r -a command <<< "$cmd"
for ((i = 1 ; i <= retries ; i+=1 )); do
"${command[@]}" && return_value=0 && break
sleep "$sleep_time"
done
return $return_value
}
etcd_hosts=(
{{- if .Values.etcd.enabled }}
"{{ ternary "https" "http" $.Values.etcd.auth.client.secureTransport }}://{{ printf "%s:%v" (include "milvus.etcd.fullname" $ ) (include "milvus.etcd.port" $ ) }}"
{{- else }}
{{- range $node :=.Values.externalEtcd.servers }}
"{{ ternary "https" "http" $.Values.externalEtcd.secureTransport }}://{{ printf "%s:%v" $node (include "milvus.etcd.port" $) }}"
{{- end }}
{{- end }}
)
check_etcd() {
local -r etcd_host="${1:-?missing etcd}"
if curl --max-time 5 "${etcd_host}/version" | grep etcdcluster; then
return 0
else
return 1
fi
}
for host in "${etcd_hosts[@]}"; do
echo "Checking connection to $host"
if retry_while "check_etcd $host"; then
echo "Connected to $host"
else
echo "Error connecting to $host"
exit 1
fi
done
echo "Connection success"
exit 0
{{- end -}}
{{/*
Init container definition for waiting for the database to be ready
*/}}
{{- define "milvus.waitForS3InitContainer" -}}
- name: wait-for-s3
image: {{ template "milvus.wait-container.image" . }}
imagePullPolicy: {{ .Values.waitContainer.image.pullPolicy }}
{{- if .Values.waitContainer.containerSecurityContext.enabled }}
securityContext: {{- omit .Values.waitContainer.containerSecurityContext "enabled" | toYaml | nindent 4 }}
{{- end }}
command:
- bash
- -ec
- |
#!/bin/bash
retry_while() {
local -r cmd="${1:?cmd is missing}"
local -r retries="${2:-12}"
local -r sleep_time="${3:-5}"
local return_value=1
read -r -a command <<< "$cmd"
for ((i = 1 ; i <= retries ; i+=1 )); do
"${command[@]}" && return_value=0 && break
sleep "$sleep_time"
done
return $return_value
}
check_s3() {
local -r s3_host="${1:-?missing s3}"
if curl --max-time 5 "${s3_host}" | grep "RequestId"; then
return 0
else
return 1
fi
}
host={{ include "milvus.s3.host" . | quote }}
echo "Checking connection to $host"
if retry_while "check_s3 $host"; then
echo "Connected to $host"
else
echo "Error connecting to $host"
exit 1
fi
echo "Connection success"
exit 0
{{- end -}}
{{/*
Init container definition for waiting for the database to be ready
*/}}
{{- define "milvus.waitForKafkaInitContainer" -}}
- name: wait-for-kafka
image: {{ template "milvus.image" . }} {{/* Bitnami shell does not have wait-for-port */}}
imagePullPolicy: {{ .Values.waitContainer.image.pullPolicy }}
{{- if .Values.waitContainer.containerSecurityContext.enabled }}
securityContext: {{- omit .Values.waitContainer.containerSecurityContext "enabled" | toYaml | nindent 4 }}
{{- end }}
command:
- bash
- -ec
- |
#!/bin/bash
retry_while() {
local -r cmd="${1:?cmd is missing}"
local -r retries="${2:-12}"
local -r sleep_time="${3:-5}"
local return_value=1
read -r -a command <<< "$cmd"
for ((i = 1 ; i <= retries ; i+=1 )); do
"${command[@]}" && return_value=0 && break
sleep "$sleep_time"
done
return $return_value
}
kafka_hosts=(
{{- if .Values.kafka.enabled }}
{{ include "milvus.kafka.fullname" . | quote }}
{{- else }}
{{- range $node :=.Values.externalKafka.servers }}
{{ print $node | quote }}
{{- end }}
{{- end }}
)
check_kafka() {
local -r kafka_host="${1:-?missing kafka}"
if wait-for-port --timeout=5 --host=${kafka_host} --state=inuse {{ include "milvus.kafka.port" . }}; then
return 0
else
return 1
fi
}
for host in "${kafka_hosts[@]}"; do
echo "Checking connection to $host"
if retry_while "check_kafka $host"; then
echo "Connected to $host"
else
echo "Error connecting to $host"
exit 1
fi
done
echo "Connection success"
exit 0
{{- end -}}
{{/*
Init container definition for waiting for the database to be ready
*/}}
{{- define "milvus.waitForProxyInitContainer" -}}
- name: wait-for-proxy
image: {{ template "milvus.image" . }} {{/* Bitnami shell does not have wait-for-port */}}
imagePullPolicy: {{ .Values.waitContainer.image.pullPolicy }}
{{- if .Values.waitContainer.containerSecurityContext.enabled }}
securityContext: {{- omit .Values.waitContainer.containerSecurityContext "enabled" | toYaml | nindent 4 }}
{{- end }}
command:
- bash
- -ec
- |
#!/bin/bash
retry_while() {
local -r cmd="${1:?cmd is missing}"
local -r retries="${2:-12}"
local -r sleep_time="${3:-5}"
local return_value=1
read -r -a command <<< "$cmd"
for ((i = 1 ; i <= retries ; i+=1 )); do
"${command[@]}" && return_value=0 && break
sleep "$sleep_time"
done
return $return_value
}
check_proxy() {
local -r proxy_host="${1:-?missing proxy}"
if wait-for-port --timeout=5 --host=${proxy_host} --state=inuse {{ .Values.proxy.service.ports.grpc }}; then
return 0
else
return 1
fi
}
host={{ include "milvus.proxy.fullname" . | quote }}
echo "Checking connection to $host"
if retry_while "check_proxy $host"; then
echo "Connected to $host"
else
echo "Error connecting to $host"
exit 1
fi
echo "Connection success"
exit 0
{{- end -}}
{{/*
Init container definition for waiting for the database to be ready
*/}}
{{- define "milvus.prepareMilvusInitContainer" -}}
# This init container renders and merges the Milvus configuration files.
# We need to use a volume because we're working with ReadOnlyRootFilesystem
- name: prepare-milvus
image: {{ template "milvus.image" .context }}
imagePullPolicy: {{ .context.Values.milvus.image.pullPolicy }}
{{- $block := index .context.Values .component }}
{{- if $block.containerSecurityContext.enabled }}
securityContext: {{- omit $block.containerSecurityContext "enabled" | toYaml | nindent 4 }}
{{- end }}
command:
- bash
- -ec
- |
#!/bin/bash
# Build final milvus.yaml with the sections of the different files
find /bitnami/milvus/conf -type f -name *.yaml -print0 | sort -z | xargs -0 yq eval-all '. as $item ireduce ({}; . * $item )' /opt/bitnami/milvus/configs/milvus.yaml > /bitnami/milvus/rendered-conf/pre-render-config_00.yaml
{{- if (include "milvus.kafka.deployed" .context) }}
# HACK: In order to enable Kafka we need to remove all Pulsar settings from the configuration file
# https://github.com/milvus-io/milvus/blob/master/configs/milvus.yaml#L110
yq 'del(.pulsar)' /bitnami/milvus/rendered-conf/pre-render-config_00.yaml > /bitnami/milvus/rendered-conf/pre-render-config_01.yaml
{{- end }}
render-template /bitnami/milvus/rendered-conf/pre-render-config_01.yaml > /bitnami/milvus/rendered-conf/milvus.yaml
rm /bitnami/milvus/rendered-conf/pre-render-config*
chmod 644 /bitnami/milvus/rendered-conf/milvus.yaml
env:
- name: BITNAMI_DEBUG
value: {{ ternary "true" "false" (or .context.Values.milvus.image.debug .context.Values.diagnosticMode.enabled) | quote }}
{{- if and (include "milvus.kafka.deployed" .context) (include "milvus.kafka.authEnabled" .context) }}
- name: MILVUS_KAFKA_PASSWORD
valueFrom:
secretKeyRef:
name: {{ include "milvus.kafka.secretName" .context }}
key: {{ include "milvus.kafka.secretPasswordKey" .context }}
{{- end }}
{{- if and (include "milvus.s3.deployed" .context) }}
- name: MILVUS_S3_ACCESS_ID
valueFrom:
secretKeyRef:
name: {{ include "milvus.s3.secretName" .context }}
key: {{ include "milvus.s3.accessKeyIDKey" .context }}
- name: MILVUS_S3_SECRET_ACCESS_KEY
valueFrom:
secretKeyRef:
name: {{ include "milvus.s3.secretName" .context }}
key: {{ include "milvus.s3.secretAccessKeyKey" .context }}
{{- end }}
{{- if $block.extraEnvVars }}
{{- include "common.tplvalues.render" (dict "value" $block.extraEnvVars "context" $) | nindent 4 }}
{{- end }}
envFrom:
{{- if $block.extraEnvVarsCM }}
- configMapRef:
name: {{ include "common.tplvalues.render" (dict "value" $block.extraEnvVarsCM "context" .context) }}
{{- end }}
{{- if $block.extraEnvVarsSecret }}
- secretRef:
name: {{ include "common.tplvalues.render" (dict "value" $block.extraEnvVarsSecret "context" $) }}
{{- end }}
volumeMounts:
- name: config-common
mountPath: /bitnami/milvus/conf/00_default
{{- if or .context.Values.milvus.extraConfig .context.Values.milvus.extraConfigExistingConfigMap }}
- name: extra-config-common
mountPath: /bitnami/milvus/conf/01_extra_common
{{- end }}
- name: component-config-default
mountPath: /bitnami/milvus/conf/02_component_default
{{- if or $block.extraConfig $block.extraConfigExistingConfigMap }}
- name: component-extra-config
mountPath: /bitnami/milvus/conf/03_extra
{{- end }}
- name: tmp
mountPath: /tmp
- name: rendered-config
mountPath: /bitnami/milvus/rendered-conf/
{{- end -}}
{{/*
Return true if the init job should be created
*/}}
{{- define "milvus.init-job.create" -}}
{{- if or (and .Values.milvus.auth.enabled .Release.IsInstall) .Values.initJob.forceRun -}}
{{- true -}}
{{- else -}}
{{/* Do not return anything */}}
{{- end -}}
{{- end -}}
{{/*
Check if there are rolling tags in the images
*/}}
{{- define "milvus.checkRollingTags" -}}
{{- include "common.warnings.rollingTag" .Values.milvus.image }}
{{- include "common.warnings.rollingTag" .Values.attu.image }}
{{- include "common.warnings.rollingTag" .Values.initJob.image }}
{{- end -}}
{{/*
Compile all warnings into a single message.
*/}}
{{- define "milvus.validateValues" -}}
{{- $messages := list -}}
{{- $messages := append $messages (include "milvus.validateValues.controllers" .) -}}
{{- $messages := append $messages (include "milvus.validateValues.attu" .) -}}
{{- $messages := without $messages "" -}}
{{- $message := join "\n" $messages -}}
{{- if $message -}}
{{- printf "\nVALUES VALIDATION:\n%s" $message -}}
{{- end -}}
{{- end -}}
{{/*
Function to validate the controller deployment
*/}}
{{- define "milvus.validateValues.controllers" -}}
{{- if not (or .Values.dataCoord.enabled .Values.rootCoord.enabled .Values.indexCoord.enabled .Values.queryCoord.enabled .Values.dataNode.enabled .Values.queryNode.enabled .Values.indexNode.enabled) -}}
milvus: Missing controllers. At least one controller should be enabled.
{{- end -}}
{{- end -}}
{{/*
Function to validate the controller deployment
*/}}
{{- define "milvus.validateValues.attu" -}}
{{- if and .Values.attu.enabled (not .Values.proxy.enabled) -}}
attu: Attu requires the Milvus proxy to be enabled
{{- end -}}
{{- end -}}