init
This commit is contained in:
46
vw-document-ai-indexer/deploy/dev/deploy.sh
Normal file
46
vw-document-ai-indexer/deploy/dev/deploy.sh
Normal file
@@ -0,0 +1,46 @@
|
||||
|
||||
# login AKS
|
||||
# az cloud set --name AzureCloud # Switch CLI to Azure cloud
|
||||
# az login # Log in to Azure China account (browser or device code flow)
|
||||
# az account set -s 079d8bd8-b4cc-4892-9307-aa6dedf890e9 #! set subs
|
||||
# az aks get-credentials -g rg-aiflow-lab -n aks-aiflow-lab --overwrite-existing --file ~/.kube/config
|
||||
kubectl config use-context aks-aiflow-lab
|
||||
kubectl config current-context
|
||||
|
||||
# kubectl create secret generic azure-files-cred \
|
||||
# --from-literal=azurestorageaccountname=saaisearchlab \
|
||||
# --from-literal=azurestorageaccountkey=xxxxxxxxxxxxxxxxxxxx \
|
||||
# -n knowledge-agent
|
||||
|
||||
# kubectl delete configmap document-ai-indexer-config -n knowledge-agent
|
||||
|
||||
docker build . -t document-ai-indexer:2.0.2
|
||||
docker tag document-ai-indexer:2.0.2 acraiflowlab.azurecr.io/document-ai-indexer:2.0.2
|
||||
docker push acraiflowlab.azurecr.io/document-ai-indexer:2.0.2
|
||||
|
||||
|
||||
# dev
|
||||
kubectl delete configmap document-ai-indexer-config -n knowledge-agent
|
||||
kubectl create configmap document-ai-indexer-config -n knowledge-agent --from-file=env.yaml --from-file=config.yaml
|
||||
|
||||
# kubectl create namespace knowledge-agent
|
||||
|
||||
# # kubectl delete pod document-ai-indexer -n knowledge-agent
|
||||
# kubectl apply -f document-ai-indexer_k8s.yml -n knowledge-agent
|
||||
|
||||
# kubectl logs -f document-ai-indexer -n knowledge-agent
|
||||
|
||||
# Deploy CronJob
|
||||
kubectl apply -f deploy/dev/document-ai-indexer-cronjob.yml --namespace knowledge-agent
|
||||
|
||||
# Check CronJob Status
|
||||
kubectl get cronjobs -n knowledge-agent --namespace knowledge-agent
|
||||
# Check Job Execution History
|
||||
kubectl get jobs -n knowledge-agent --namespace knowledge-agent
|
||||
|
||||
###########
|
||||
# Manually trigger a job (for testing)
|
||||
kubectl delete job manual-test -n knowledge-agent
|
||||
kubectl create job --from=cronjob/document-ai-indexer-cronjob manual-test -n knowledge-agent
|
||||
# Check Job Logs
|
||||
kubectl logs -f job/manual-test -n knowledge-agent
|
||||
@@ -0,0 +1,64 @@
|
||||
apiVersion: batch/v1
|
||||
kind: CronJob
|
||||
metadata:
|
||||
name: document-ai-indexer-cronjob
|
||||
spec:
|
||||
# Scheduling configuration - execute every 10 minutes
|
||||
schedule: "*/10 * * * *"
|
||||
|
||||
# Concurrency policy: Disable concurrent execution. If the previous job is still running, new execution will be skipped.
|
||||
concurrencyPolicy: Forbid
|
||||
|
||||
# Successful jobs history limit: Keep the last 3 successful job records.
|
||||
successfulJobsHistoryLimit: 10
|
||||
|
||||
# Failed jobs history limit: Keep the last failed job record.
|
||||
failedJobsHistoryLimit: 10
|
||||
|
||||
# Job template
|
||||
jobTemplate:
|
||||
spec:
|
||||
backoffLimit: 0
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: document-ai-indexer
|
||||
job-type: cronjob
|
||||
spec:
|
||||
restartPolicy: Never
|
||||
|
||||
volumes:
|
||||
# 1. ConfigMap volume
|
||||
- name: config-volume
|
||||
configMap:
|
||||
name: document-ai-indexer-config
|
||||
items:
|
||||
- key: env.yaml
|
||||
path: env.yaml
|
||||
- key: config.yaml
|
||||
path: config.yaml
|
||||
|
||||
# 2. Azure File Share volume
|
||||
- name: data-volume
|
||||
azureFile:
|
||||
secretName: azure-files-cred # Quote Secret
|
||||
shareName: fs-document-ai-indexer # Your file share name
|
||||
readOnly: false # Write permission
|
||||
|
||||
containers:
|
||||
- name: document-ai-indexer
|
||||
image: acraiflowlab.azurecr.io/document-ai-indexer:2.0.1
|
||||
imagePullPolicy: Always
|
||||
# Mount the volume into the container
|
||||
volumeMounts:
|
||||
# ConfigMap Mount
|
||||
- name: config-volume
|
||||
mountPath: /app/env.yaml
|
||||
subPath: env.yaml
|
||||
- name: config-volume
|
||||
mountPath: /app/config.yaml
|
||||
subPath: config.yaml
|
||||
|
||||
# Azure File Shared mount
|
||||
- name: data-volume
|
||||
mountPath: /app/run_tmp # Program write/read directory
|
||||
@@ -0,0 +1,42 @@
|
||||
apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
name: document-ai-indexer
|
||||
spec:
|
||||
restartPolicy: Never
|
||||
|
||||
volumes:
|
||||
# 1. 原有的 ConfigMap 卷
|
||||
- name: config-volume
|
||||
configMap:
|
||||
name: document-ai-indexer-config
|
||||
items:
|
||||
- key: env.yaml
|
||||
path: env.yaml
|
||||
- key: config.yaml
|
||||
path: config.yaml
|
||||
|
||||
# 2. Azure File Share 卷
|
||||
- name: data-volume
|
||||
azureFile:
|
||||
secretName: azure-files-cred # 引用你创建的 Secret
|
||||
shareName: fs-document-ai-indexer # 你的文件共享名称
|
||||
readOnly: false # 写权限
|
||||
|
||||
containers:
|
||||
- name: document-ai-indexer
|
||||
image: acraiflowlab.azurecr.io/document-ai-indexer:2.0.1
|
||||
imagePullPolicy: Always
|
||||
# 挂载卷到容器内
|
||||
volumeMounts:
|
||||
# ConfigMap 挂载
|
||||
- name: config-volume
|
||||
mountPath: /app/env.yaml
|
||||
subPath: env.yaml
|
||||
- name: config-volume
|
||||
mountPath: /app/config.yaml
|
||||
subPath: config.yaml
|
||||
|
||||
# Azure File 共享挂载
|
||||
- name: data-volume
|
||||
mountPath: /app/run_tmp # 程序写入/读取目录
|
||||
Reference in New Issue
Block a user