From 18fa32a915d1cbce056136f99fb05a19c635cd31 Mon Sep 17 00:00:00 2001 From: Zpekii Date: Sat, 10 Jan 2026 20:27:15 +0800 Subject: [PATCH] fix: update configuration files to use YAML format and adjust references in deployment --- .gitignore | 3 ++- .linux-config-template.json | 8 -------- .linux-config-template.yaml | 4 ++++ .vscode/launch.json | 1 - deployment.yaml | 18 +++++++----------- main.go | 2 +- 6 files changed, 14 insertions(+), 22 deletions(-) delete mode 100644 .linux-config-template.json create mode 100644 .linux-config-template.yaml diff --git a/.gitignore b/.gitignore index 7b08788..9bdb3c4 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ *.prof certs/* helloapp -.*-config.json \ No newline at end of file +.*-config.json +.*-config.yaml \ No newline at end of file diff --git a/.linux-config-template.json b/.linux-config-template.json deleted file mode 100644 index 70c0730..0000000 --- a/.linux-config-template.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "server": { - "port": 8800 - }, - "certs": { - "testKeyPath": "./certs/test.key" - } -} \ No newline at end of file diff --git a/.linux-config-template.yaml b/.linux-config-template.yaml new file mode 100644 index 0000000..b44ca23 --- /dev/null +++ b/.linux-config-template.yaml @@ -0,0 +1,4 @@ +server: + port: 8800 +certs: + testKeyPath: ./certs/test.key # 需要和 deployment.yaml 中的路径保持一致, 并且 certs 目录需要挂载 secret diff --git a/.vscode/launch.json b/.vscode/launch.json index f706a87..4579ceb 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -11,7 +11,6 @@ "request": "launch", "mode": "auto", "program": "${workspaceFolder}", - "args": ["-f", ".linux-config.json"] } ] } \ No newline at end of file diff --git a/deployment.yaml b/deployment.yaml index c6d936b..784abf6 100644 --- a/deployment.yaml +++ b/deployment.yaml @@ -43,9 +43,9 @@ spec: - name: config-volume mountPath: /config - name: helloapp-test-key - mountPath: /certs + mountPath: /certs/test.key command: ["/helloapp"] - args: ["-f", "/config/.linux-config.json"] + args: ["-f", "/config/.linux-config.yaml"] volumes: - name: config-volume configMap: @@ -60,12 +60,8 @@ metadata: name: k8s-example-config namespace: helloapp data: - .linux-config.json: | - { - "server": { - "port": 8800 - }, - "certs": { - "testKeyPath": "./certs/test.key" - } - } + .linux-config.yaml: | + server: + port: 8800 + certs: + testKeyPath: /certs/test.key \ No newline at end of file diff --git a/main.go b/main.go index 6a1c41a..4502cb3 100644 --- a/main.go +++ b/main.go @@ -17,7 +17,7 @@ var ( func main() { // read -f parameter (config file) - configPath := flag.String("f", ".linux-config.json", "config file") + configPath := flag.String("f", ".linux-config.yaml", "config file") flag.Parse() conf.Init(*configPath)