I'm struggling to create two JSON config files in the main application directory (/publish) while leaving all other files in that directory intact. I tried the following:
apiVersion: apps/v1
kind: Deployment
metadata:
name: myapp
labels:
app: myapp
spec:
replicas: 1
selector:
matchLabels:
app: myapp
template:
metadata:
labels:
app: myapp
spec:
containers:
- name: myapp
image: url_to_image
ports:
- containerPort: 1234
volumeMounts:
- name: config-files
mountPath: "/publish"
volumes:
- name: config-files
configMap:
name: myapp
---
apiVersion: v1
kind: Service
metadata:
name: myapp
spec:
ports:
- port: 80
targetPort: 1234
protocol: TCP
type: NodePort
selector:
app: myapp
---
kind: ConfigMap
apiVersion: v1
metadata:
name: myapp
labels:
app: myapp
data:
appsettings.json: |
{ some JSON }
sharedsettings.json: |
{ more JSON }
Two config files (appsettings.json and sharedsettings.json) are correctly created but unfortunately all other files in /publish are deleted in the process.
What would be the best approach?
Ok, found a solution but it's not very elegant. Any better solutions out there?