fix: update configuration files to use YAML format and adjust references in deployment

This commit is contained in:
2026-01-10 20:27:15 +08:00
parent 9865f7fa7a
commit 18fa32a915
6 changed files with 14 additions and 22 deletions

1
.gitignore vendored
View File

@@ -3,3 +3,4 @@
certs/*
helloapp
.*-config.json
.*-config.yaml

View File

@@ -1,8 +0,0 @@
{
"server": {
"port": 8800
},
"certs": {
"testKeyPath": "./certs/test.key"
}
}

View File

@@ -0,0 +1,4 @@
server:
port: 8800
certs:
testKeyPath: ./certs/test.key # 需要和 deployment.yaml 中的路径保持一致, 并且 certs 目录需要挂载 secret

1
.vscode/launch.json vendored
View File

@@ -11,7 +11,6 @@
"request": "launch",
"mode": "auto",
"program": "${workspaceFolder}",
"args": ["-f", ".linux-config.json"]
}
]
}

View File

@@ -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

View File

@@ -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)