这是我的webpack文件的一部分。
output: {
filename: "[name].[chunkhash:8].js",
path: path.resolve(__dirname, "../../dist/static/"),
publicPath: `${**process.env.STATIC_URL**}/xxxxxxx/static/`
}
我想在这里访问在kubernetes的configmap中设置的环境变量。有办法吗?
答案 0 :(得分:0)
有一个专用的envFrom:
field in the PodSpec,它允许将ConfigMap密钥作为环境变量注入(假设它们是“环境安全的”,因此没有整数,布尔值或非字符串值):
containers:
- image: whatever
envFrom:
configMapRef:
name: your-configmap-name-goes-here
或者,如果您只想要一个键,则env:
项目本身中也有一个类似的valueFrom:
field:
containers:
- image: whatever
env:
- name: STATIC_URL
valueFrom:
configMapKeyRef:
name: your-configmap-name-goes-here
key: whatever-key-holds-the-static-url-value