在wwwroot / config / config.json中具有外部配置的ASP.NET Core SPA
config.json的内容
{
"termsAndConditionsLink": "https://some-dev-url.with/legal/terms/"
}
当文件未被ConfigMap覆盖时,它可以正常工作,并且我可以获取文件的全部内容。
curl https://dev-app.com/config/config.json
{
"termsAndConditionsLink": "https://some-dev-url.with/legal/terms/"
}
使用Volume将ConfigMap数据安装到此路径时,不会完全返回。
curl https://dev-app.com/config/config.json
{
"termsAndCon
该文件位于pod中:
pwd
/app/wwwroot/config
ls -la
total 12
drwxrwxrwx 3 root root 4096 Nov 20 08:48 .
drwxr-xr-x 6 root root 4096 Nov 20 08:46 ..
drwxr-xr-x 2 root root 4096 Nov 20 08:48 ..2018_11_20_08_48_02.390652870
lrwxrwxrwx 1 root root 31 Nov 20 08:48 ..data -> ..2018_11_20_08_48_02.390652870
lrwxrwxrwx 1 root root 18 Nov 20 08:48 config.json -> ..data/config.json
cat config.json
{
"termsAndConditionsLink": "https://some-dev-url.with/legal/terms/"
}
ConfigMap.yaml
kind: ConfigMap
apiVersion: v1
metadata:
name: my-config
data:
config.json: |-
{
"termsAndConditionsLink": "https://some-dev-url.with/legal/terms/"
}
Deployment.yaml
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: my-app
labels:
...
spec:
template:
metadata:
labels:
...
spec:
containers:
...
volumeMounts:
- name: my-volume
mountPath: /app/wwwroot/config
volumes:
- name: my-volume
configMap:
name: my-config
答案 0 :(得分:-1)
从ConfigMap在该位置装载卷时,您是否表示/app/wwwroot/config
目录中的所有其他文件都消失了?
您是否尝试过projected卷:
volumes:
- name: my-volume
projected:
sources:
- configMap:
name: my-config
编辑:对于那些可能遇到此类问题并且不阅读帖子下方消息的人-与@edbighead交换消息后,另一个建议是在其中使用subPath
部署以使config目录可写,因为ConfigMap卷挂载是只读的:
mountPath: /app/wwwroot/config/config.json
subPath: config.json
这显然解决了问题。