diff --git a/deploy/chart/authhub/configs/backend/copy-config.yml b/deploy/chart/authhub/configs/backend/copy-config.yml index 43d4e14c8373c8f0fcb6654d4f5b89fe1eba16e9..25f33b9b245d27a9689c09b9db1ec11357857902 100644 --- a/deploy/chart/authhub/configs/backend/copy-config.yml +++ b/deploy/chart/authhub/configs/backend/copy-config.yml @@ -1,6 +1,6 @@ copy: - - from: /config/aops-config.yaml - to: /config-rw/aops-config.yaml + - from: /config/aops-config.yml + to: /config-rw/aops-config.yml mode: uid: 0 gid: 0 @@ -8,8 +8,8 @@ copy: secrets: - /db-secrets - /authhub-secrets - - from: /config/conf.d/authhub.yaml - to: /config-rw/conf.d/authhub.yaml + - from: /config/conf.d/authhub.yml + to: /config-rw/conf.d/authhub.yml mode: uid: 0 gid: 0 diff --git a/deploy/chart/authhub/templates/backend/authhub-backend.yaml b/deploy/chart/authhub/templates/backend/authhub-backend.yaml index 8cfc36faa7dfdff964083c6f82c255f65474bd45..953ce1126353033952b6b7eb0ecb30798f632e47 100644 --- a/deploy/chart/authhub/templates/backend/authhub-backend.yaml +++ b/deploy/chart/authhub/templates/backend/authhub-backend.yaml @@ -60,25 +60,22 @@ spec: limits: {{ toYaml .Values.authhub.backend.resourceLimits | nindent 14 }} initContainers: - - name: authhub-backend-copy-secret + - name: authback-copy 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 }} + command: + - python3 + - ./main.py + - --config + - /config/copy-config.yml + - --copy volumeMounts: - mountPath: /db-secrets name: euler-copilot-database-vl - mountPath: /authhub-secrets name: authhub-secret-vl - - mountPath: /config/aops-config.yml - name: authhub-config - subPath: aops-config.yml - - mountPath: /config/conf.d/authhub.yml - name: authhub-config - subPath: authhub.yml - mountPath: /config-rw name: authhub-shared - - mountPath: /app/config.yaml - name: authhub-config - subPath: copy-config.yml volumes: - name: authhub-shared emptyDir: @@ -86,6 +83,13 @@ spec: - name: authhub-config configMap: name: authhub-backend-config + items: + - key: aops-config.yml + path: aops-config.yml + - key: authhub.yml + path: conf.d/authhub.yml + - key: copy-config.yml + path: copy-config.yml - name: authhub-secret-vl secret: secretName: authhub-secret diff --git a/deploy/secret_helper/Dockerfile b/deploy/secret_helper/Dockerfile index ca8421e351ae14edb2efc4adccda0dadd17bc1d1..2fe4fe7f605a79e019eb373eccade7cf1e7014b9 100644 --- a/deploy/secret_helper/Dockerfile +++ b/deploy/secret_helper/Dockerfile @@ -3,7 +3,10 @@ RUN mkdir /app && \ mkdir /secrets WORKDIR /app COPY . . -RUN yum update -y && \ +RUN sed -i 's|repo.openeuler.org|mirrors.nju.edu.cn/openeuler|g' /etc/yum.repos.d/openEuler.repo && \ + sed -i '/metalink/d' /etc/yum.repos.d/openEuler.repo && \ + sed -i '/metadata_expire/d' /etc/yum.repos.d/openEuler.repo && \ + yum update -y && \ yum install python3 python3-pip -y && \ yum clean all && \ pip3 install --no-cache-dir -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple diff --git a/deploy/secret_helper/file_copy.py b/deploy/secret_helper/file_copy.py index cd17eac149e8a46013e07bbebfc94e99cf7060db..ed346645711b3c1f03d5904bb72dd3e9bad3c956 100644 --- a/deploy/secret_helper/file_copy.py +++ b/deploy/secret_helper/file_copy.py @@ -28,6 +28,8 @@ def copy_file(file: Path, out_path: Path, secrets: dict[str, str]) -> None: if secrets: for key, value in secrets.items(): data = data.replace(r"${" + key + "}", value) + # 确保父文件夹存在 + out_path.parent.mkdir(parents=True, exist_ok=True) with out_path.open("w", encoding="utf-8") as f: f.write(data) diff --git a/deploy/secret_helper/main.py b/deploy/secret_helper/main.py index 602573e4fb8f9e468e72e02ee8a27f54b9025795..a810ea5a57d96f840e772b974eee077956a55cce 100644 --- a/deploy/secret_helper/main.py +++ b/deploy/secret_helper/main.py @@ -33,7 +33,8 @@ if __name__ == "__main__": config = yaml.safe_load(f) for copy_config in config["copy"]: - copy(copy_config["from"], copy_config["to"], copy_config["mode"], copy_config["secrets"]) + secrets = copy_config.get("secrets", []) + copy(copy_config["from"], copy_config["to"], copy_config["mode"], secrets) sys.exit(0)