Deploy Milvus
Deployment Preparation
-
Nodes used to run Milvus must first join the Kubernetes cluster, and their status must be
Ready. -
Before deploying Milvus, prepare the following external dependencies:
- Kafka
- etcd
- S3 object storage (MinIO)
-
Create the dedicated Milvus bucket
mdmilvusin S3 object storage (MinIO)Milvus uses object storage to store data files. Create a dedicated bucket for it. The following example uses
mcto connect to MinIO and create themdmilvusbucket:mc alias set minio http://MINIO_ENDPOINT MINIO_ACCESS_KEY MINIO_SECRET_KEYmc mb minio/mdmilvusmc ls minio-
Replace
MINIO_ENDPOINTwith the actual MinIO endpoint, for examplehttp://10.206.0.6:9000. -
Replace
MINIO_ACCESS_KEYandMINIO_SECRET_KEYwith the actual access key and secret key.
-
-
Check Node Status
kubectl get nodes -o wide-
Confirm that the nodes planned to run Milvus have joined the Kubernetes cluster.
-
Confirm that the node status is
Ready.
-
-
Add labels and taints to dedicated Milvus worker nodes
First mark the Kubernetes worker nodes used to run Milvus, and use taints to prevent other business Pods from being scheduled to these nodes by mistake.
kubectl label nodes <milvus-node-name> hap=milvuskubectl taint nodes <milvus-node-name> hap=milvus:NoSchedule-
hap=milvusis the node label used to identify dedicated Milvus worker nodes. -
hap=milvus:NoScheduleis the node taint used to prevent Pods without the corresponding toleration from being scheduled to these nodes. -
Replace
<milvus-node-name>with the actual Milvus worker node name. If there are multiple nodes, add the node label and taint to each node.
-
-
Preload images on dedicated Milvus worker nodes
Before installing
Milvus OperatorandMilvus, prepare the required images on the Kubernetes worker nodes that will run Milvus.- Servers with Internet Access
- Servers without Internet Access
crictl pull registry.cn-hangzhou.aliyuncs.com/mdpublic/mingdaoyun-milvus-operator:v1.3.6crictl pull registry.cn-hangzhou.aliyuncs.com/mdpublic/mingdaoyun-milvus:v2.6.17-
Milvusimage package:-
amd64:https://pdpublic.mingdao.com/private-deployment/offline/common/mingdaoyun-milvus-linux-v2.6.17.tar.gz -
arm64:https://pdpublic.mingdao.com/private-deployment/offline/common/mingdaoyun-milvus-linux-v2.6.17.tar.gz
-
-
Milvus Operatorimage package:-
amd64:https://pdpublic.mingdao.com/private-deployment/offline/common/mingdaoyun-milvus-operator-linux-v1.3.6.tar.gz -
arm64:https://pdpublic.mingdao.com/private-deployment/offline/common/mingdaoyun-milvus-operator-linux-v1.3.6.tar.gz
-
-
The following uses
amd64as an example. Download the image packages, then decompress and import them into the local container runtime:wget https://pdpublic.mingdao.com/private-deployment/offline/common/mingdaoyun-milvus-linux-v2.6.17.tar.gzwget https://pdpublic.mingdao.com/private-deployment/offline/common/mingdaoyun-milvus-operator-linux-v1.3.6.tar.gzgunzip -d mingdaoyun-milvus-linux-v2.6.17.tar.gzgunzip -d mingdaoyun-milvus-operator-linux-v1.3.6.tar.gzctr -n k8s.io image import mingdaoyun-milvus-linux-v2.6.17.tarctr -n k8s.io image import mingdaoyun-milvus-operator-linux-v1.3.6.tar
-
registry.cn-hangzhou.aliyuncs.com/mdpublic/mingdaoyun-milvus-operator:v1.3.6is used to deploy Milvus Operator. -
registry.cn-hangzhou.aliyuncs.com/mdpublic/mingdaoyun-milvus:v2.6.17is used to deploy Milvus cluster workloads.
Deploy Milvus Operator
Deploy Milvus Operator first. The subsequent Milvus custom resource depends on it to create workloads.
For easier maintenance and reuse, store the
yamlfiles used in this section under/data/mingdao/script/kubernetes/milvus/on Kubernetes Master 01. Run download and deployment commands from this directory afterward.
-
Prepare
milvus-operator-deployment.yamlCreate a directory on Kubernetes Master 01 to store the files, and switch to that directory:
mkdir -p /data/mingdao/script/kubernetes/milvuscd /data/mingdao/script/kubernetes/milvusThen download
milvus-operator-deployment.yamlto the current directory.- Servers with Internet Access
- Servers without Internet Access
wget https://pdpublic.mingdao.com/private-deployment/offline/common/milvus-operator-deployment.yaml# Download milvus-operator-deployment.yaml in an Internet-connected environment first, then upload it to the current directory.# Download link:https://pdpublic.mingdao.com/private-deployment/offline/common/milvus-operator-deployment.yaml -
Apply the operator resource
kubectl apply -f milvus-operator-deployment.yaml-
This step deploys the Milvus Operator controller.
-
The subsequent
Milvusresource can be parsed and created only after the operator is running normally.
-
-
Check operator status
kubectl get pod -n milvus-operator -o wide- Confirm that the
Milvus OperatorPod has started normally.
- Confirm that the
Deploy Milvus
The following steps are based on milvus.yaml.
For easier maintenance and reuse, store the
yamlfiles used in this section under/data/mingdao/script/kubernetes/milvus/on Kubernetes Master 01. Run creation and deployment commands from this directory afterward.
-
Create the Milvus namespace
kubectl create namespace milvus- If the namespace already exists, ignore this command.
-
Create the S3 credential Secret
The Milvus storage dependency uses
secretRef: milvus-s3-secret, so create the corresponding Secret in themilvusnamespace first.kubectl -n milvus create secret generic milvus-s3-secret \--from-literal=accessKey='replace-with-s3-access-key' \--from-literal=secretKey='replace-with-s3-secret-key'-
accessKeyis the object storage access key. -
secretKeyis the object storage secret key.
-
-
Prepare
milvus.yamlCreate
milvus.yamlunder/data/mingdao/script/kubernetes/milvus/on Kubernetes Master 01 with the following content:apiVersion: milvus.io/v1beta1kind: Milvusmetadata:name: hap-ragnamespace: milvuslabels:app: milvusspec:mode: clustercomponents:image: registry.cn-hangzhou.aliyuncs.com/mdpublic/mingdaoyun-milvus:v2.6.17imagePullPolicy: IfNotPresentnodeSelector:hap: milvustolerations:- key: "hap"operator: "Equal"value: "milvus"effect: "NoSchedule"proxy:replicas: 2resources:requests:cpu: "250m"memory: "1Gi"limits:cpu: "2"memory: "4Gi"affinity:podAntiAffinity:preferredDuringSchedulingIgnoredDuringExecution:- weight: 100podAffinityTerm:topologyKey: kubernetes.io/hostnamelabelSelector:matchLabels:app.kubernetes.io/component: proxymixCoord:replicas: 2resources:requests:cpu: "250m"memory: "1Gi"limits:cpu: "4"memory: "8Gi"affinity:podAntiAffinity:preferredDuringSchedulingIgnoredDuringExecution:- weight: 100podAffinityTerm:topologyKey: kubernetes.io/hostnamelabelSelector:matchLabels:app.kubernetes.io/component: mixcoordstreamingNode:replicas: 2resources:requests:cpu: "250m"memory: "1Gi"limits:cpu: "6"memory: "12Gi"affinity:podAntiAffinity:preferredDuringSchedulingIgnoredDuringExecution:- weight: 100podAffinityTerm:topologyKey: kubernetes.io/hostnamelabelSelector:matchLabels:app.kubernetes.io/component: streamingnodequeryNode:replicas: 2resources:requests:cpu: "250m"memory: "1Gi"limits:cpu: "8"memory: "32Gi"affinity:podAntiAffinity:preferredDuringSchedulingIgnoredDuringExecution:- weight: 100podAffinityTerm:topologyKey: kubernetes.io/hostnamelabelSelector:matchLabels:app.kubernetes.io/component: querynodedataNode:replicas: 2resources:requests:cpu: "250m"memory: "1Gi"limits:cpu: "6"memory: "12Gi"affinity:podAntiAffinity:preferredDuringSchedulingIgnoredDuringExecution:- weight: 100podAffinityTerm:topologyKey: kubernetes.io/hostnamelabelSelector:matchLabels:app.kubernetes.io/component: datanodedependencies:msgStreamType: kafkakafka:external: truebrokerList: # Modify: Kafka addresses- "192.168.10.31:9092"- "192.168.10.32:9092"- "192.168.10.33:9092"etcd:external: trueendpoints: # Modify: etcd addresses- "http://192.168.10.31:2379"- "http://192.168.10.32:2379"- "http://192.168.10.33:2379"storage:external: truetype: S3endpoint: "cos.ap-nanjing.myqcloud.com:443" # Modify: S3 object storage endpointsecretRef: milvus-s3-secret # Modify: S3 Secret nameconfig:common:security:authorizationEnabled: truedefaultRootPassword: "<set_a_strong_password>" # Modify: set the Milvus root user passwordmixCoord:enableActiveStandby: truemsgChannel:chanNamePrefix:cluster: milvusmq:type: kafkakafka:securityProtocol: PLAINTEXTetcd:rootPath: "milvus"metaSubPath: "meta"kvSubPath: "kv"auth:enabled: trueuserName: "root"password: "******" # Modify: etcd passwordssl:enabled: falseminio:cloudProvider: aws # Fixed: S3 compatiblebucketName: "mdmilvus" # Modify as needed: bucket namerootPath: "milvus"useSSL: true # Modify as needed: whether to access S3 over HTTPSuseVirtualHost: true-
dependencies.kafka.brokerListanddependencies.etcd.endpointsconfigure the externalKafkaandetcdservice addresses. Before deployment, confirm that these addresses are reachable from theMilvusworker nodes. -
dependencies.storageconfigures the externalS3object storage.endpointandsecretRefmust match the actual environment. -
config.common.security.authorizationEnabledenables authentication, anddefaultRootPasswordmust be set to a strong password. -
config.etcd.auth.userNameandconfig.etcd.auth.passwordare used to access the externaletcd. Replace them with the actual authentication information. -
config.minio.bucketNameis currently set tomdmilvus, which specifies the object storage bucket to use. KeeprootPathasmilvus. If the object storage endpoint or access method changes, adjustuseSSLanduseVirtualHostaccordingly.
-
-
Apply the Milvus resource
kubectl apply -f milvus.yaml- This step creates the Milvus cluster for
hap-ragthrough Milvus Operator.
- This step creates the Milvus cluster for
-
Check Milvus Resource Status
kubectl get pods -n milvus -o widekubectl get svc -n milvus- Confirm that each component Pod has been scheduled and is running normally.
- Confirm that the exposed Service has been created.
-
Access Milvus
After deployment, the
Milvusaccess address is as follows:http://hap-rag-milvus.milvus:19530- This address is accessible only from Pods inside the current Kubernetes cluster.
Connect to the HAP Service
Add the following environment variables to config.yaml of the HAP service:
ENV_RAG_ENABLE: "true"
ENV_MILVUS_URL: "http://hap-rag-milvus.milvus:19530"
ENV_MILVUS_DATABASE: "default"
ENV_MILVUS_USERNAME: "root"
ENV_MILVUS_PASSWORD: "your_password"
-
Set
ENV_MILVUS_PASSWORDto the customMilvuspassword configured earlier. -
After saving the configuration, restart the
HAPmicroservices for the changes to take effect.