[英]Reading Value form ConfigMap that are mounted as file in Kubernetes cluster JAVA
Here is my ConfigMap这是我的配置图
apiVersion: v1
data:
application_config.properties: |-
id= abc
mode= abc
username= abc
endpoint: abc
url= abc
id= abc
kind: ConfigMap
metadata:
name: yml-config
and here is my deployment这是我的部署
---
apiVersion: apps/v1
kind: Deployment
metadata:
....
spec:
....
template:
metadata:
labels:
app: demo
name: demo
spec:
containers:
- image: abc:1.0
imagePullPolicy: Always
name: demo
resources:
limits:
cpu: 500m
memory: 650Mi
requests:
cpu: 500m
memory: 650Mi
volumeMounts:
- mountPath: /opt/config/application_config.properties
subPath: application_config.properties
name: application-config-volume
........
volumes:
- name: application-config-volume
configMap:
name: yml-config
What I need is -> I wish to mount my configmap as a single properties file in the mentioned location and just wish to read the values in core java by doing some I/O usage.我需要的是->我希望将我的配置映射作为单个属性文件安装在上述位置,并且只想通过使用一些 I/O 来读取核心 java 中的值。
But I tried many ways used subpath, items and keys tag too.但我也尝试了很多使用子路径、项目和键标签的方法。 But I am only getting File not found exception.但我只得到 File not found 异常。
(point to note - I dont have the access to look into the container which is creating some issue ) It would be great if someone could help me along with the java code showing how to fetch the value based on the mount path. (请注意 - 我无权查看正在创建一些问题的容器)如果有人可以帮助我以及 java 代码显示如何根据安装路径获取值,那就太好了。 Which I may try.我可以试试。 Thanks in advance.提前致谢。
You can use any function or command that is used to read file at that location您可以使用任何 function 或用于在该位置读取文件的命令
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.