From 9444fdb8fdcda8199a88327d35fb506fb66e747d Mon Sep 17 00:00:00 2001 From: ylzhangah <1194926515@qq.com> Date: Thu, 27 Feb 2025 15:48:02 +0800 Subject: [PATCH 01/14] update file --- .../templates/backend/authhub-backend.yaml | 18 ++++++++++-- .../chart/authhub/templates/mysql/mysql.yaml | 9 +++++- .../authhub/templates/web/authhub-web.yaml | 9 +++++- .../databases/templates/minio/minio.yaml | 9 +++++- .../databases/templates/mongo/mongo.yaml | 9 +++++- .../databases/templates/pgsql/pgsql.yaml | 9 +++++- .../databases/templates/redis/redis.yaml | 9 +++++- .../templates/framework/framework.yaml | 18 ++++++++++-- .../templates/rag-web/rag-web.yaml | 9 +++++- .../euler_copilot/templates/rag/rag.yaml | 18 ++++++++++-- .../euler_copilot/templates/web/web.yaml | 9 +++++- .../scripts/2-install-tools/install_tools.sh | 2 +- .../modify_eulercopilot_yaml.py | 29 +++++++++++++++++-- 13 files changed, 139 insertions(+), 18 deletions(-) diff --git a/deploy/chart/authhub/templates/backend/authhub-backend.yaml b/deploy/chart/authhub/templates/backend/authhub-backend.yaml index 4a19b4ad..35ef8923 100644 --- a/deploy/chart/authhub/templates/backend/authhub-backend.yaml +++ b/deploy/chart/authhub/templates/backend/authhub-backend.yaml @@ -37,7 +37,14 @@ spec: automountServiceAccountToken: false containers: - name: authhub-backend - image: {{ if .Values.authhub.backend.image }}{{ .Values.authhub.backend.image }}{{ else }}{{ .Values.globals.imageRegistry | default "hub.oepkgs.net" }}/neocopilot/authhub:0.9.3-{{ .Values.globals.arch | default "x86" }}{{ end }} + image: {{- if .Values.authhub.backend.image }} + {{- .Values.authhub.backend.image }} + {{- else }} + {{- $registry := .Values.globals.imageRegistry | default "hub.oepkgs.net" }} + {{- $arch := .Values.globals.arch | default "x86" }} + {{- $suffix := ternary "arm" "x86" (eq $arch "arm") }} + {{- printf "%s/neocopilot/authhub:0.9.3-%s" $registry $suffix }} + {{- end }} imagePullPolicy: {{ default "IfNotPresent" .Values.globals.imagePullPolicy }} ports: - containerPort: 11120 @@ -61,7 +68,14 @@ spec: {{ toYaml .Values.authhub.backend.resourceLimits | nindent 14 }} initContainers: - name: authhub-backend-copy-secret - image: {{ if .Values.authhub.secret_inject.image }}{{ .Values.authhub.secret_inject.image }}{{ else }}{{ .Values.globals.imageRegistry | default "hub.oepkgs.net" }}/neocopilot/secret_inject:dev-{{ .Values.globals.arch | default "x86" }}{{ end }} + image: {{- if .Values.authhub.secret_inject.image }} + {{- .Values.authhub.secret_inject.image }} + {{- else }} + {{- $registry := .Values.globals.imageRegistry | default "hub.oepkgs.net" }} + {{- $arch := .Values.globals.arch | default "x86" }} + {{- $suffix := ternary "arm" "x86" (eq $arch "arm") }} + {{- printf "%s/neocopilot/secret_inject:dev-%s" $registry $suffix }} + {{- end }} imagePullPolicy: {{ default "IfNotPresent" .Values.globals.imagePullPolicy }} volumeMounts: - mountPath: /secrets/mysql-password diff --git a/deploy/chart/authhub/templates/mysql/mysql.yaml b/deploy/chart/authhub/templates/mysql/mysql.yaml index 6ff30405..cc2c97d1 100644 --- a/deploy/chart/authhub/templates/mysql/mysql.yaml +++ b/deploy/chart/authhub/templates/mysql/mysql.yaml @@ -37,7 +37,14 @@ spec: automountServiceAccountToken: false containers: - name: mysql - image: {{ if .Values.authhub.mysql.image }}{{ .Values.authhub.mysql.image }}{{ else }}{{ .Values.globals.imageRegistry | default "hub.oepkgs.net" }}/neocopilot/mysql:8-{{ .Values.globals.arch | default "x86" }}{{ end }} + image: {{- if .Values.authhub.mysql.image }} + {{- .Values.authhub.mysql.image }} + {{- else }} + {{- $registry := .Values.globals.imageRegistry | default "hub.oepkgs.net" }} + {{- $arch := .Values.globals.arch | default "x86" }} + {{- $suffix := ternary "arm" "x86" (eq $arch "arm") }} + {{- printf "%s/neocopilot/mysql:8-%s" $registry $suffix }} + {{- end }} imagePullPolicy: {{ default "IfNotPresent" .Values.globals.imagePullPolicy }} args: - "--character-set-server=utf8mb4" diff --git a/deploy/chart/authhub/templates/web/authhub-web.yaml b/deploy/chart/authhub/templates/web/authhub-web.yaml index 66d9e689..cd196b2e 100644 --- a/deploy/chart/authhub/templates/web/authhub-web.yaml +++ b/deploy/chart/authhub/templates/web/authhub-web.yaml @@ -56,7 +56,14 @@ spec: automountServiceAccountToken: false containers: - name: authhub-web - image: {{ if .Values.authhub.web.image }}{{ .Values.authhub.web.image }}{{ else }}{{ .Values.globals.imageRegistry | default "hub.oepkgs.net" }}/neocopilot/authhub-web:0.9.3-{{ .Values.globals.arch | default "x86" }}{{ end }} + image: {{- if .Values.authhub.web.image }} + {{- .Values.authhub.web.image }} + {{- else }} + {{- $registry := .Values.globals.imageRegistry | default "hub.oepkgs.net" }} + {{- $arch := .Values.globals.arch | default "x86" }} + {{- $suffix := ternary "arm" "x86" (eq $arch "arm") }} + {{- printf "%s/neocopilot/authhub-web:0.9.3-%s" $registry $suffix }} + {{- end }} imagePullPolicy: {{ default "IfNotPresent" .Values.globals.imagePullPolicy }} ports: - containerPort: 8000 diff --git a/deploy/chart/databases/templates/minio/minio.yaml b/deploy/chart/databases/templates/minio/minio.yaml index 767d4daa..62c5312f 100644 --- a/deploy/chart/databases/templates/minio/minio.yaml +++ b/deploy/chart/databases/templates/minio/minio.yaml @@ -59,7 +59,14 @@ spec: automountServiceAccountToken: false containers: - name: minio - image: {{ if .Values.databases.minio.image }}{{ .Values.databases.minio.image }}{{ else }}{{ .Values.globals.imageRegistry | default "hub.oepkgs.net" }}/neocopilot/minio:empty-{{ .Values.globals.arch | default "x86" }}{{ end }} + image: {{- if .Values.databases.minio.image }} + {{- .Values.databases.minio.image }} + {{- else }} + {{- $registry := .Values.globals.imageRegistry | default "hub.oepkgs.net" }} + {{- $arch := .Values.globals.arch | default "x86" }} + {{- $suffix := ternary "arm" "x86" (eq $arch "arm") }} + {{- printf "%s/neocopilot/minio:empty-%s" $registry $suffix }} + {{- end }} imagePullPolicy: {{ default "IfNotPresent" .Values.globals.imagePullPolicy }} args: - "server" diff --git a/deploy/chart/databases/templates/mongo/mongo.yaml b/deploy/chart/databases/templates/mongo/mongo.yaml index 93d2b256..389e4d17 100644 --- a/deploy/chart/databases/templates/mongo/mongo.yaml +++ b/deploy/chart/databases/templates/mongo/mongo.yaml @@ -37,7 +37,14 @@ spec: automountServiceAccountToken: false containers: - name: mongo - image: {{ if .Values.databases.mongo.image }}{{ .Values.databases.mongo.image }}{{ else }}{{ .Values.globals.imageRegistry | default "hub.oepkgs.net" }}/neocopilot/mongo:7.0.16-{{ .Values.globals.arch | default "x86" }}{{ end }} + image: {{- if .Values.databases.mongo.image }} + {{- .Values.databases.mongo.image }} + {{- else }} + {{- $registry := .Values.globals.imageRegistry | default "hub.oepkgs.net" }} + {{- $arch := .Values.globals.arch | default "x86" }} + {{- $suffix := ternary "arm" "x86" (eq $arch "arm") }} + {{- printf "%s/neocopilot/mongo:7.0.16-%s" $registry $suffix }} + {{- end }} imagePullPolicy: {{ default "IfNotPresent" .Values.globals.imagePullPolicy }} command: - bash diff --git a/deploy/chart/databases/templates/pgsql/pgsql.yaml b/deploy/chart/databases/templates/pgsql/pgsql.yaml index 791e7975..dd2078c0 100644 --- a/deploy/chart/databases/templates/pgsql/pgsql.yaml +++ b/deploy/chart/databases/templates/pgsql/pgsql.yaml @@ -37,7 +37,14 @@ spec: automountServiceAccountToken: false containers: - name: pgsql - image: {{ if .Values.databases.pgsql.image }}{{ .Values.databases.pgsql.image }}{{ else }}{{ .Values.globals.imageRegistry | default "hub.oepkgs.net" }}/neocopilot/pgsql-empty:pg16-{{ .Values.globals.arch | default "x86" }}{{ end }} + image: {{- if .Values.databases.pgsql.image }} + {{- .Values.databases.pgsql.image }} + {{- else }} + {{- $registry := .Values.globals.imageRegistry | default "hub.oepkgs.net" }} + {{- $arch := .Values.globals.arch | default "x86" }} + {{- $suffix := ternary "arm" "x86" (eq $arch "arm") }} + {{- printf "%s/neocopilot/pgsqle-empty:pg16-%s" $registry $suffix }} + {{- end }} imagePullPolicy: {{ default "IfNotPresent" .Values.globals.imagePullPolicy }} ports: - containerPort: 5432 diff --git a/deploy/chart/databases/templates/redis/redis.yaml b/deploy/chart/databases/templates/redis/redis.yaml index 6b269a6c..6525a625 100644 --- a/deploy/chart/databases/templates/redis/redis.yaml +++ b/deploy/chart/databases/templates/redis/redis.yaml @@ -35,7 +35,14 @@ spec: automountServiceAccountToken: false containers: - name: redis - image: {{ if .Values.databases.redis.image }}{{ .Values.databases.redis.image }}{{ else }}{{ .Values.globals.imageRegistry | default "hub.oepkgs.net" }}/neocopilot/redis:7.4-alpine-{{ .Values.globals.arch | default "x86" }}{{ end }} + image: {{- if .Values.databases.redis.image }} + {{- .Values.databases.redis.image }} + {{- else }} + {{- $registry := .Values.globals.imageRegistry | default "hub.oepkgs.net" }} + {{- $arch := .Values.globals.arch | default "x86" }} + {{- $suffix := ternary "arm" "x86" (eq $arch "arm") }} + {{- printf "%s/neocopilot/redis:7.4-alpine-%s" $registry $suffix }} + {{- end }} imagePullPolicy: {{ default "IfNotPresent" .Values.globals.imagePullPolicy }} command: - redis-server diff --git a/deploy/chart/euler_copilot/templates/framework/framework.yaml b/deploy/chart/euler_copilot/templates/framework/framework.yaml index 33f18628..392224f9 100644 --- a/deploy/chart/euler_copilot/templates/framework/framework.yaml +++ b/deploy/chart/euler_copilot/templates/framework/framework.yaml @@ -38,7 +38,14 @@ spec: fsGroup: 1001 containers: - name: framework - image: {{ if .Values.euler_copilot.framework.image }}{{ .Values.euler_copilot.framework.image }}{{ else }}{{ .Values.globals.imageRegistry | default "hub.oepkgs.net" }}/neocopilot/euler-copilot-framework:0.9.4-{{ .Values.globals.arch | default "x86" }}{{ end }} + image: {{- if .Values.euler_copilot.framework.image }} + {{- .Values.euler_copilot.framework.image }} + {{- else }} + {{- $registry := .Values.globals.imageRegistry | default "hub.oepkgs.net" }} + {{- $arch := .Values.globals.arch | default "x86" }} + {{- $suffix := ternary "arm" "x86" (eq $arch "arm") }} + {{- printf "%s/neocopilot/euler-copilot-framework:0.9.4-%s" $registry $suffix }} + {{- end }} imagePullPolicy: {{ default "IfNotPresent" .Values.globals.imagePullPolicy }} ports: - containerPort: 8002 @@ -80,7 +87,14 @@ spec: {{ toYaml .Values.euler_copilot.framework.resourceLimits | nindent 14 }} initContainers: - name: framework-copy - image: {{ if .Values.euler_copilot.secret_inject.image }}{{ .Values.euler_copilot.secret_inject.image }}{{ else }}{{ .Values.globals.imageRegistry | default "hub.oepkgs.net" }}/neocopilot/secret_inject:dev-{{ .Values.globals.arch | default "x86" }}{{ end }} + image: {{- if .Values.euler_copilot.secret_inject.image }} + {{- .Values.euler_copilot.secret_inject.image }} + {{- else }} + {{- $registry := .Values.globals.imageRegistry | default "hub.oepkgs.net" }} + {{- $arch := .Values.globals.arch | default "x86" }} + {{- $suffix := ternary "arm" "x86" (eq $arch "arm") }} + {{- printf "%s/neocopilot/secret_inject:dev-%s" $registry $suffix }} + {{- end }} imagePullPolicy: {{ default "IfNotPresent" .Values.globals.imagePullPolicy }} volumeMounts: - mountPath: /config/.env diff --git a/deploy/chart/euler_copilot/templates/rag-web/rag-web.yaml b/deploy/chart/euler_copilot/templates/rag-web/rag-web.yaml index a067d483..7e2a0b6c 100644 --- a/deploy/chart/euler_copilot/templates/rag-web/rag-web.yaml +++ b/deploy/chart/euler_copilot/templates/rag-web/rag-web.yaml @@ -56,7 +56,14 @@ spec: automountServiceAccountToken: false containers: - name: rag-web - image: {{ if .Values.euler_copilot.rag_web.image }}{{ .Values.euler_copilot.rag_web.image }}{{ else }}{{ .Values.globals.imageRegistry | default "hub.oepkgs.net" }}/neocopilot/data_chain_web:0.9.4-{{ .Values.globals.arch | default "x86" }}{{ end }} + image: {{- if .Values.euler_copilot.rag_web.image }} + {{- .Values.euler_copilot.rag_web.image }} + {{- else }} + {{- $registry := .Values.globals.imageRegistry | default "hub.oepkgs.net" }} + {{- $arch := .Values.globals.arch | default "x86" }} + {{- $suffix := ternary "arm" "x86" (eq $arch "arm") }} + {{- printf "%s/neocopilot/data_chain_web:0.9.4-%s" $registry $suffix }} + {{- end }} imagePullPolicy: {{ default "IfNotPresent" .Values.globals.imagePullPolicy }} ports: - containerPort: 9888 diff --git a/deploy/chart/euler_copilot/templates/rag/rag.yaml b/deploy/chart/euler_copilot/templates/rag/rag.yaml index 75660921..5d68ef85 100644 --- a/deploy/chart/euler_copilot/templates/rag/rag.yaml +++ b/deploy/chart/euler_copilot/templates/rag/rag.yaml @@ -37,7 +37,14 @@ spec: automountServiceAccountToken: false containers: - name: rag - image: {{ if .Values.euler_copilot.rag.image }}{{ .Values.euler_copilot.rag.image }}{{ else }}{{ .Values.globals.imageRegistry | default "hub.oepkgs.net" }}/neocopilot/data_chain_back_end:0.9.4-{{ .Values.globals.arch | default "x86" }}{{ end }} + image: {{- if .Values.euler_copilot.rag.image }} + {{- .Values.euler_copilot.rag.image }} + {{- else }} + {{- $registry := .Values.globals.imageRegistry | default "hub.oepkgs.net" }} + {{- $arch := .Values.globals.arch | default "x86" }} + {{- $suffix := ternary "arm" "x86" (eq $arch "arm") }} + {{- printf "%s/neocopilot/data_chain_back_end:0.9.4-%s" $registry $suffix }} + {{- end }} imagePullPolicy: {{ default "IfNotPresent" .Values.globals.imagePullPolicy }} ports: - containerPort: 9988 @@ -64,7 +71,14 @@ spec: {{ toYaml .Values.euler_copilot.rag.resourceLimits | nindent 14 }} initContainers: - name: rag-copy-secret - image: {{ if .Values.euler_copilot.secret_inject.image }}{{ .Values.euler_copilot.secret_inject.image }}{{ else }}{{ .Values.globals.imageRegistry | default "hub.oepkgs.net" }}/neocopilot/secret_inject:dev-{{ .Values.globals.arch | default "x86" }}{{ end }} + image: {{- if .Values.euler_copilot.secret_inject.image }} + {{- .Values.euler_copilot.secret_inject.image }} + {{- else }} + {{- $registry := .Values.globals.imageRegistry | default "hub.oepkgs.net" }} + {{- $arch := .Values.globals.arch | default "x86" }} + {{- $suffix := ternary "arm" "x86" (eq $arch "arm") }} + {{- printf "%s/neocopilot/secret_inject:dev-%s" $registry $suffix }} + {{- end }} imagePullPolicy: {{ default "IfNotPresent" .Values.globals.imagePullPolicy }} volumeMounts: - mountPath: /config/.env diff --git a/deploy/chart/euler_copilot/templates/web/web.yaml b/deploy/chart/euler_copilot/templates/web/web.yaml index e02a99d7..47edfcae 100644 --- a/deploy/chart/euler_copilot/templates/web/web.yaml +++ b/deploy/chart/euler_copilot/templates/web/web.yaml @@ -57,7 +57,14 @@ spec: fsGroup: 1001 containers: - name: web - image: {{ if .Values.euler_copilot.web.image }}{{ .Values.euler_copilot.web.image }}{{ else }}{{ .Values.globals.imageRegistry | default "hub.oepkgs.net" }}/neocopilot/euler-copilot-web:0.9.4-{{ .Values.globals.arch | default "x86" }}{{ end }} + image: {{- if .Values.euler_copilot.web.image }} + {{- .Values.euler_copilot.web.image }} + {{- else }} + {{- $registry := .Values.globals.imageRegistry | default "hub.oepkgs.net" }} + {{- $arch := .Values.globals.arch | default "x86" }} + {{- $suffix := ternary "arm" "x86" (eq $arch "arm") }} + {{- printf "%s/neocopilot/euler-copilot-web:0.9.4-%s" $registry $suffix }} + {{- end }} imagePullPolicy: {{ default "IfNotPresent" .Values.globals.imagePullPolicy }} ports: - containerPort: 8080 diff --git a/deploy/scripts/2-install-tools/install_tools.sh b/deploy/scripts/2-install-tools/install_tools.sh index 5d5a9ace..a1e43987 100644 --- a/deploy/scripts/2-install-tools/install_tools.sh +++ b/deploy/scripts/2-install-tools/install_tools.sh @@ -44,7 +44,7 @@ install_basic_tools() { # 使用 pip 安装 requests echo "Installing requests with pip..." - pip install requests + pip install requests ruamel.yaml echo "All basic tools have been installed." } diff --git a/deploy/scripts/9-other-script/modify_eulercopilot_yaml.py b/deploy/scripts/9-other-script/modify_eulercopilot_yaml.py index 0f474a57..d8e70eba 100755 --- a/deploy/scripts/9-other-script/modify_eulercopilot_yaml.py +++ b/deploy/scripts/9-other-script/modify_eulercopilot_yaml.py @@ -1,13 +1,36 @@ -import argparse import sys +import argparse +import subprocess +# 尝试导入 YAML 库 try: from ruamel.yaml import YAML from ruamel.yaml.comments import CommentedMap USING_RUAMEL = True except ImportError: - import yaml # PyYAML - USING_RUAMEL = False + try: + import yaml # 回退到 PyYAML + USING_RUAMEL = False + except ImportError: + print("未检测到 YAML 处理库,正在自动安装 ruamel.yaml...") + try: + # 优先尝试安装 ruamel.yaml + subprocess.check_call([sys.executable, '-m', 'pip', 'install', 'ruamel.yaml']) + from ruamel.yaml import YAML + from ruamel.yaml.comments import CommentedMap + USING_RUAMEL = True + print("ruamel.yaml 安装成功") + except Exception as e: + print(f"安装 ruamel.yaml 失败: {e}, 改为尝试安装 PyYAML") + try: + # 回退安装 PyYAML + subprocess.check_call([sys.executable, '-m', 'pip', 'install', 'PyYAML']) + import yaml + USING_RUAMEL = False + print("PyYAML 安装成功") + except Exception as e: + print(f"安装 PyYAML 也失败: {e}") + sys.exit(1) def parse_value(value): """智能转换值的类型""" -- Gitee From d65539c9345ff5525960552e6eca5228d42e0c54 Mon Sep 17 00:00:00 2001 From: ylzhangah <1194926515@qq.com> Date: Thu, 27 Feb 2025 15:54:40 +0800 Subject: [PATCH 02/14] update file --- deploy/chart/databases/templates/pgsql/pgsql.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deploy/chart/databases/templates/pgsql/pgsql.yaml b/deploy/chart/databases/templates/pgsql/pgsql.yaml index dd2078c0..cc3d8d5c 100644 --- a/deploy/chart/databases/templates/pgsql/pgsql.yaml +++ b/deploy/chart/databases/templates/pgsql/pgsql.yaml @@ -43,7 +43,7 @@ spec: {{- $registry := .Values.globals.imageRegistry | default "hub.oepkgs.net" }} {{- $arch := .Values.globals.arch | default "x86" }} {{- $suffix := ternary "arm" "x86" (eq $arch "arm") }} - {{- printf "%s/neocopilot/pgsqle-empty:pg16-%s" $registry $suffix }} + {{- printf "%s/neocopilot/pgsql-empty:pg16-%s" $registry $suffix }} {{- end }} imagePullPolicy: {{ default "IfNotPresent" .Values.globals.imagePullPolicy }} ports: -- Gitee From ebd8e9afaa5acefd8a8bf6f9c189dfd0ec374db2 Mon Sep 17 00:00:00 2001 From: ylzhangah <1194926515@qq.com> Date: Thu, 27 Feb 2025 16:04:28 +0800 Subject: [PATCH 03/14] update file --- deploy/scripts/2-install-tools/install_tools.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) mode change 100644 => 100755 deploy/scripts/2-install-tools/install_tools.sh diff --git a/deploy/scripts/2-install-tools/install_tools.sh b/deploy/scripts/2-install-tools/install_tools.sh old mode 100644 new mode 100755 index a1e43987..5d5a9ace --- a/deploy/scripts/2-install-tools/install_tools.sh +++ b/deploy/scripts/2-install-tools/install_tools.sh @@ -44,7 +44,7 @@ install_basic_tools() { # 使用 pip 安装 requests echo "Installing requests with pip..." - pip install requests ruamel.yaml + pip install requests echo "All basic tools have been installed." } -- Gitee From 9750a0a1961a579a3adaa08cdd158c263efe7fba Mon Sep 17 00:00:00 2001 From: ylzhangah <1194926515@qq.com> Date: Thu, 27 Feb 2025 18:20:40 +0800 Subject: [PATCH 04/14] update file --- .../templates/backend/authhub-backend.yaml | 18 ++---------------- .../chart/authhub/templates/mysql/mysql.yaml | 9 +-------- .../authhub/templates/web/authhub-web.yaml | 9 +-------- .../chart/databases/templates/minio/minio.yaml | 9 +-------- .../chart/databases/templates/mongo/mongo.yaml | 9 +-------- .../chart/databases/templates/pgsql/pgsql.yaml | 9 +-------- .../chart/databases/templates/redis/redis.yaml | 9 +-------- .../templates/framework/framework.yaml | 18 ++---------------- .../templates/rag-web/rag-web.yaml | 9 +-------- .../chart/euler_copilot/templates/rag/rag.yaml | 18 ++---------------- .../chart/euler_copilot/templates/web/web.yaml | 9 +-------- .../scripts/3-install-ollama/install_ollama.sh | 2 +- 12 files changed, 15 insertions(+), 113 deletions(-) diff --git a/deploy/chart/authhub/templates/backend/authhub-backend.yaml b/deploy/chart/authhub/templates/backend/authhub-backend.yaml index 35ef8923..dc1fbe78 100644 --- a/deploy/chart/authhub/templates/backend/authhub-backend.yaml +++ b/deploy/chart/authhub/templates/backend/authhub-backend.yaml @@ -37,14 +37,7 @@ spec: automountServiceAccountToken: false containers: - name: authhub-backend - image: {{- if .Values.authhub.backend.image }} - {{- .Values.authhub.backend.image }} - {{- else }} - {{- $registry := .Values.globals.imageRegistry | default "hub.oepkgs.net" }} - {{- $arch := .Values.globals.arch | default "x86" }} - {{- $suffix := ternary "arm" "x86" (eq $arch "arm") }} - {{- printf "%s/neocopilot/authhub:0.9.3-%s" $registry $suffix }} - {{- end }} + image: {{ .Values.authhub.backend.image | default (printf "%s/neocopilot/authhub:0.9.3-%s" (.Values.globals.imageRegistry | default "hub.oepkgs.net") (ternary "arm" "x86" (eq (.Values.globals.arch | default "x86") "arm")) }} imagePullPolicy: {{ default "IfNotPresent" .Values.globals.imagePullPolicy }} ports: - containerPort: 11120 @@ -68,14 +61,7 @@ spec: {{ toYaml .Values.authhub.backend.resourceLimits | nindent 14 }} initContainers: - name: authhub-backend-copy-secret - image: {{- if .Values.authhub.secret_inject.image }} - {{- .Values.authhub.secret_inject.image }} - {{- else }} - {{- $registry := .Values.globals.imageRegistry | default "hub.oepkgs.net" }} - {{- $arch := .Values.globals.arch | default "x86" }} - {{- $suffix := ternary "arm" "x86" (eq $arch "arm") }} - {{- printf "%s/neocopilot/secret_inject:dev-%s" $registry $suffix }} - {{- end }} + image: {{ .Values.authhub.secret_inject.image | default (printf "%s/neocopilot/secret_inject:dev-%s" (.Values.globals.imageRegistry | default "hub.oepkgs.net") (ternary "arm" "x86" (eq (.Values.globals.arch | default "x86") "arm")) }} imagePullPolicy: {{ default "IfNotPresent" .Values.globals.imagePullPolicy }} volumeMounts: - mountPath: /secrets/mysql-password diff --git a/deploy/chart/authhub/templates/mysql/mysql.yaml b/deploy/chart/authhub/templates/mysql/mysql.yaml index cc2c97d1..ce6b73f5 100644 --- a/deploy/chart/authhub/templates/mysql/mysql.yaml +++ b/deploy/chart/authhub/templates/mysql/mysql.yaml @@ -37,14 +37,7 @@ spec: automountServiceAccountToken: false containers: - name: mysql - image: {{- if .Values.authhub.mysql.image }} - {{- .Values.authhub.mysql.image }} - {{- else }} - {{- $registry := .Values.globals.imageRegistry | default "hub.oepkgs.net" }} - {{- $arch := .Values.globals.arch | default "x86" }} - {{- $suffix := ternary "arm" "x86" (eq $arch "arm") }} - {{- printf "%s/neocopilot/mysql:8-%s" $registry $suffix }} - {{- end }} + image: {{ .Values.authhub.mysql.image | default (printf "%s/neocopilot/mysql:8-%s" (.Values.globals.imageRegistry | default "hub.oepkgs.net") (ternary "arm" "x86" (eq (.Values.globals.arch | default "x86") "arm")) }} imagePullPolicy: {{ default "IfNotPresent" .Values.globals.imagePullPolicy }} args: - "--character-set-server=utf8mb4" diff --git a/deploy/chart/authhub/templates/web/authhub-web.yaml b/deploy/chart/authhub/templates/web/authhub-web.yaml index cd196b2e..04763521 100644 --- a/deploy/chart/authhub/templates/web/authhub-web.yaml +++ b/deploy/chart/authhub/templates/web/authhub-web.yaml @@ -56,14 +56,7 @@ spec: automountServiceAccountToken: false containers: - name: authhub-web - image: {{- if .Values.authhub.web.image }} - {{- .Values.authhub.web.image }} - {{- else }} - {{- $registry := .Values.globals.imageRegistry | default "hub.oepkgs.net" }} - {{- $arch := .Values.globals.arch | default "x86" }} - {{- $suffix := ternary "arm" "x86" (eq $arch "arm") }} - {{- printf "%s/neocopilot/authhub-web:0.9.3-%s" $registry $suffix }} - {{- end }} + image: {{ .Values.authhub.web.image | default (printf "%s/neocopilot/authhub-web:0.9.3-%s" (.Values.globals.imageRegistry | default "hub.oepkgs.net") (ternary "arm" "x86" (eq (.Values.globals.arch | default "x86") "arm")) }} imagePullPolicy: {{ default "IfNotPresent" .Values.globals.imagePullPolicy }} ports: - containerPort: 8000 diff --git a/deploy/chart/databases/templates/minio/minio.yaml b/deploy/chart/databases/templates/minio/minio.yaml index 62c5312f..b44608a3 100644 --- a/deploy/chart/databases/templates/minio/minio.yaml +++ b/deploy/chart/databases/templates/minio/minio.yaml @@ -59,14 +59,7 @@ spec: automountServiceAccountToken: false containers: - name: minio - image: {{- if .Values.databases.minio.image }} - {{- .Values.databases.minio.image }} - {{- else }} - {{- $registry := .Values.globals.imageRegistry | default "hub.oepkgs.net" }} - {{- $arch := .Values.globals.arch | default "x86" }} - {{- $suffix := ternary "arm" "x86" (eq $arch "arm") }} - {{- printf "%s/neocopilot/minio:empty-%s" $registry $suffix }} - {{- end }} + image: {{ .Values.databases.minio.image | default (printf "%s/neocopilot/minio:empty-%s" (.Values.globals.imageRegistry | default "hub.oepkgs.net") (ternary "arm" "x86" (eq (.Values.globals.arch | default "x86") "arm")) }} imagePullPolicy: {{ default "IfNotPresent" .Values.globals.imagePullPolicy }} args: - "server" diff --git a/deploy/chart/databases/templates/mongo/mongo.yaml b/deploy/chart/databases/templates/mongo/mongo.yaml index 389e4d17..02918916 100644 --- a/deploy/chart/databases/templates/mongo/mongo.yaml +++ b/deploy/chart/databases/templates/mongo/mongo.yaml @@ -37,14 +37,7 @@ spec: automountServiceAccountToken: false containers: - name: mongo - image: {{- if .Values.databases.mongo.image }} - {{- .Values.databases.mongo.image }} - {{- else }} - {{- $registry := .Values.globals.imageRegistry | default "hub.oepkgs.net" }} - {{- $arch := .Values.globals.arch | default "x86" }} - {{- $suffix := ternary "arm" "x86" (eq $arch "arm") }} - {{- printf "%s/neocopilot/mongo:7.0.16-%s" $registry $suffix }} - {{- end }} + image: {{ .Values.databases.mongo.image | default (printf "%s/neocopilot/mongo:7.0.16-%s" (.Values.globals.imageRegistry | default "hub.oepkgs.net") (ternary "arm" "x86" (eq (.Values.globals.arch | default "x86") "arm")) }} imagePullPolicy: {{ default "IfNotPresent" .Values.globals.imagePullPolicy }} command: - bash diff --git a/deploy/chart/databases/templates/pgsql/pgsql.yaml b/deploy/chart/databases/templates/pgsql/pgsql.yaml index cc3d8d5c..b696b3cf 100644 --- a/deploy/chart/databases/templates/pgsql/pgsql.yaml +++ b/deploy/chart/databases/templates/pgsql/pgsql.yaml @@ -37,14 +37,7 @@ spec: automountServiceAccountToken: false containers: - name: pgsql - image: {{- if .Values.databases.pgsql.image }} - {{- .Values.databases.pgsql.image }} - {{- else }} - {{- $registry := .Values.globals.imageRegistry | default "hub.oepkgs.net" }} - {{- $arch := .Values.globals.arch | default "x86" }} - {{- $suffix := ternary "arm" "x86" (eq $arch "arm") }} - {{- printf "%s/neocopilot/pgsql-empty:pg16-%s" $registry $suffix }} - {{- end }} + image: {{ .Values.databases.pgsql.image | default (printf "%s/neocopilot/pgsql-empty:pgsql-%s" (.Values.globals.imageRegistry | default "hub.oepkgs.net") (ternary "arm" "x86" (eq (.Values.globals.arch | default "x86") "arm")) }} imagePullPolicy: {{ default "IfNotPresent" .Values.globals.imagePullPolicy }} ports: - containerPort: 5432 diff --git a/deploy/chart/databases/templates/redis/redis.yaml b/deploy/chart/databases/templates/redis/redis.yaml index 6525a625..3ca5eef4 100644 --- a/deploy/chart/databases/templates/redis/redis.yaml +++ b/deploy/chart/databases/templates/redis/redis.yaml @@ -35,14 +35,7 @@ spec: automountServiceAccountToken: false containers: - name: redis - image: {{- if .Values.databases.redis.image }} - {{- .Values.databases.redis.image }} - {{- else }} - {{- $registry := .Values.globals.imageRegistry | default "hub.oepkgs.net" }} - {{- $arch := .Values.globals.arch | default "x86" }} - {{- $suffix := ternary "arm" "x86" (eq $arch "arm") }} - {{- printf "%s/neocopilot/redis:7.4-alpine-%s" $registry $suffix }} - {{- end }} + image: {{ .Values.databases.redis.image | default (printf "%s/neocopilot/redis:7.4-alpine-%s" (.Values.globals.imageRegistry | default "hub.oepkgs.net") (ternary "arm" "x86" (eq (.Values.globals.arch | default "x86") "arm")) }} imagePullPolicy: {{ default "IfNotPresent" .Values.globals.imagePullPolicy }} command: - redis-server diff --git a/deploy/chart/euler_copilot/templates/framework/framework.yaml b/deploy/chart/euler_copilot/templates/framework/framework.yaml index 392224f9..e11d86ba 100644 --- a/deploy/chart/euler_copilot/templates/framework/framework.yaml +++ b/deploy/chart/euler_copilot/templates/framework/framework.yaml @@ -38,14 +38,7 @@ spec: fsGroup: 1001 containers: - name: framework - image: {{- if .Values.euler_copilot.framework.image }} - {{- .Values.euler_copilot.framework.image }} - {{- else }} - {{- $registry := .Values.globals.imageRegistry | default "hub.oepkgs.net" }} - {{- $arch := .Values.globals.arch | default "x86" }} - {{- $suffix := ternary "arm" "x86" (eq $arch "arm") }} - {{- printf "%s/neocopilot/euler-copilot-framework:0.9.4-%s" $registry $suffix }} - {{- end }} + image: {{ .Values.euler_copilot.framework.image | default (printf "%s/neocopilot/euler-copilot-framework:0.9.4-%s" (.Values.globals.imageRegistry | default "hub.oepkgs.net") (ternary "arm" "x86" (eq (.Values.globals.arch | default "x86") "arm")) }} imagePullPolicy: {{ default "IfNotPresent" .Values.globals.imagePullPolicy }} ports: - containerPort: 8002 @@ -87,14 +80,7 @@ spec: {{ toYaml .Values.euler_copilot.framework.resourceLimits | nindent 14 }} initContainers: - name: framework-copy - image: {{- if .Values.euler_copilot.secret_inject.image }} - {{- .Values.euler_copilot.secret_inject.image }} - {{- else }} - {{- $registry := .Values.globals.imageRegistry | default "hub.oepkgs.net" }} - {{- $arch := .Values.globals.arch | default "x86" }} - {{- $suffix := ternary "arm" "x86" (eq $arch "arm") }} - {{- printf "%s/neocopilot/secret_inject:dev-%s" $registry $suffix }} - {{- end }} + image: {{ .Values.euler_copilot.secret_inject.image | default (printf "%s/neocopilot/secret_inject:dev-%s" (.Values.globals.imageRegistry | default "hub.oepkgs.net") (ternary "arm" "x86" (eq (.Values.globals.arch | default "x86") "arm")) }} imagePullPolicy: {{ default "IfNotPresent" .Values.globals.imagePullPolicy }} volumeMounts: - mountPath: /config/.env diff --git a/deploy/chart/euler_copilot/templates/rag-web/rag-web.yaml b/deploy/chart/euler_copilot/templates/rag-web/rag-web.yaml index 7e2a0b6c..b1315703 100644 --- a/deploy/chart/euler_copilot/templates/rag-web/rag-web.yaml +++ b/deploy/chart/euler_copilot/templates/rag-web/rag-web.yaml @@ -56,14 +56,7 @@ spec: automountServiceAccountToken: false containers: - name: rag-web - image: {{- if .Values.euler_copilot.rag_web.image }} - {{- .Values.euler_copilot.rag_web.image }} - {{- else }} - {{- $registry := .Values.globals.imageRegistry | default "hub.oepkgs.net" }} - {{- $arch := .Values.globals.arch | default "x86" }} - {{- $suffix := ternary "arm" "x86" (eq $arch "arm") }} - {{- printf "%s/neocopilot/data_chain_web:0.9.4-%s" $registry $suffix }} - {{- end }} + image: {{ .Values.euler_copilot.rag_web.image | default (printf "%s/neocopilot/data_chain_web:0.9.4-%s" (.Values.globals.imageRegistry | default "hub.oepkgs.net") (ternary "arm" "x86" (eq (.Values.globals.arch | default "x86") "arm")) }} imagePullPolicy: {{ default "IfNotPresent" .Values.globals.imagePullPolicy }} ports: - containerPort: 9888 diff --git a/deploy/chart/euler_copilot/templates/rag/rag.yaml b/deploy/chart/euler_copilot/templates/rag/rag.yaml index 5d68ef85..c5f4a031 100644 --- a/deploy/chart/euler_copilot/templates/rag/rag.yaml +++ b/deploy/chart/euler_copilot/templates/rag/rag.yaml @@ -37,14 +37,7 @@ spec: automountServiceAccountToken: false containers: - name: rag - image: {{- if .Values.euler_copilot.rag.image }} - {{- .Values.euler_copilot.rag.image }} - {{- else }} - {{- $registry := .Values.globals.imageRegistry | default "hub.oepkgs.net" }} - {{- $arch := .Values.globals.arch | default "x86" }} - {{- $suffix := ternary "arm" "x86" (eq $arch "arm") }} - {{- printf "%s/neocopilot/data_chain_back_end:0.9.4-%s" $registry $suffix }} - {{- end }} + image: {{ .Values.euler_copilot.rag.image | default (printf "%s/neocopilot/data_chain_back_end:0.9.4-%s" (.Values.globals.imageRegistry | default "hub.oepkgs.net") (ternary "arm" "x86" (eq (.Values.globals.arch | default "x86") "arm")) }} imagePullPolicy: {{ default "IfNotPresent" .Values.globals.imagePullPolicy }} ports: - containerPort: 9988 @@ -71,14 +64,7 @@ spec: {{ toYaml .Values.euler_copilot.rag.resourceLimits | nindent 14 }} initContainers: - name: rag-copy-secret - image: {{- if .Values.euler_copilot.secret_inject.image }} - {{- .Values.euler_copilot.secret_inject.image }} - {{- else }} - {{- $registry := .Values.globals.imageRegistry | default "hub.oepkgs.net" }} - {{- $arch := .Values.globals.arch | default "x86" }} - {{- $suffix := ternary "arm" "x86" (eq $arch "arm") }} - {{- printf "%s/neocopilot/secret_inject:dev-%s" $registry $suffix }} - {{- end }} + image: {{ .Values.euler_copilot.secret_inject.image | default (printf "%s/neocopilot/secret_inject:dev-%s" (.Values.globals.imageRegistry | default "hub.oepkgs.net") (ternary "arm" "x86" (eq (.Values.globals.arch | default "x86") "arm")) }} imagePullPolicy: {{ default "IfNotPresent" .Values.globals.imagePullPolicy }} volumeMounts: - mountPath: /config/.env diff --git a/deploy/chart/euler_copilot/templates/web/web.yaml b/deploy/chart/euler_copilot/templates/web/web.yaml index 47edfcae..5472baf0 100644 --- a/deploy/chart/euler_copilot/templates/web/web.yaml +++ b/deploy/chart/euler_copilot/templates/web/web.yaml @@ -57,14 +57,7 @@ spec: fsGroup: 1001 containers: - name: web - image: {{- if .Values.euler_copilot.web.image }} - {{- .Values.euler_copilot.web.image }} - {{- else }} - {{- $registry := .Values.globals.imageRegistry | default "hub.oepkgs.net" }} - {{- $arch := .Values.globals.arch | default "x86" }} - {{- $suffix := ternary "arm" "x86" (eq $arch "arm") }} - {{- printf "%s/neocopilot/euler-copilot-web:0.9.4-%s" $registry $suffix }} - {{- end }} + image: {{ .Values.euler_copilot.web.image | default (printf "%s/neocopilot/euler-copilot-web:0.9.4-%s" (.Values.globals.imageRegistry | default "hub.oepkgs.net") (ternary "arm" "x86" (eq (.Values.globals.arch | default "x86") "arm")) }} imagePullPolicy: {{ default "IfNotPresent" .Values.globals.imagePullPolicy }} ports: - containerPort: 8080 diff --git a/deploy/scripts/3-install-ollama/install_ollama.sh b/deploy/scripts/3-install-ollama/install_ollama.sh index 368a7adb..0e0850d4 100755 --- a/deploy/scripts/3-install-ollama/install_ollama.sh +++ b/deploy/scripts/3-install-ollama/install_ollama.sh @@ -202,7 +202,7 @@ After=network-online.target [Service] Environment="OLLAMA_MODELS=/var/lib/ollama/.ollama/models" -Environment=1"OLLAMA_HOST=0.0.0.0:11434" +Environment="OLLAMA_HOST=0.0.0.0:11434" ExecStart=$OLLAMA_BIN_PATH serve User=ollama Group=ollama -- Gitee From d676312df9ceabcc7ff64a8921b066f4f49830cf Mon Sep 17 00:00:00 2001 From: ylzhangah <1194926515@qq.com> Date: Thu, 27 Feb 2025 18:44:22 +0800 Subject: [PATCH 05/14] update file --- deploy/chart/databases/templates/minio/minio.yaml | 2 +- deploy/chart/databases/templates/mongo/mongo.yaml | 2 +- deploy/chart/databases/templates/pgsql/pgsql.yaml | 2 +- deploy/chart/databases/templates/redis/redis.yaml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/deploy/chart/databases/templates/minio/minio.yaml b/deploy/chart/databases/templates/minio/minio.yaml index b44608a3..fd2fdc80 100644 --- a/deploy/chart/databases/templates/minio/minio.yaml +++ b/deploy/chart/databases/templates/minio/minio.yaml @@ -59,7 +59,7 @@ spec: automountServiceAccountToken: false containers: - name: minio - image: {{ .Values.databases.minio.image | default (printf "%s/neocopilot/minio:empty-%s" (.Values.globals.imageRegistry | default "hub.oepkgs.net") (ternary "arm" "x86" (eq (.Values.globals.arch | default "x86") "arm")) }} + image: {{ .Values.databases.minio.image | default (printf "%s/neocopilot/minio:empty-%s" (.Values.globals.imageRegistry | default "hub.oepkgs.net") (ternary "arm" "x86" (eq (.Values.globals.arch | default "x86") "arm"))) }} imagePullPolicy: {{ default "IfNotPresent" .Values.globals.imagePullPolicy }} args: - "server" diff --git a/deploy/chart/databases/templates/mongo/mongo.yaml b/deploy/chart/databases/templates/mongo/mongo.yaml index 02918916..ec5774b6 100644 --- a/deploy/chart/databases/templates/mongo/mongo.yaml +++ b/deploy/chart/databases/templates/mongo/mongo.yaml @@ -37,7 +37,7 @@ spec: automountServiceAccountToken: false containers: - name: mongo - image: {{ .Values.databases.mongo.image | default (printf "%s/neocopilot/mongo:7.0.16-%s" (.Values.globals.imageRegistry | default "hub.oepkgs.net") (ternary "arm" "x86" (eq (.Values.globals.arch | default "x86") "arm")) }} + image: {{ .Values.databases.mongo.image | default (printf "%s/neocopilot/mongo:7.0.16-%s" (.Values.globals.imageRegistry | default "hub.oepkgs.net") (ternary "arm" "x86" (eq (.Values.globals.arch | default "x86") "arm"))) }} imagePullPolicy: {{ default "IfNotPresent" .Values.globals.imagePullPolicy }} command: - bash diff --git a/deploy/chart/databases/templates/pgsql/pgsql.yaml b/deploy/chart/databases/templates/pgsql/pgsql.yaml index b696b3cf..3fa5eb48 100644 --- a/deploy/chart/databases/templates/pgsql/pgsql.yaml +++ b/deploy/chart/databases/templates/pgsql/pgsql.yaml @@ -37,7 +37,7 @@ spec: automountServiceAccountToken: false containers: - name: pgsql - image: {{ .Values.databases.pgsql.image | default (printf "%s/neocopilot/pgsql-empty:pgsql-%s" (.Values.globals.imageRegistry | default "hub.oepkgs.net") (ternary "arm" "x86" (eq (.Values.globals.arch | default "x86") "arm")) }} + image: {{ .Values.databases.pgsql.image | default (printf "%s/neocopilot/pgsql-empty:pg16-%s" (.Values.globals.imageRegistry | default "hub.oepkgs.net") (ternary "arm" "x86" (eq (.Values.globals.arch | default "x86") "arm"))) }} imagePullPolicy: {{ default "IfNotPresent" .Values.globals.imagePullPolicy }} ports: - containerPort: 5432 diff --git a/deploy/chart/databases/templates/redis/redis.yaml b/deploy/chart/databases/templates/redis/redis.yaml index 3ca5eef4..c9e4d6af 100644 --- a/deploy/chart/databases/templates/redis/redis.yaml +++ b/deploy/chart/databases/templates/redis/redis.yaml @@ -35,7 +35,7 @@ spec: automountServiceAccountToken: false containers: - name: redis - image: {{ .Values.databases.redis.image | default (printf "%s/neocopilot/redis:7.4-alpine-%s" (.Values.globals.imageRegistry | default "hub.oepkgs.net") (ternary "arm" "x86" (eq (.Values.globals.arch | default "x86") "arm")) }} + image: {{ .Values.databases.redis.image | default (printf "%s/neocopilot/redis:7.4-alpine-%s" (.Values.globals.imageRegistry | default "hub.oepkgs.net") (ternary "arm" "x86" (eq (.Values.globals.arch | default "x86") "arm"))) }} imagePullPolicy: {{ default "IfNotPresent" .Values.globals.imagePullPolicy }} command: - redis-server -- Gitee From 838ba28cd1745accddd394e8c9ebdbabbfbdd51e Mon Sep 17 00:00:00 2001 From: ylzhangah <1194926515@qq.com> Date: Thu, 27 Feb 2025 18:47:50 +0800 Subject: [PATCH 06/14] update file --- deploy/chart/authhub/templates/backend/authhub-backend.yaml | 4 ++-- deploy/chart/authhub/templates/mysql/mysql.yaml | 2 +- deploy/chart/authhub/templates/web/authhub-web.yaml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/deploy/chart/authhub/templates/backend/authhub-backend.yaml b/deploy/chart/authhub/templates/backend/authhub-backend.yaml index dc1fbe78..54884d24 100644 --- a/deploy/chart/authhub/templates/backend/authhub-backend.yaml +++ b/deploy/chart/authhub/templates/backend/authhub-backend.yaml @@ -37,7 +37,7 @@ spec: automountServiceAccountToken: false containers: - name: authhub-backend - image: {{ .Values.authhub.backend.image | default (printf "%s/neocopilot/authhub:0.9.3-%s" (.Values.globals.imageRegistry | default "hub.oepkgs.net") (ternary "arm" "x86" (eq (.Values.globals.arch | default "x86") "arm")) }} + image: {{ .Values.authhub.backend.image | default (printf "%s/neocopilot/authhub:0.9.3-%s" (.Values.globals.imageRegistry | default "hub.oepkgs.net") (ternary "arm" "x86" (eq (.Values.globals.arch | default "x86") "arm"))) }} imagePullPolicy: {{ default "IfNotPresent" .Values.globals.imagePullPolicy }} ports: - containerPort: 11120 @@ -61,7 +61,7 @@ spec: {{ toYaml .Values.authhub.backend.resourceLimits | nindent 14 }} initContainers: - name: authhub-backend-copy-secret - image: {{ .Values.authhub.secret_inject.image | default (printf "%s/neocopilot/secret_inject:dev-%s" (.Values.globals.imageRegistry | default "hub.oepkgs.net") (ternary "arm" "x86" (eq (.Values.globals.arch | default "x86") "arm")) }} + image: {{ .Values.authhub.secret_inject.image | default (printf "%s/neocopilot/secret_inject:dev-%s" (.Values.globals.imageRegistry | default "hub.oepkgs.net") (ternary "arm" "x86" (eq (.Values.globals.arch | default "x86") "arm"))) }} imagePullPolicy: {{ default "IfNotPresent" .Values.globals.imagePullPolicy }} volumeMounts: - mountPath: /secrets/mysql-password diff --git a/deploy/chart/authhub/templates/mysql/mysql.yaml b/deploy/chart/authhub/templates/mysql/mysql.yaml index ce6b73f5..f9fdc318 100644 --- a/deploy/chart/authhub/templates/mysql/mysql.yaml +++ b/deploy/chart/authhub/templates/mysql/mysql.yaml @@ -37,7 +37,7 @@ spec: automountServiceAccountToken: false containers: - name: mysql - image: {{ .Values.authhub.mysql.image | default (printf "%s/neocopilot/mysql:8-%s" (.Values.globals.imageRegistry | default "hub.oepkgs.net") (ternary "arm" "x86" (eq (.Values.globals.arch | default "x86") "arm")) }} + image: {{ .Values.authhub.mysql.image | default (printf "%s/neocopilot/mysql:8-%s" (.Values.globals.imageRegistry | default "hub.oepkgs.net") (ternary "arm" "x86" (eq (.Values.globals.arch | default "x86") "arm"))) }} imagePullPolicy: {{ default "IfNotPresent" .Values.globals.imagePullPolicy }} args: - "--character-set-server=utf8mb4" diff --git a/deploy/chart/authhub/templates/web/authhub-web.yaml b/deploy/chart/authhub/templates/web/authhub-web.yaml index 04763521..05ca0315 100644 --- a/deploy/chart/authhub/templates/web/authhub-web.yaml +++ b/deploy/chart/authhub/templates/web/authhub-web.yaml @@ -56,7 +56,7 @@ spec: automountServiceAccountToken: false containers: - name: authhub-web - image: {{ .Values.authhub.web.image | default (printf "%s/neocopilot/authhub-web:0.9.3-%s" (.Values.globals.imageRegistry | default "hub.oepkgs.net") (ternary "arm" "x86" (eq (.Values.globals.arch | default "x86") "arm")) }} + image: {{ .Values.authhub.web.image | default (printf "%s/neocopilot/authhub-web:0.9.3-%s" (.Values.globals.imageRegistry | default "hub.oepkgs.net") (ternary "arm" "x86" (eq (.Values.globals.arch | default "x86") "arm"))) }} imagePullPolicy: {{ default "IfNotPresent" .Values.globals.imagePullPolicy }} ports: - containerPort: 8000 -- Gitee From 75f7f33ca8d0ad573ef0706a187c6fa859e4aab6 Mon Sep 17 00:00:00 2001 From: ylzhangah <1194926515@qq.com> Date: Thu, 27 Feb 2025 18:49:57 +0800 Subject: [PATCH 07/14] update file --- deploy/chart/euler_copilot/templates/framework/framework.yaml | 4 ++-- deploy/chart/euler_copilot/templates/rag-web/rag-web.yaml | 2 +- deploy/chart/euler_copilot/templates/rag/rag.yaml | 4 ++-- deploy/chart/euler_copilot/templates/web/web.yaml | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/deploy/chart/euler_copilot/templates/framework/framework.yaml b/deploy/chart/euler_copilot/templates/framework/framework.yaml index e11d86ba..d5687123 100644 --- a/deploy/chart/euler_copilot/templates/framework/framework.yaml +++ b/deploy/chart/euler_copilot/templates/framework/framework.yaml @@ -38,7 +38,7 @@ spec: fsGroup: 1001 containers: - name: framework - image: {{ .Values.euler_copilot.framework.image | default (printf "%s/neocopilot/euler-copilot-framework:0.9.4-%s" (.Values.globals.imageRegistry | default "hub.oepkgs.net") (ternary "arm" "x86" (eq (.Values.globals.arch | default "x86") "arm")) }} + image: {{ .Values.euler_copilot.framework.image | default (printf "%s/neocopilot/euler-copilot-framework:0.9.4-%s" (.Values.globals.imageRegistry | default "hub.oepkgs.net") (ternary "arm" "x86" (eq (.Values.globals.arch | default "x86") "arm"))) }} imagePullPolicy: {{ default "IfNotPresent" .Values.globals.imagePullPolicy }} ports: - containerPort: 8002 @@ -80,7 +80,7 @@ spec: {{ toYaml .Values.euler_copilot.framework.resourceLimits | nindent 14 }} initContainers: - name: framework-copy - image: {{ .Values.euler_copilot.secret_inject.image | default (printf "%s/neocopilot/secret_inject:dev-%s" (.Values.globals.imageRegistry | default "hub.oepkgs.net") (ternary "arm" "x86" (eq (.Values.globals.arch | default "x86") "arm")) }} + image: {{ .Values.euler_copilot.secret_inject.image | default (printf "%s/neocopilot/secret_inject:dev-%s" (.Values.globals.imageRegistry | default "hub.oepkgs.net") (ternary "arm" "x86" (eq (.Values.globals.arch | default "x86") "arm"))) }} imagePullPolicy: {{ default "IfNotPresent" .Values.globals.imagePullPolicy }} volumeMounts: - mountPath: /config/.env diff --git a/deploy/chart/euler_copilot/templates/rag-web/rag-web.yaml b/deploy/chart/euler_copilot/templates/rag-web/rag-web.yaml index b1315703..7dcd40c5 100644 --- a/deploy/chart/euler_copilot/templates/rag-web/rag-web.yaml +++ b/deploy/chart/euler_copilot/templates/rag-web/rag-web.yaml @@ -56,7 +56,7 @@ spec: automountServiceAccountToken: false containers: - name: rag-web - image: {{ .Values.euler_copilot.rag_web.image | default (printf "%s/neocopilot/data_chain_web:0.9.4-%s" (.Values.globals.imageRegistry | default "hub.oepkgs.net") (ternary "arm" "x86" (eq (.Values.globals.arch | default "x86") "arm")) }} + image: {{ .Values.euler_copilot.rag_web.image | default (printf "%s/neocopilot/data_chain_web:0.9.4-%s" (.Values.globals.imageRegistry | default "hub.oepkgs.net") (ternary "arm" "x86" (eq (.Values.globals.arch | default "x86") "arm"))) }} imagePullPolicy: {{ default "IfNotPresent" .Values.globals.imagePullPolicy }} ports: - containerPort: 9888 diff --git a/deploy/chart/euler_copilot/templates/rag/rag.yaml b/deploy/chart/euler_copilot/templates/rag/rag.yaml index c5f4a031..75dbd6ad 100644 --- a/deploy/chart/euler_copilot/templates/rag/rag.yaml +++ b/deploy/chart/euler_copilot/templates/rag/rag.yaml @@ -37,7 +37,7 @@ spec: automountServiceAccountToken: false containers: - name: rag - image: {{ .Values.euler_copilot.rag.image | default (printf "%s/neocopilot/data_chain_back_end:0.9.4-%s" (.Values.globals.imageRegistry | default "hub.oepkgs.net") (ternary "arm" "x86" (eq (.Values.globals.arch | default "x86") "arm")) }} + image: {{ .Values.euler_copilot.rag.image | default (printf "%s/neocopilot/data_chain_back_end:0.9.4-%s" (.Values.globals.imageRegistry | default "hub.oepkgs.net") (ternary "arm" "x86" (eq (.Values.globals.arch | default "x86") "arm"))) }} imagePullPolicy: {{ default "IfNotPresent" .Values.globals.imagePullPolicy }} ports: - containerPort: 9988 @@ -64,7 +64,7 @@ spec: {{ toYaml .Values.euler_copilot.rag.resourceLimits | nindent 14 }} initContainers: - name: rag-copy-secret - image: {{ .Values.euler_copilot.secret_inject.image | default (printf "%s/neocopilot/secret_inject:dev-%s" (.Values.globals.imageRegistry | default "hub.oepkgs.net") (ternary "arm" "x86" (eq (.Values.globals.arch | default "x86") "arm")) }} + image: {{ .Values.euler_copilot.secret_inject.image | default (printf "%s/neocopilot/secret_inject:dev-%s" (.Values.globals.imageRegistry | default "hub.oepkgs.net") (ternary "arm" "x86" (eq (.Values.globals.arch | default "x86") "arm"))) }} imagePullPolicy: {{ default "IfNotPresent" .Values.globals.imagePullPolicy }} volumeMounts: - mountPath: /config/.env diff --git a/deploy/chart/euler_copilot/templates/web/web.yaml b/deploy/chart/euler_copilot/templates/web/web.yaml index 5472baf0..d0dacc4f 100644 --- a/deploy/chart/euler_copilot/templates/web/web.yaml +++ b/deploy/chart/euler_copilot/templates/web/web.yaml @@ -57,7 +57,7 @@ spec: fsGroup: 1001 containers: - name: web - image: {{ .Values.euler_copilot.web.image | default (printf "%s/neocopilot/euler-copilot-web:0.9.4-%s" (.Values.globals.imageRegistry | default "hub.oepkgs.net") (ternary "arm" "x86" (eq (.Values.globals.arch | default "x86") "arm")) }} + image: {{ .Values.euler_copilot.web.image | default (printf "%s/neocopilot/euler-copilot-web:0.9.4-%s" (.Values.globals.imageRegistry | default "hub.oepkgs.net") (ternary "arm" "x86" (eq (.Values.globals.arch | default "x86") "arm"))) }} imagePullPolicy: {{ default "IfNotPresent" .Values.globals.imagePullPolicy }} ports: - containerPort: 8080 -- Gitee From f03fbb4f7e0996f04f29dd4293222585ed2b4573 Mon Sep 17 00:00:00 2001 From: ylzhangah <1194926515@qq.com> Date: Thu, 27 Feb 2025 19:37:31 +0800 Subject: [PATCH 08/14] update file --- .../7-install-authhub/install_authhub.sh | 29 +++++++++++-------- 1 file changed, 17 insertions(+), 12 deletions(-) mode change 100644 => 100755 deploy/scripts/7-install-authhub/install_authhub.sh diff --git a/deploy/scripts/7-install-authhub/install_authhub.sh b/deploy/scripts/7-install-authhub/install_authhub.sh old mode 100644 new mode 100755 index cc841224..168ca64c --- a/deploy/scripts/7-install-authhub/install_authhub.sh +++ b/deploy/scripts/7-install-authhub/install_authhub.sh @@ -1,6 +1,5 @@ #!/bin/bash - set -eo pipefail RED='\033[31m' @@ -26,7 +25,8 @@ get_architecture() { return 1 ;; esac - echo -e "${GREEN}检测到系统架构:$(uname -m)${NC}" + echo -e "${GREEN}检测到系统架构:$(uname -m)${NC}" >&2 + echo "$arch" } create_namespace() { @@ -61,9 +61,9 @@ delete_pvcs() { local pvc_name pvc_name=$(kubectl get pvc -n euler-copilot | grep 'mysql-pvc' 2>/dev/null || true) - if [ -n "$pvc_list" ]; then + if [ -n "$pvc_name" ]; then echo -e "${YELLOW}找到以下PVC,开始清理...${NC}" - kubectl delete pvc mysql-pvc -n euler-copilot --force --grace-period=0 || echo -e "${RED}PVC删除失败,继续执行...${NC}" + kubectl delete pvc mysql-pvc -n euler-copilot --force --grace-period=0 || echo -e "${RED}PVC删除失败,继续执行...${NC}" else echo -e "${YELLOW}未找到需要清理的PVC${NC}" fi @@ -88,6 +88,7 @@ get_user_input() { } helm_install() { + local arch="$1" echo -e "${BLUE}==> 进入部署目录...${NC}" [ ! -d "${DEPLOY_DIR}/chart" ] && { echo -e "${RED}错误:部署目录不存在 ${DEPLOY_DIR}/chart ${NC}" @@ -140,15 +141,20 @@ check_pods_status() { } main() { - get_architecture - create_namespace - delete_pvcs - get_user_input - helm_install - check_pods_status + local arch + arch=$(get_architecture) || exit 1 + create_namespace || exit 1 + delete_pvcs || exit 1 + get_user_input || exit 1 + helm_install "$arch" || exit 1 + check_pods_status || { + echo -e "${RED}部署失败:Pod状态检查未通过!${NC}" + exit 1 + } echo -e "\n${GREEN}=========================" - echo "Authhub 部署完成!" + echo -e "Authhub 部署完成!" + echo -e "查看pod状态:kubectl get pod -n euler-copilot" echo -e "Authhub登录地址为: https://${authhub_domain}" echo -e "默认账号密码: administrator/changeme" echo -e "=========================${NC}" @@ -156,4 +162,3 @@ main() { trap 'echo -e "${RED}操作被中断!${NC}"; exit 1' INT main "$@" - -- Gitee From f00fefa03628b740cbbe22b7b6ad11022a419e74 Mon Sep 17 00:00:00 2001 From: ylzhangah <1194926515@qq.com> Date: Thu, 27 Feb 2025 20:10:22 +0800 Subject: [PATCH 09/14] update file --- .../get_client_id_and_secret.py | 81 ++++++++++++++----- 1 file changed, 61 insertions(+), 20 deletions(-) diff --git a/deploy/scripts/9-other-script/get_client_id_and_secret.py b/deploy/scripts/9-other-script/get_client_id_and_secret.py index 49644f86..834f5a25 100755 --- a/deploy/scripts/9-other-script/get_client_id_and_secret.py +++ b/deploy/scripts/9-other-script/get_client_id_and_secret.py @@ -31,11 +31,8 @@ def get_service_cluster_ip(namespace, service_name): # 从解析后的JSON中获取Cluster IP cluster_ip = service_info['spec'].get('clusterIP', 'No Cluster IP found') - return cluster_ip - - def get_user_token(auth_hub_url, username="administrator", password="changeme"): url = auth_hub_url + "/oauth2/manager-login" payload = { @@ -45,10 +42,31 @@ def get_user_token(auth_hub_url, username="administrator", password="changeme"): headers = { "Content-Type": "application/json", } - response = requests.post(url, data=json.dumps(payload), headers=headers, verify=False) - if response.status_code == 200: - user_token = response.json()["data"]["user_token"] - return user_token + try: + response = requests.post(url, json=payload, headers=headers, verify=False, timeout=10) + response.raise_for_status() # 触发HTTPError异常如果状态码不是2xx + response_data = response.json() + + # 检查响应结构是否包含data.user_token + if "data" in response_data and "user_token" in response_data["data"]: + return response_data["data"]["user_token"] + else: + print("错误:响应中缺少预期的数据结构") + print("完整响应内容:", json.dumps(response_data, indent=2)) + sys.exit(1) + + except requests.exceptions.HTTPError as e: + print(f"登录请求失败,HTTP状态码:{response.status_code}") + print("响应内容:", response.text) + sys.exit(1) + except json.JSONDecodeError: + print("错误:无法解析响应为JSON") + print("原始响应:", response.text) + sys.exit(1) + except Exception as e: + print(f"发生未知错误:{str(e)}") + sys.exit(1) + def register_app(auth_hub_url, user_token, client_name, client_url, redierct_urls): url = auth_hub_url + "/oauth2/applications/register" @@ -71,21 +89,34 @@ def register_app(auth_hub_url, user_token, client_name, client_url, redierct_url response = requests.post(url, json=payload, headers=headers) return response.json() - -def get_client_secret(auth_hub_url, user_token): # 修改参数列表 +def get_client_secret(auth_hub_url, user_token): url = auth_hub_url + "/oauth2/applications" headers = { "Authorization": user_token, "Content-Type": "application/json" } - response = requests.get(url, headers=headers) - for app in response.json()['data']["applications"]: - if app["client_metadata"]["client_name"] == "EulerCopilot": - return { - "client_id": app["client_info"]["client_id"], - "client_secret": app["client_info"]["client_secret"] - } - return {"error": "Application not found"} + try: + response = requests.get(url, headers=headers, timeout=10) + response.raise_for_status() + apps_data = response.json() + + # 确保响应结构正确 + if "data" in apps_data and "applications" in apps_data["data"]: + for app in apps_data["data"]["applications"]: + if app.get("client_metadata", {}).get("client_name") == "EulerCopilot": + return { + "client_id": app["client_info"]["client_id"], + "client_secret": app["client_info"]["client_secret"] + } + return {"error": "Application not found"} + else: + print("错误:应用列表响应结构异常") + print("完整响应:", json.dumps(apps_data, indent=2)) + sys.exit(1) + + except requests.exceptions.RequestException as e: + print(f"获取客户端凭证失败:{str(e)}") + sys.exit(1) if __name__ == "__main__": namespace = "euler-copilot" @@ -101,13 +132,23 @@ if __name__ == "__main__": print("2. 服务尚未分配IP(查看状态: kubectl get svc/{service_name} -n {namespace} -w)") sys.exit(1) + print("\n请填写应用注册信息(直接回车使用默认值)") + # 注册应用 + client_name = input(f"请输入 client_name (默认:EulerCopilot):").strip() or "EulerCopilot" + client_url = input(f"请输入 client_url (默认:https://www.eulercopilot.local):").strip() or "https://www.eulercopilot.local" + + redirect_input = input( + f"请输入 redirect_urls (逗号分隔,默认:https://www.eulercopilot.local/api/auth/login):" +).strip() + if redirect_input: + redirect_urls = [url.strip() for url in redirect_input.split(",")] + else: + redirect_urls = ["https://www.eulercopilot.local/api/auth/login"] + auth_hub_url = f"http://{cluster_ip}:8000" user_token = get_user_token(auth_hub_url) # 注册应用 - client_name = "EulerCopilot" - client_url = "https://www.eulercopilot.local" - redirect_urls = ["https://www.eulercopilot.local/api/auth/login"] register_app(auth_hub_url, user_token, client_name, client_url, redirect_urls) # 获取客户端凭证 -- Gitee From 2ab1444417b183dd797a40dc177a7826500a61a7 Mon Sep 17 00:00:00 2001 From: ylzhangah <1194926515@qq.com> Date: Fri, 28 Feb 2025 11:11:29 +0800 Subject: [PATCH 10/14] install_eulercopilot.sh --- .../install_eulercopilot.sh | 166 +++++++++--------- 1 file changed, 84 insertions(+), 82 deletions(-) mode change 100644 => 100755 deploy/scripts/8-install-EulerCopilot/install_eulercopilot.sh diff --git a/deploy/scripts/8-install-EulerCopilot/install_eulercopilot.sh b/deploy/scripts/8-install-EulerCopilot/install_eulercopilot.sh old mode 100644 new mode 100755 index 64bad6ec..c06d7a0e --- a/deploy/scripts/8-install-EulerCopilot/install_eulercopilot.sh +++ b/deploy/scripts/8-install-EulerCopilot/install_eulercopilot.sh @@ -14,21 +14,17 @@ PLUGINS_DIR="/home/eulercopilot/semantics" # 获取系统架构 get_architecture() { - local arch - arch=$(uname -m) + local arch=$(uname -m) case "$arch" in - x86_64) - arch="x86" - ;; - aarch64) - arch="arm" - ;; + x86_64) arch="x86" ;; + aarch64) arch="arm" ;; *) echo -e "${RED}错误:不支持的架构 $arch${NC}" >&2 return 1 ;; esac - echo -e "${GREEN}检测到系统架构:$(uname -m)${NC}" >&2 + echo -e "${GREEN}检测到系统架构:${arch} (原始标识: $(uname -m))${NC}" >&2 + echo "$arch" } # 自动检测业务网口 @@ -69,64 +65,74 @@ get_network_ip() { } get_client_info() { - # 调用Python脚本并捕获标准输出和标准错误 - output=$(python3 "${DEPLOY_DIR}/scripts/9-other-script/get_client_id_and_secret.py") - exit_code=$? - - # 检查执行结果 - if [ $exit_code -ne 0 ]; then - echo -e "${RED}获取客户端凭证失败:${output}${NC}" >&2 + # 自动生成客户端名称(格式:client_随机8位字符) + local client_name="client_$(openssl rand -hex 4 | cut -c1-8)" + + # 生成输入应答(使用随机生成的client_name) + { + echo "$client_name" # 客户端名称(使用随机生成值) + echo "" # client_url(回车使用默认) + echo "" # redirect_urls(回车使用默认) + } | python3 "${DEPLOY_DIR}/scripts/9-other-script/get_client_id_and_secret.py" > client_info.tmp + + # 检查Python脚本执行结果 + if [ $? -ne 0 ]; then + echo -e "${RED}错误:Python脚本执行失败${NC}" + cat client_info.tmp + rm -f client_info.tmp exit 1 fi - # 解析输出结果 - client_id=$(echo "$output" | grep "client_id: " | awk '{print $2}') - client_secret=$(echo "$output" | grep "client_secret: " | awk '{print $2}') + # 提取凭证信息(保持原有逻辑) + client_id=$(grep "client_id: " client_info.tmp | awk '{print $8}') + client_secret=$(grep "client_secret: " client_info.tmp | awk '{print $2}') + #rm -f client_info.tmp - # 验证结果 + # 验证结果(保持原有逻辑) if [ -z "$client_id" ] || [ -z "$client_secret" ]; then echo -e "${RED}错误:无法获取有效的客户端凭证${NC}" >&2 exit 1 fi - echo "==============================" - echo "Client ID: $client_id" - echo "Client Secret: $client_secret" - echo "==============================" + # 输出结果(保持原有格式) + echo -e "${GREEN}==============================${NC}" + echo -e "${GREEN}Client ID: ${client_id}${NC}" + echo -e "${GREEN}Client Secret: ${client_secret}${NC}" + echo -e "${GREEN}==============================${NC}" } get_user_input() { - # 处理Copilot域名 - echo -e "${BLUE}请输入 EulerCopilot 域名(直接回车使用默认值 www.eulercopilot.local):${NC}" - read -p "EulerCopilot 的前端域名: " eulercopilot_domain - - if [[ -z "$eulercopilot_domain" ]]; then - eulercopilot_domain="www.eulercopilot.local" - echo -e "${GREEN}使用默认域名:${eulercopilot_domain}${NC}" - else - if ! [[ "${eulercopilot_domain}" =~ ^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+\.[a-zA-Z]{2,}$ ]]; then - echo -e "${RED}错误:输入的EulerCopilot域名格式不正确${NC}" >&2 - exit 1 - fi - echo -e "${GREEN}输入域名:${eulercopilot_domain}${NC}" + # 从环境变量读取或使用默认值 + eulercopilot_domain=${EULERCOPILOT_DOMAIN:-"www.eulercopilot.local"} + authhub_domain=${AUTHHUB_DOMAIN:-"authhub.eulercopilot.local"} + + # 非交互模式直接使用默认值 + if [ -t 0 ]; then # 仅在交互式终端显示提示 + echo -e "${BLUE}请输入 EulerCopilot 域名(默认:$eulercopilot_domain):${NC}" + read -p "> " input_euler + [ -n "$input_euler" ] && eulercopilot_domain=$input_euler + + echo -e "${BLUE}请输入 Authhub 域名(默认:$authhub_domain):${NC}" + read -p "> " input_auth + [ -n "$input_auth" ] && authhub_domain=$input_auth fi - # 处理Authhub域名 - echo -e "${BLUE}请输入 Authhub 的域名配置(直接回车使用默认值 authhub.eulercopilot.local):${NC}" - read -p "Authhub 的前端域名: " authhub_domain - if [[ -z "$authhub_domain" ]]; then - authhub_domain="authhub.eulercopilot.local" - echo -e "${GREEN}使用默认域名:${authhub_domain}${NC}" - else - if ! [[ "${authhub_domain}" =~ ^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+\.[a-zA-Z]{2,}$ ]]; then - echo -e "${RED}错误:输入的AuthHub域名格式不正确${NC}" >&2 - exit 1 - fi - echo -e "${GREEN}输入域名:${authhub_domain}${NC}" + # 统一验证域名格式 + local domain_regex='^([a-zA-Z0-9-]{1,63}\.)+[a-zA-Z]{2,}$' + if ! [[ $eulercopilot_domain =~ $domain_regex ]]; then + echo -e "${RED}错误:EulerCopilot域名格式不正确${NC}" >&2 + exit 1 + fi + if ! [[ $authhub_domain =~ $domain_regex ]]; then + echo -e "${RED}错误:AuthHub域名格式不正确${NC}" >&2 + exit 1 fi + + echo -e "${GREEN}使用配置:" + echo "EulerCopilot域名: $eulercopilot_domain" + echo "Authhub域名: $authhub_domain${NC}" } -# 检查必要目录 check_directories() { echo -e "${BLUE}检查语义接口目录是否存在...${NC}" >&2 if [ -d "${PLUGINS_DIR}" ]; then @@ -141,7 +147,6 @@ check_directories() { fi } -# 安装前检查并删除已有部署 check_and_delete_existing_deployment() { echo -e "${YELLOW}检查是否存在已部署的euler-copilot...${NC}" >&2 if helm list -n euler-copilot --short | grep -q "^euler-copilot$"; then @@ -158,7 +163,6 @@ check_and_delete_existing_deployment() { fi } -# 修改YAML配置文件的方法 modify_yaml() { local host=$1 echo -e "${BLUE}开始修改YAML配置文件...${NC}" >&2 @@ -183,7 +187,6 @@ modify_yaml() { echo -e "${GREEN}YAML文件修改成功!${NC}" >&2 } -# 进入Chart目录的方法 enter_chart_directory() { echo -e "${BLUE}进入Chart目录...${NC}" >&2 cd "${DEPLOY_DIR}/chart/" || { @@ -192,13 +195,12 @@ enter_chart_directory() { } } -# 执行Helm安装的方法 execute_helm_install() { local arch=$1 - echo -e "${BLUE}开始部署EulerCopilot...${NC}" >&2 + echo -e "${BLUE}开始部署EulerCopilot(架构: $arch)...${NC}" >&2 + enter_chart_directory - helm upgrade --install euler-copilot -n euler-copilot ./euler_copilot \ - --set globals.arch="$arch" || { + helm upgrade --install euler-copilot -n euler-copilot ./euler_copilot --set globals.arch=$arch --create-namespace || { echo -e "${RED}Helm 安装 EulerCopilot 失败!${NC}" >&2 exit 1 } @@ -218,68 +220,68 @@ check_pods_status() { local current_time=$(date +%s) local elapsed=$((current_time - start_time)) - # 超时处理逻辑 if [ $elapsed -gt $timeout ]; then - echo -e "${YELLOW}警告:部署超时!请检查以下Pod状态:${NC}" >&2 - kubectl get pods -n euler-copilot + echo -e "${YELLOW}警告:部署超时!请检查以下资源:${NC}" >&2 + kubectl get pods -n euler-copilot -o wide + echo -e "\n${YELLOW}建议检查:${NC}" + echo "1. 查看未就绪Pod的日志: kubectl logs -n euler-copilot " + echo "2. 检查PVC状态: kubectl get pvc -n euler-copilot" + echo "3. 检查Service状态: kubectl get svc -n euler-copilot" return 1 fi - # 检查所有Pod状态 - local not_running - not_running=$(kubectl get pods -n euler-copilot -o jsonpath='{range .items[*]}{.metadata.name} {.status.phase} {.status.conditions[?(@.type=="Ready")].status}{"\n"}{end}' \ + local not_running=$(kubectl get pods -n euler-copilot -o jsonpath='{range .items[*]}{.metadata.name} {.status.phase} {.status.conditions[?(@.type=="Ready")].status}{"\n"}{end}' \ | awk '$2 != "Running" || $3 != "True" {print $1 " " $2}') if [ -z "$not_running" ]; then echo -e "${GREEN}所有Pod已正常运行!${NC}" >&2 - kubectl get pods -n euler-copilot + kubectl get pods -n euler-copilot -o wide return 0 else echo "等待Pod就绪(已等待 ${elapsed} 秒)..." - echo "当前未启动Pod:" + echo "当前未就绪Pod:" echo "$not_running" | awk '{print " - " $1 " (" $2 ")"}' sleep 10 fi done } -# 主函数执行各个步骤 main() { local arch host arch=$(get_architecture) || exit 1 host=$(get_network_ip) || exit 1 - if ! get_client_info; then - echo -e "${RED}获取客户端信息失败${NC}" - exit 1 - fi + get_client_info get_user_input check_directories check_and_delete_existing_deployment modify_yaml "$host" execute_helm_install "$arch" - # Pod状态检查并处理结果 if check_pods_status; then echo -e "${GREEN}所有组件已就绪!${NC}" else - echo -e "${YELLOW}注意:部分组件尚未就绪,可稍后手动检查${NC}" >&2 + echo -e "${YELLOW}注意:部分组件尚未就绪,请根据上述建议进行排查${NC}" >&2 fi # 最终部署信息输出 echo -e "\n${GREEN}==================================================${NC}" echo -e "${GREEN} EulerCopilot 部署完成! ${NC}" echo -e "${GREEN}==================================================${NC}" - echo -e "${YELLOW}EulerCopilot访问地址:\thttps://${eulercopilot_domain}${NC}" - echo -e "${YELLOW}AuthHub管理地址:\thttps://${authhub_domain}${NC}" - echo -e "${YELLOW}插件目录:\t\t${PLUGINS_DIR}${NC}" - echo -e "${YELLOW}Chart目录:\t${DEPLOY_DIR}/chart/${NC}" + echo -e "${YELLOW}访问地址:" + echo -e "EulerCopilot UI:\thttps://${eulercopilot_domain}" + echo -e "AuthHub 管理界面:\thttps://${authhub_domain}" + echo -e "\n${YELLOW}系统信息:" + echo -e "业务网络IP:\t${host}" + echo -e "系统架构:\t$(uname -m) (识别为: ${arch})" + echo -e "插件目录:\t${PLUGINS_DIR}" + echo -e "Chart目录:\t${DEPLOY_DIR}/chart/${NC}" echo - echo -e "${BLUE}温馨提示:" - echo -e "${BLUE}1. 请确保域名已正确解析到集群Ingress地址${NC}" - echo -e "${BLUE}2. 首次拉取RAG镜像可能需要约1-3分钟,Pod会稍后自动启动${NC}" - echo -e "${BLUE}3. 查看实时状态:kubectl get pods -n euler-copilot${NC}" - echo -e "${BLUE}4. 查看镜像:k3s crictl images${NC}" + echo -e "${BLUE}操作指南:" + echo -e "1. 查看集群状态: kubectl get all -n euler-copilot" + echo -e "2. 查看实时日志: kubectl logs -n euler-copilot -f deployment/euler-copilot" + echo -e "3. 添加域名解析(示例):" + echo -e " ${host} ${eulercopilot_domain}" + echo -e " ${host} ${authhub_domain}${NC}" } -# 调用主函数 main -- Gitee From 39073f08af28c06b0963e14b8b891cc83b356c29 Mon Sep 17 00:00:00 2001 From: ylzhangah <1194926515@qq.com> Date: Fri, 28 Feb 2025 11:22:47 +0800 Subject: [PATCH 11/14] update file --- deploy/scripts/1-check-env/check_env.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) mode change 100644 => 100755 deploy/scripts/1-check-env/check_env.sh diff --git a/deploy/scripts/1-check-env/check_env.sh b/deploy/scripts/1-check-env/check_env.sh old mode 100644 new mode 100755 index 930d73ab..8d82a926 --- a/deploy/scripts/1-check-env/check_env.sh +++ b/deploy/scripts/1-check-env/check_env.sh @@ -144,8 +144,8 @@ function check_ram { } function check_disk { - local DISK_THRESHOLD=50000 - local PERCENT_THRESHOLD=85 + local DISK_THRESHOLD=10000 # 修改为10G(单位:MB) + local PERCENT_THRESHOLD=70 read -r available size <<< $(df -m /var/lib | awk 'NR==2{print $4,$2}') echo -e "${COLOR_INFO}[Info] 磁盘可用空间: ${available}MB, 总大小: ${size}MB${COLOR_RESET}" -- Gitee From 103b2bfb9c6ee55b14f88ce8e6b49df93c630647 Mon Sep 17 00:00:00 2001 From: ylzhangah <1194926515@qq.com> Date: Fri, 28 Feb 2025 12:20:11 +0800 Subject: [PATCH 12/14] update file --- .../7-install-authhub/install_authhub.sh | 22 ++++---- .../install_eulercopilot.sh | 53 +++++++++++++++---- .../get_client_id_and_secret.py | 27 ++++++++-- .../install_oidc_eulercopilot.sh | 0 4 files changed, 79 insertions(+), 23 deletions(-) mode change 100644 => 100755 deploy/scripts/9-other-script/install_oidc_eulercopilot.sh diff --git a/deploy/scripts/7-install-authhub/install_authhub.sh b/deploy/scripts/7-install-authhub/install_authhub.sh index 168ca64c..3fca42fa 100755 --- a/deploy/scripts/7-install-authhub/install_authhub.sh +++ b/deploy/scripts/7-install-authhub/install_authhub.sh @@ -106,34 +106,38 @@ helm_install() { } check_pods_status() { - echo -e "${BLUE}==> 等待初始化就绪(30秒)...${NC}" + echo -e "${BLUE}==> 等待初始化就绪(30秒)...${NC}" >&2 sleep 30 local timeout=300 local start_time=$(date +%s) - echo -e "${BLUE}开始监控Authhub Pod状态(总超时时间300秒)...${NC}" + echo -e "${BLUE}开始监控Pod状态(总超时时间300秒)...${NC}" >&2 while true; do local current_time=$(date +%s) local elapsed=$((current_time - start_time)) if [ $elapsed -gt $timeout ]; then - echo -e "${RED}错误:部署超时!${NC}" - kubectl get pods -n euler-copilot --selector=app.kubernetes.io/instance=authhub + echo -e "${YELLOW}警告:部署超时!请检查以下资源:${NC}" >&2 + kubectl get pods -n euler-copilot -o wide + echo -e "\n${YELLOW}建议检查:${NC}" + echo "1. 查看未就绪Pod的日志: kubectl logs -n euler-copilot " + echo "2. 检查PVC状态: kubectl get pvc -n euler-copilot" + echo "3. 检查Service状态: kubectl get svc -n euler-copilot" return 1 fi - # 检查所有属于authhub的Pod状态 - local not_running=$(kubectl get pods -n euler-copilot --selector=app.kubernetes.io/instance=authhub -o jsonpath='{range .items[*]}{.metadata.name} {.status.phase}{"\n"}{end}' | grep -v "Running") + local not_running=$(kubectl get pods -n euler-copilot -o jsonpath='{range .items[*]}{.metadata.name} {.status.phase} {.status.conditions[?(@.type=="Ready")].status}{"\n"}{end}' \ + | awk '$2 != "Running" || $3 != "True" {print $1 " " $2}') if [ -z "$not_running" ]; then - echo -e "${GREEN}所有Authhub Pod已正常运行!${NC}" - kubectl get pods -n euler-copilot --selector=app.kubernetes.io/instance=authhub + echo -e "${GREEN}所有Pod已正常运行!${NC}" >&2 + kubectl get pods -n euler-copilot -o wide return 0 else echo "等待Pod就绪(已等待 ${elapsed} 秒)..." - echo "当前异常Pod:" + echo "当前未就绪Pod:" echo "$not_running" | awk '{print " - " $1 " (" $2 ")"}' sleep 10 fi diff --git a/deploy/scripts/8-install-EulerCopilot/install_eulercopilot.sh b/deploy/scripts/8-install-EulerCopilot/install_eulercopilot.sh index c06d7a0e..ff5d3090 100755 --- a/deploy/scripts/8-install-EulerCopilot/install_eulercopilot.sh +++ b/deploy/scripts/8-install-EulerCopilot/install_eulercopilot.sh @@ -64,6 +64,8 @@ get_network_ip() { echo "$host" } + +# 获取client info get_client_info() { # 自动生成客户端名称(格式:client_随机8位字符) local client_name="client_$(openssl rand -hex 4 | cut -c1-8)" @@ -78,15 +80,12 @@ get_client_info() { # 检查Python脚本执行结果 if [ $? -ne 0 ]; then echo -e "${RED}错误:Python脚本执行失败${NC}" - cat client_info.tmp - rm -f client_info.tmp exit 1 fi # 提取凭证信息(保持原有逻辑) - client_id=$(grep "client_id: " client_info.tmp | awk '{print $8}') + client_id=$(grep "client_id: " client_info.tmp | awk '{print $2}') client_secret=$(grep "client_secret: " client_info.tmp | awk '{print $2}') - #rm -f client_info.tmp # 验证结果(保持原有逻辑) if [ -z "$client_id" ] || [ -z "$client_secret" ]; then @@ -101,7 +100,28 @@ get_client_info() { echo -e "${GREEN}==============================${NC}" } -get_user_input() { + +get_client_info_input() { + + # 非交互模式直接使用默认值 + if [ -t 0 ]; then # 仅在交互式终端显示提示 + echo -e "${BLUE}请输入 Client ID: 域名(端点信息:Client ID): ${NC}" + read -p "> " input_id + [ -n "$input_id" ] && client_id=$input_id + + echo -e "${BLUE}请输入 Client Secret: 域名(端点信息:Client Secret):${NC}" + read -p "> " input_secret + [ -n "$input_secret" ] && client_secret=$input_secret + fi + + # 统一验证域名格式 + echo -e "${GREEN}使用配置:" + echo "Client ID: $client_id" + echo "Client Secret: $client_secret" + +} +# # 处理域名 +get_domain_input() { # 从环境变量读取或使用默认值 eulercopilot_domain=${EULERCOPILOT_DOMAIN:-"www.eulercopilot.local"} authhub_domain=${AUTHHUB_DOMAIN:-"authhub.eulercopilot.local"} @@ -130,9 +150,10 @@ get_user_input() { echo -e "${GREEN}使用配置:" echo "EulerCopilot域名: $eulercopilot_domain" - echo "Authhub域名: $authhub_domain${NC}" + echo "Authhub域名: $authhub_domain" } +# 检查语义接口是否存在 check_directories() { echo -e "${BLUE}检查语义接口目录是否存在...${NC}" >&2 if [ -d "${PLUGINS_DIR}" ]; then @@ -147,6 +168,7 @@ check_directories() { fi } +# 检查是否存在已经部署的EulerCopilot check_and_delete_existing_deployment() { echo -e "${YELLOW}检查是否存在已部署的euler-copilot...${NC}" >&2 if helm list -n euler-copilot --short | grep -q "^euler-copilot$"; then @@ -163,6 +185,7 @@ check_and_delete_existing_deployment() { fi } +# 修改配置文件 modify_yaml() { local host=$1 echo -e "${BLUE}开始修改YAML配置文件...${NC}" >&2 @@ -187,6 +210,7 @@ modify_yaml() { echo -e "${GREEN}YAML文件修改成功!${NC}" >&2 } +# 检查目录 enter_chart_directory() { echo -e "${BLUE}进入Chart目录...${NC}" >&2 cd "${DEPLOY_DIR}/chart/" || { @@ -195,6 +219,7 @@ enter_chart_directory() { } } +# 执行安装 execute_helm_install() { local arch=$1 echo -e "${BLUE}开始部署EulerCopilot(架构: $arch)...${NC}" >&2 @@ -207,6 +232,7 @@ execute_helm_install() { echo -e "${GREEN}Helm安装EulerCopilot成功!${NC}" >&2 } +# 检查pod状态 check_pods_status() { echo -e "${BLUE}==> 等待初始化就绪(30秒)...${NC}" >&2 sleep 30 @@ -250,8 +276,13 @@ main() { local arch host arch=$(get_architecture) || exit 1 host=$(get_network_ip) || exit 1 - get_client_info - get_user_input + if get_client_info; then + echo -e "${GREEN}已成功获取client info${NC}" + else + get_client_info_input + echo -e "${YELLOW}需要手动登录Authhub域名并创建应用,获取client信息${NC}" + fi + get_domain_input check_directories check_and_delete_existing_deployment modify_yaml "$host" @@ -275,11 +306,13 @@ main() { echo -e "系统架构:\t$(uname -m) (识别为: ${arch})" echo -e "插件目录:\t${PLUGINS_DIR}" echo -e "Chart目录:\t${DEPLOY_DIR}/chart/${NC}" - echo + echo -e "" echo -e "${BLUE}操作指南:" echo -e "1. 查看集群状态: kubectl get all -n euler-copilot" echo -e "2. 查看实时日志: kubectl logs -n euler-copilot -f deployment/euler-copilot" - echo -e "3. 添加域名解析(示例):" + echo -e "3. 查看POD状态:kubectl get pods -n euler-copilot" + echo -e "4. 查看数据库并使用base64密码:kubectl edit secret euler-copilot-system -n euler-copilot" + echo -e "5. 添加域名解析(示例):" echo -e " ${host} ${eulercopilot_domain}" echo -e " ${host} ${authhub_domain}${NC}" } diff --git a/deploy/scripts/9-other-script/get_client_id_and_secret.py b/deploy/scripts/9-other-script/get_client_id_and_secret.py index 834f5a25..0a3a3f43 100755 --- a/deploy/scripts/9-other-script/get_client_id_and_secret.py +++ b/deploy/scripts/9-other-script/get_client_id_and_secret.py @@ -99,11 +99,30 @@ def get_client_secret(auth_hub_url, user_token): response = requests.get(url, headers=headers, timeout=10) response.raise_for_status() apps_data = response.json() - - # 确保响应结构正确 + if "data" in apps_data and "applications" in apps_data["data"]: for app in apps_data["data"]["applications"]: - if app.get("client_metadata", {}).get("client_name") == "EulerCopilot": + # 调试输出应用信息(取消注释查看完整数据结构) + print("调试应用信息:", json.dumps(app, indent=2)) # <- 重要调试信息 + + # 处理client_metadata字段的多种类型 + client_metadata = app.get("client_metadata") or {} + if isinstance(client_metadata, str): # 如果是字符串则解析 + try: + client_metadata = json.loads(client_metadata) + except json.JSONDecodeError: + client_metadata = {} + elif not isinstance(client_metadata, dict): # 非字典类型处理 + client_metadata = {} + + # 检查client_name的位置(根据实际情况调整) + target_name = ( + client_metadata.get("client_name") + or app.get("client_name") + or app.get("client_info", {}).get("client_name") + ) + + if target_name == "EulerCopilot": return { "client_id": app["client_info"]["client_id"], "client_secret": app["client_info"]["client_secret"] @@ -113,7 +132,7 @@ def get_client_secret(auth_hub_url, user_token): print("错误:应用列表响应结构异常") print("完整响应:", json.dumps(apps_data, indent=2)) sys.exit(1) - + except requests.exceptions.RequestException as e: print(f"获取客户端凭证失败:{str(e)}") sys.exit(1) diff --git a/deploy/scripts/9-other-script/install_oidc_eulercopilot.sh b/deploy/scripts/9-other-script/install_oidc_eulercopilot.sh old mode 100644 new mode 100755 -- Gitee From ec30ef3d98328f38ac4a33e3bdbf4fd9940b3a9d Mon Sep 17 00:00:00 2001 From: ylzhangah <1194926515@qq.com> Date: Fri, 28 Feb 2025 17:12:06 +0800 Subject: [PATCH 13/14] update file --- .../install_eulercopilot.sh | 20 +- .../get_client_id_and_secret.py | 231 +++++++----------- 2 files changed, 100 insertions(+), 151 deletions(-) diff --git a/deploy/scripts/8-install-EulerCopilot/install_eulercopilot.sh b/deploy/scripts/8-install-EulerCopilot/install_eulercopilot.sh index ff5d3090..cd9457f1 100755 --- a/deploy/scripts/8-install-EulerCopilot/install_eulercopilot.sh +++ b/deploy/scripts/8-install-EulerCopilot/install_eulercopilot.sh @@ -64,9 +64,7 @@ get_network_ip() { echo "$host" } - -# 获取client info -get_client_info() { +get_client_info_auto() { # 自动生成客户端名称(格式:client_随机8位字符) local client_name="client_$(openssl rand -hex 4 | cut -c1-8)" @@ -75,22 +73,23 @@ get_client_info() { echo "$client_name" # 客户端名称(使用随机生成值) echo "" # client_url(回车使用默认) echo "" # redirect_urls(回车使用默认) - } | python3 "${DEPLOY_DIR}/scripts/9-other-script/get_client_id_and_secret.py" > client_info.tmp + } | python3 "${DEPLOY_DIR}/scripts/9-other-script/get_client_id_and_secret.py" > client_info.tmp 2>&1 # 检查Python脚本执行结果 if [ $? -ne 0 ]; then echo -e "${RED}错误:Python脚本执行失败${NC}" - exit 1 + cat client_info.tmp + # rm -f client_info.tmp fi # 提取凭证信息(保持原有逻辑) client_id=$(grep "client_id: " client_info.tmp | awk '{print $2}') client_secret=$(grep "client_secret: " client_info.tmp | awk '{print $2}') + #rm -f client_info.tmp # 验证结果(保持原有逻辑) if [ -z "$client_id" ] || [ -z "$client_secret" ]; then echo -e "${RED}错误:无法获取有效的客户端凭证${NC}" >&2 - exit 1 fi # 输出结果(保持原有格式) @@ -100,8 +99,7 @@ get_client_info() { echo -e "${GREEN}==============================${NC}" } - -get_client_info_input() { +get_client_info_manual() { # 非交互模式直接使用默认值 if [ -t 0 ]; then # 仅在交互式终端显示提示 @@ -276,11 +274,9 @@ main() { local arch host arch=$(get_architecture) || exit 1 host=$(get_network_ip) || exit 1 - if get_client_info; then - echo -e "${GREEN}已成功获取client info${NC}" - else - get_client_info_input + if not get_client_info_auto; then echo -e "${YELLOW}需要手动登录Authhub域名并创建应用,获取client信息${NC}" + get_client_info_manual fi get_domain_input check_directories diff --git a/deploy/scripts/9-other-script/get_client_id_and_secret.py b/deploy/scripts/9-other-script/get_client_id_and_secret.py index 0a3a3f43..19638bec 100755 --- a/deploy/scripts/9-other-script/get_client_id_and_secret.py +++ b/deploy/scripts/9-other-script/get_client_id_and_secret.py @@ -13,168 +13,121 @@ urllib3.disable_warnings() def get_service_cluster_ip(namespace, service_name): cmd = ["kubectl", "get", "service", service_name, "-n", namespace, "-o", "json"] result = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) - # 增强错误处理 + if result.returncode != 0: error_msg = result.stderr.decode().strip() print(f"获取服务信息失败: [命名空间: {namespace}] [服务名: {service_name}]") print(f"Kubectl错误详情: {error_msg}") - # 常见错误提示 if "NotFound" in error_msg: print("→ 请检查:") - print(" 1. 服务是否部署完成(kubectl get pods -n {namespace})") + print(f" 1. 服务是否部署完成(kubectl get pods -n {namespace})") print(" 2. 服务名称是否拼写正确") print(" 3. 是否在正确的Kubernetes上下文环境中") - - # 解析JSON输出 + sys.exit(1) + service_info = json.loads(result.stdout.decode()) - - # 从解析后的JSON中获取Cluster IP - cluster_ip = service_info['spec'].get('clusterIP', 'No Cluster IP found') - return cluster_ip + return service_info['spec'].get('clusterIP', 'No Cluster IP found') + def get_user_token(auth_hub_url, username="administrator", password="changeme"): url = auth_hub_url + "/oauth2/manager-login" - payload = { - "password": password, - "username": username, - } - headers = { - "Content-Type": "application/json", - } - try: - response = requests.post(url, json=payload, headers=headers, verify=False, timeout=10) - response.raise_for_status() # 触发HTTPError异常如果状态码不是2xx - response_data = response.json() + response = requests.post( + url, + json={"password": password, "username": username}, + headers={"Content-Type": "application/json"}, + verify=False, + timeout=10 + ) + response.raise_for_status() + return response.json()["data"]["user_token"] + + +def register_app(auth_hub_url, user_token, client_name, client_url, redirect_urls): + requests.post( + auth_hub_url + "/oauth2/applications/register", + json={ + "client_name": client_name, + "client_uri": client_url, + "redirect_uris": redirect_urls, + "skip_authorization": True, + "scope": ["email", "phone", "username", "openid", "offline_access"], + "grant_types": ["authorization_code"], + "response_types": ["code"], + "token_endpoint_auth_method": "none" + }, + headers={"Authorization": user_token, "Content-Type": "application/json"} + ) + + +def get_client_secret(auth_hub_url, user_token, target_client_name): + response = requests.get( + auth_hub_url + "/oauth2/applications", + headers={"Authorization": user_token, "Content-Type": "application/json"}, + timeout=10 + ) + response.raise_for_status() + apps_data = response.json() + + for app in apps_data["data"]["applications"]: + # 处理 client_metadata 字段 + client_metadata = app.get("client_metadata") or {} + if isinstance(client_metadata, str): + try: + client_metadata = json.loads(client_metadata) + except json.JSONDecodeError: + client_metadata = {} + + # 优先从 client_metadata 获取名称 + candidate_names = [ + client_metadata.get("client_name"), + app.get("client_name"), + app.get("client_info", {}).get("client_name") + ] - # 检查响应结构是否包含data.user_token - if "data" in response_data and "user_token" in response_data["data"]: - return response_data["data"]["user_token"] - else: - print("错误:响应中缺少预期的数据结构") - print("完整响应内容:", json.dumps(response_data, indent=2)) - sys.exit(1) - - except requests.exceptions.HTTPError as e: - print(f"登录请求失败,HTTP状态码:{response.status_code}") - print("响应内容:", response.text) - sys.exit(1) - except json.JSONDecodeError: - print("错误:无法解析响应为JSON") - print("原始响应:", response.text) - sys.exit(1) - except Exception as e: - print(f"发生未知错误:{str(e)}") - sys.exit(1) + # 调试输出关键信息 + print(f"\n匹配进度 | 候选名称: {candidate_names} | 目标名称: {target_client_name}") + + # 不区分大小写匹配 + if any(str(name).lower() == target_client_name.lower() for name in candidate_names if name): + return { + "client_id": app["client_info"]["client_id"], + "client_secret": app["client_info"]["client_secret"] + } + + raise ValueError(f"未找到匹配应用,请检查 client_name 是否准确(尝试使用全小写名称)") -def register_app(auth_hub_url, user_token, client_name, client_url, redierct_urls): - url = auth_hub_url + "/oauth2/applications/register" - payload = { - "client_name":client_name, - "client_uri":client_url, - "redirect_uris":redierct_urls, - "skip_authorization":True, - "register_callback_uris":[], - "logout_callback_uris":[], - "scope":["email","phone","username","openid","offline_access"], - "grant_types":["authorization_code"], - "response_types":["code"], - "token_endpoint_auth_method":"none" - } - headers = { - "Authorization": user_token, - "Content-Type": "application/json" - } - response = requests.post(url, json=payload, headers=headers) - return response.json() - -def get_client_secret(auth_hub_url, user_token): - url = auth_hub_url + "/oauth2/applications" - headers = { - "Authorization": user_token, - "Content-Type": "application/json" - } - try: - response = requests.get(url, headers=headers, timeout=10) - response.raise_for_status() - apps_data = response.json() - - if "data" in apps_data and "applications" in apps_data["data"]: - for app in apps_data["data"]["applications"]: - # 调试输出应用信息(取消注释查看完整数据结构) - print("调试应用信息:", json.dumps(app, indent=2)) # <- 重要调试信息 - - # 处理client_metadata字段的多种类型 - client_metadata = app.get("client_metadata") or {} - if isinstance(client_metadata, str): # 如果是字符串则解析 - try: - client_metadata = json.loads(client_metadata) - except json.JSONDecodeError: - client_metadata = {} - elif not isinstance(client_metadata, dict): # 非字典类型处理 - client_metadata = {} - - # 检查client_name的位置(根据实际情况调整) - target_name = ( - client_metadata.get("client_name") - or app.get("client_name") - or app.get("client_info", {}).get("client_name") - ) - - if target_name == "EulerCopilot": - return { - "client_id": app["client_info"]["client_id"], - "client_secret": app["client_info"]["client_secret"] - } - return {"error": "Application not found"} - else: - print("错误:应用列表响应结构异常") - print("完整响应:", json.dumps(apps_data, indent=2)) - sys.exit(1) - - except requests.exceptions.RequestException as e: - print(f"获取客户端凭证失败:{str(e)}") - sys.exit(1) - if __name__ == "__main__": + # 获取服务信息 namespace = "euler-copilot" service_name = "authhub-web-service" - print(f"正在查询服务信息: [命名空间: {namespace}] [服务名: {service_name}]") cluster_ip = get_service_cluster_ip(namespace, service_name) + auth_hub_url = f"http://{cluster_ip}:8000" - # 增加更明确的错误提示 - if not cluster_ip or cluster_ip == 'No Cluster IP found': - print(f"无法获取ClusterIP,可能原因:") - print("1. 服务类型不是ClusterIP(可能是NodePort/LoadBalancer)") - print("2. 服务尚未分配IP(查看状态: kubectl get svc/{service_name} -n {namespace} -w)") - sys.exit(1) - - print("\n请填写应用注册信息(直接回车使用默认值)") - # 注册应用 - client_name = input(f"请输入 client_name (默认:EulerCopilot):").strip() or "EulerCopilot" - client_url = input(f"请输入 client_url (默认:https://www.eulercopilot.local):").strip() or "https://www.eulercopilot.local" - + # 用户输入 + print("\n请填写应用注册信息(直接回车使用默认值)") + client_name = input("请输入 client_name (默认:EulerCopilot):").strip() or "EulerCopilot" + client_url = input("请输入 client_url (默认:https://www.eulercopilot.local):").strip() or "https://www.eulercopilot.local" + redirect_input = input( - f"请输入 redirect_urls (逗号分隔,默认:https://www.eulercopilot.local/api/auth/login):" -).strip() - if redirect_input: - redirect_urls = [url.strip() for url in redirect_input.split(",")] - else: - redirect_urls = ["https://www.eulercopilot.local/api/auth/login"] + "请输入 redirect_urls (逗号分隔,默认:https://www.eulercopilot.local/api/auth/login):" + ).strip() + redirect_urls = [url.strip() for url in redirect_input.split(",")] if redirect_input else [ + "https://www.eulercopilot.local/api/auth/login" + ] - auth_hub_url = f"http://{cluster_ip}:8000" - user_token = get_user_token(auth_hub_url) - - # 注册应用 - register_app(auth_hub_url, user_token, client_name, client_url, redirect_urls) + # 认证流程 + try: + user_token = get_user_token(auth_hub_url) + register_app(auth_hub_url, user_token, client_name, client_url, redirect_urls) + client_info = get_client_secret(auth_hub_url, user_token, client_name) + + print("\n认证信息获取成功:") + print(f"client_id: {client_info['client_id']}") + print(f"client_secret: {client_info['client_secret']}") - # 获取客户端凭证 - client_info = get_client_secret(auth_hub_url, user_token) # 传递user_token - if "error" in client_info: - print(client_info["error"]) + except Exception as e: + print(f"\n错误: {str(e)}") sys.exit(1) - - print(f"client_id: {client_info['client_id']}") - print(f"client_secret: {client_info['client_secret']}") -- Gitee From 48db1e390d977f7b96aa92be07c25f15bf66c453 Mon Sep 17 00:00:00 2001 From: ylzhangah <1194926515@qq.com> Date: Fri, 28 Feb 2025 17:26:59 +0800 Subject: [PATCH 14/14] update file --- deploy/scripts/8-install-EulerCopilot/install_eulercopilot.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/deploy/scripts/8-install-EulerCopilot/install_eulercopilot.sh b/deploy/scripts/8-install-EulerCopilot/install_eulercopilot.sh index cd9457f1..5d18df19 100755 --- a/deploy/scripts/8-install-EulerCopilot/install_eulercopilot.sh +++ b/deploy/scripts/8-install-EulerCopilot/install_eulercopilot.sh @@ -79,13 +79,12 @@ get_client_info_auto() { if [ $? -ne 0 ]; then echo -e "${RED}错误:Python脚本执行失败${NC}" cat client_info.tmp - # rm -f client_info.tmp fi # 提取凭证信息(保持原有逻辑) client_id=$(grep "client_id: " client_info.tmp | awk '{print $2}') client_secret=$(grep "client_secret: " client_info.tmp | awk '{print $2}') - #rm -f client_info.tmp + rm -f client_info.tmp # 验证结果(保持原有逻辑) if [ -z "$client_id" ] || [ -z "$client_secret" ]; then -- Gitee