I have a JSON file mounted by configMap:
apiVersion: v1
data:
config.json: |
{{- toPrettyJson $.Values.serviceConfig | nindent 4 }}
kind: ConfigMap
metadata:
name: service-config
namespace: {{ .Release.Namespace }}
In deployment.yaml, it's:
spec:
... ...
volumes:
- name: config-vol
configMap:
name: service-config
containers:
- name: {{ .Chart.Name }}
... ...
volumeMounts:
- mountPath: /src/config
name: config-vol
My application needs to get that JSON file and use it, but how to retreive it by Go code. I searched it on the Internet but found nothing. If it's not able to retrieve, how can we use it? It's my first time touching the configMap, and I'm sorry if it's a dumb question. Thank you in advance!
Your deployment.yaml
is pointing to the wrong configmap name first.
you can use something like
apiVersion: v1
kind: ConfigMap
metadata:
name: command
data:
command.json: |
#!/bin/bash
echo "running sh script on node..!"
---
- name: command
image: IMAGE
imagePullPolicy: IfNotPresent
volumeMounts:
- name: commandfile
mountPath: /test/command.json <---------------Path where you want to mount or add it and used by application from there as it is
subPath: command.json
restartPolicy: OnFailure
volumes:
- name: commandfile
configMap:
name: command <------------------ configmap name should match
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.