I have this Spring Boot application which need some files, directories from my host and in kubernetes runtime to resolve those placeholders.
Now, i tried to mount volume directly in the pod from my host directory location, but is monted empty dir
I also tried to mount a configMap object with the path of that directory in my volume mounted, but when i go inside the pod, directory/file name is there, but when i want to see what is inside it throws: Not a directory or file
Is there a way to achive what i want to do? To mount some files/directories in my pod container and make them availlable so can resolve Placeholders at runtime?
Placeholders aren't resolving usint these approches, so.. i'm asking for an advice, some help of what to do:
ConfigMap object:
apiVersion: v1
kind: ConfigMap
metadata:
name: gateway-configmap
data:
PLACEHOLDER_VALUE: /root/my-projectDirectory
PLACEHOLDER_LOGS: /root/my-projectDirectory/logs
PV AND PVC:
apiVersion: v1
kind: PersistentVolume
metadata:
name: gateway-pv
spec:
capacity:
storage: 1Gi
accessModes:
- ReadWriteOnce
hostPath:
path: /root/my-projectDirectory
type: Directory
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: gateway-pvc
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
---
apiVersion: v1
kind: PersistentVolume
metadata:
name: gateway-pv-logs
spec:
capacity:
storage: 1Gi
accessModes:
- ReadWriteOnce
hostPath:
path: /root/my-projectDirectory/logs
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: gateway-pv-logs-pvc
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
Deployment and Service of my Spring Boot app:
apiVersion: apps/v1
kind: Deployment
metadata:
name: gateway-deployment
spec:
replicas: 1
selector:
matchLabels:
app: gateway
template:
metadata:
labels:
app: gateway
spec:
containers:
- name: gateway-pod
image: gateway
imagePullPolicy: IfNotPresent
env:
- name: PLACEHOLDER_VALUE
value: 'PLACEHOLDER_VALUE'
- name: PLACEHOLDER_LOGS
value: 'PLACEHOLDER_LOGS'
volumeMounts:
- mountPath: /PLACEHOLDER_LOGS
name: gateway-volume
- mountPath: /PLACEHOLDER_VALUE
name: gateway-pv-logs
volumes:
- name: gateway-volume
persistentVolumeClaim:
claimName: gateway-pvc
- name: gateway-pv-logs
persistentVolumeClaim:
claimName: gateway-pv-logs-pvc
---
apiVersion: v1
kind: Service
metadata:
name: gateway-service
spec:
selector:
app: gateway
ports:
- protocol: 'TCP'
port: 9000
targetPort: 9000
type: NodePort