From 01d33fec90e4dfaa63791f9b14d581eeb1c5598f Mon Sep 17 00:00:00 2001 From: DeepFlow-pengbin <1473371932@qq.com> Date: Wed, 10 Apr 2024 16:28:28 +0800 Subject: [PATCH] add stella chart --- .../charts/stella-agent-ce/Chart.yaml | 3 + .../stella-agent-ce/templates/_affinity.tpl | 41 +++++++++++++ .../templates/_volumeClaimTemplates.tpl | 24 ++++++++ .../templates/stella-agent-ce-configmap.yaml | 8 +++ .../templates/stella-agent-ce-service.yaml | 15 +++++ .../stella-agent-ce-statefulset.yaml | 60 +++++++++++++++++++ .../charts/stella-agent-ce/values.yaml | 52 ++++++++++++++++ charts/deepflow/values.yaml | 55 ++++++++++++++++- 8 files changed, 257 insertions(+), 1 deletion(-) create mode 100644 charts/deepflow/charts/stella-agent-ce/Chart.yaml create mode 100644 charts/deepflow/charts/stella-agent-ce/templates/_affinity.tpl create mode 100644 charts/deepflow/charts/stella-agent-ce/templates/_volumeClaimTemplates.tpl create mode 100644 charts/deepflow/charts/stella-agent-ce/templates/stella-agent-ce-configmap.yaml create mode 100644 charts/deepflow/charts/stella-agent-ce/templates/stella-agent-ce-service.yaml create mode 100644 charts/deepflow/charts/stella-agent-ce/templates/stella-agent-ce-statefulset.yaml create mode 100644 charts/deepflow/charts/stella-agent-ce/values.yaml diff --git a/charts/deepflow/charts/stella-agent-ce/Chart.yaml b/charts/deepflow/charts/stella-agent-ce/Chart.yaml new file mode 100644 index 0000000..2ec66c6 --- /dev/null +++ b/charts/deepflow/charts/stella-agent-ce/Chart.yaml @@ -0,0 +1,3 @@ +apiVersion: v2 +name: stella-agent-ce +version: 0.1.0 diff --git a/charts/deepflow/charts/stella-agent-ce/templates/_affinity.tpl b/charts/deepflow/charts/stella-agent-ce/templates/_affinity.tpl new file mode 100644 index 0000000..76d97c3 --- /dev/null +++ b/charts/deepflow/charts/stella-agent-ce/templates/_affinity.tpl @@ -0,0 +1,41 @@ +{{- define "nodeaffinity" }} + nodeAffinity: + requiredDuringSchedulingIgnoredDuringExecution: + {{- include "nodeAffinityRequiredDuringScheduling" . }} + preferredDuringSchedulingIgnoredDuringExecution: + {{- include "nodeAffinityPreferredDuringScheduling" . }} +{{- end }} + +{{- define "nodeAffinityRequiredDuringScheduling" }} + {{- if or .Values.nodeAffinityLabelSelector .Values.global.nodeAffinityLabelSelector }} + nodeSelectorTerms: + {{- range $matchExpressionsIndex, $matchExpressionsItem := .Values.nodeAffinityLabelSelector }} + - matchExpressions: + {{- range $Index, $item := $matchExpressionsItem.matchExpressions }} + - key: {{ $item.key }} + operator: {{ $item.operator }} + {{- if $item.values }} + values: + {{- $vals := split "," $item.values }} + {{- range $i, $v := $vals }} + - {{ $v | quote }} + {{- end }} + {{- end }} + {{- end }} + {{- end }} + {{- range $matchExpressionsIndex, $matchExpressionsItem := .Values.global.nodeAffinityLabelSelector }} + - matchExpressions: + {{- range $Index, $item := $matchExpressionsItem.matchExpressions }} + - key: {{ $item.key }} + operator: {{ $item.operator }} + {{- if $item.values }} + values: + {{- $vals := split "," $item.values }} + {{- range $i, $v := $vals }} + - {{ $v | quote }} + {{- end }} + {{- end }} + {{- end }} + {{- end }} + {{- end }} +{{- end }} \ No newline at end of file diff --git a/charts/deepflow/charts/stella-agent-ce/templates/_volumeClaimTemplates.tpl b/charts/deepflow/charts/stella-agent-ce/templates/_volumeClaimTemplates.tpl new file mode 100644 index 0000000..82c21a9 --- /dev/null +++ b/charts/deepflow/charts/stella-agent-ce/templates/_volumeClaimTemplates.tpl @@ -0,0 +1,24 @@ +{{- /* PVC templates */ -}} +{{- define "persistentVolumeClaim" -}} +{{- range $index, $volume := .Values.storageConfig.persistence }} +- kind: PersistentVolumeClaim + apiVersion: v1 + metadata: + name: {{ $volume.name }} + annotations: + {{- toYaml $volume.annotations | nindent 8 }} + spec: + accessModes: + {{- toYaml $volume.accessModes | nindent 8 }} + resources: + requests: + storage: {{ $volume.size | quote }} + {{- if (tpl $volume.storageClass $) }} + storageClassName: {{ tpl $volume.storageClass $ | quote }} + {{- end }} + {{- if $volume.selector }} + selector: + {{- toYaml $volume.selector | nindent 8 }} + {{- end }} +{{- end }} +{{- end }} diff --git a/charts/deepflow/charts/stella-agent-ce/templates/stella-agent-ce-configmap.yaml b/charts/deepflow/charts/stella-agent-ce/templates/stella-agent-ce-configmap.yaml new file mode 100644 index 0000000..d39a0ab --- /dev/null +++ b/charts/deepflow/charts/stella-agent-ce/templates/stella-agent-ce-configmap.yaml @@ -0,0 +1,8 @@ +kind: ConfigMap +apiVersion: v1 +metadata: + name: df-llm-agent + namespace: deepflow +data: + df-llm-agent.yaml: |- + {{- toYaml .Values.configMapData | nindent 6 }} diff --git a/charts/deepflow/charts/stella-agent-ce/templates/stella-agent-ce-service.yaml b/charts/deepflow/charts/stella-agent-ce/templates/stella-agent-ce-service.yaml new file mode 100644 index 0000000..5f0e358 --- /dev/null +++ b/charts/deepflow/charts/stella-agent-ce/templates/stella-agent-ce-service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: df-llm-agent + namespace: deepflow +spec: + ports: + - port: 20831 + nodePort: 30831 + targetPort: 20831 + protocol: TCP + name: http + selector: + component: df-llm-agent + type: NodePort diff --git a/charts/deepflow/charts/stella-agent-ce/templates/stella-agent-ce-statefulset.yaml b/charts/deepflow/charts/stella-agent-ce/templates/stella-agent-ce-statefulset.yaml new file mode 100644 index 0000000..7a5af28 --- /dev/null +++ b/charts/deepflow/charts/stella-agent-ce/templates/stella-agent-ce-statefulset.yaml @@ -0,0 +1,60 @@ +{{- if and (not $.Values.global.allInOneLocalStorage ) (eq ( tpl $.Values.storageConfig.generateType . ) "hostPath") (not $.Values.nodeAffinityLabelSelector) }} +{{- fail "You must set nodeAffinityLabelSelector" -}} +{{- end}} +kind: StatefulSet +apiVersion: apps/v1 +metadata: + name: df-llm-agent-deployment + namespace: deepflow + labels: + component: df-llm-agent +spec: + replicas: {{ .Values.replicas }} + serviceName: df-llm-agent + selector: + matchLabels: + component: df-llm-agent + template: + metadata: + labels: + component: df-llm-agent + spec: + hostNetwork: true + dnsPolicy: ClusterFirstWithHostNet + containers: + - name: df-llm-agent + image: "{{ tpl .Values.image.repository . }}:{{ tpl (toString .Values.image.tag) . }}" + imagePullPolicy: {{ tpl .Values.image.pullPolicy . }} + volumeMounts: + - name: debug-path + mountPath: /root/debug + - name: web-volumes-df-llm-agent + mountPath: /etc/web/df-llm-agent.yaml + subPath: df-llm-agent.yaml + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + affinity: + {{- include "nodeaffinity" . | indent 6 }} + {{- include "podAffinity" . | indent 6 }} + {{- include "podAntiAffinity" . | indent 6 }} + {{- if or .Values.global.tolerations .Values.tolerations }} + {{- end }} + volumes: + - name: web-volumes-df-llm-agent + configMap: + name: df-llm-agent + items: + - key: df-llm-agent.yaml + path: df-llm-agent.yaml + {{- if eq ( tpl .Values.storageConfig.generateType . ) "hostPath" }} + - name: debug-path + hostPath: + path: {{ tpl .Values.storageConfig.hostPath . }}/stella-agent-ce/debug/ + type: DirectoryOrCreate + {{- end }} + {{- if eq ( tpl $.Values.storageConfig.generateType . ) "persistentVolumeClaim" }} + volumeClaimTemplates: + {{- include "persistentVolumeClaim" . | indent 2 }} + {{- end }} diff --git a/charts/deepflow/charts/stella-agent-ce/values.yaml b/charts/deepflow/charts/stella-agent-ce/values.yaml new file mode 100644 index 0000000..52fcd0a --- /dev/null +++ b/charts/deepflow/charts/stella-agent-ce/values.yaml @@ -0,0 +1,52 @@ +global: + allInOneLocalStorage: false + storageClass: "" + +replicas: 1 +image: + repository: "{{ .Values.global.image.repository }}/df-llm-agent" + pullPolicy: Always + tag: latest +storageConfig: + ## persistentVolumeClaim/hostPath + ## If you use hostPath, you must configure nodeAffinityLabelSelector, otherwise your data will be lost when Pod drifts + ## 如果使用hostPath存储mysql数据,则必须配置nodeAffinityLabelSelector,避免pod漂移导致数据丢失 + type: persistentVolumeClaim + generateType: "{{ if $.Values.global.allInOneLocalStorage }}hostPath{{ else }}{{$.Values.storageConfig.type}}{{end}}" #Please ignore this + hostPath: "/opt/stella-agent-ce/debug/" + persistence: + - name: debug-path + storageClass: "{{ .Values.global.storageClass }}" + annotations: + "helm.sh/resource-policy": keep + # existingClaim: your-claim-pvc-name + accessModes: + - ReadWriteOnce + size: 50Gi +configMapData: + daemon: true + api_timeout: 500 + sql_show: false + log_file: "/var/log/df-llm-agent.log" + log_level: "info" + instance_path: "/root/df-llm-agent" + redis: + host: + - "redis" + cluster_enabled: false + port: 6379 + db: 6 + password: "password123" + mysql: + user_name: "root" + user_password: "deepflow" + host: "{{ if $.Values.global.externalMySQL.enabled }}{{$.Values.global.externalMySQL.ip}}{{ else }}{{ $.Release.Name }}-mysql{{end}}" + port: 30130 + database: "deepflow_llm" +nodeAffinityLabelSelector: + ## If you use hostPath, you must configure nodeAffinityLabelSelector, otherwise your data will be lost when Pod drifts + ## 如果使用hostPath存储stella-agent-ce数据,则必须配置nodeAffinityLabelSelector,避免pod漂移导致数据丢失 + #- matchExpressions: + # - key: kubernetes.io/hostname + # operator: In + ## values: k8s-master \ No newline at end of file diff --git a/charts/deepflow/values.yaml b/charts/deepflow/values.yaml index 8faa0de..b1707c8 100644 --- a/charts/deepflow/values.yaml +++ b/charts/deepflow/values.yaml @@ -900,4 +900,57 @@ grafana: # - secretName: chart-example-tls # hosts: # - chart-example.local - assertNoLeakedSecrets: false \ No newline at end of file + assertNoLeakedSecrets: false + + +stella-agent-ce: + replicas: 1 + image: + repository: "{{ .Values.global.image.repository }}/df-llm-agent" + pullPolicy: Always + tag: latest + + storageConfig: + ## persistentVolumeClaim/hostPath + ## If you use hostPath, you must configure nodeAffinityLabelSelector, otherwise your data will be lost when Pod drifts + ## 如果使用hostPath存储mysql数据,则必须配置nodeAffinityLabelSelector,避免pod漂移导致数据丢失 + type: persistentVolumeClaim + generateType: "{{ if $.Values.global.allInOneLocalStorage }}hostPath{{ else }}{{$.Values.storageConfig.type}}{{end}}" #Please ignore this + hostPath: "/opt/stella-agent-ce/debug/" + persistence: + - name: debug-path + storageClass: "{{ .Values.global.storageClass }}" + annotations: + "helm.sh/resource-policy": keep + # existingClaim: your-claim-pvc-name + accessModes: + - ReadWriteOnce + size: 50Gi + configMapData: + daemon: true + api_timeout: 500 + sql_show: false + log_file: "/var/log/df-llm-agent.log" + log_level: "info" + instance_path: "/root/df-llm-agent" + redis: + host: + - "redis" + cluster_enabled: false + port: 6379 + db: 6 + password: "password123" + mysql: + user_name: "root" + user_password: "deepflow" + host: "{{ if $.Values.global.externalMySQL.enabled }}{{$.Values.global.externalMySQL.ip}}{{ else }}{{ $.Release.Name }}-mysql{{end}}" + port: 30130 + database: "deepflow_llm" + nodeAffinityLabelSelector: + ## If you use hostPath, you must configure nodeAffinityLabelSelector, otherwise your data will be lost when Pod drifts + ## 如果使用hostPath存储stella-agent-ce数据,则必须配置nodeAffinityLabelSelector,避免pod漂移导致数据丢失 + #- matchExpressions: + # - key: kubernetes.io/hostname + # operator: In + ## values: k8s-master +