debugkubernetesMinor
Why am I getting error trying to mount a directory onto a file?
Viewed 0 times
whyerrordirectoryfiletryinggettingontomount
Problem
I have this prometheus deployment manifest file: to create prometheus deployment
but this error that "trying to mount a directory onto a file "
```
Events:
Type
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: prometheus
namespace: monitoring
labels:
app: prometheus
spec:
replicas: 1
strategy:
rollingUpdate:
maxSurge: 1
maxUnavailable: 1
type: RollingUpdate
selector:
matchLabels:
app: prometheus
template:
metadata:
labels:
app: prometheus
annotations:
prometheus.io/scrape: "true"
prometheus.io/port: "9090"
spec:
nodeSelector:
boardType: aarch64
initContainers:
- name: prometheus-data-permission-setup
image: busybox
command: ["/bin/chmod","-R","777", "/data"]
volumeMounts:
- name: prometheus-data
mountPath: /data
containers:
- name: prometheus
image: rycus86/prometheus:latest
imagePullPolicy: IfNotPresent
args:
- '--storage.tsdb.path=/data'
- '--config.file=/etc/prometheus/prometheus.yml'
command:
- /bin/prometheus
ports:
- name: web
containerPort: 9090
volumeMounts:
- name: config-volume
mountPath: /etc/prometheus/prometheus.yml
subPath: prometheus.yml
- name: prometheus-data
mountPath: /data
readOnly: false
resources:
requests:
cpu: "250m"
ephemeral-storage: "4Gi"
limits:
memory: "200Mi"
cpu: "500m"
ephemeral-storage: "20Gi"
restartPolicy: Always
securityContext: {}
terminationGracePeriodSeconds: 30
volumes:
- name: config-volume
configMap:
name: prometheus-config
- name: prometheus-data
hostPath:
path: /data
type: Directory
serviceAccountName: prometheusbut this error that "trying to mount a directory onto a file "
```
Events:
Type
Solution
volumeMount based on configMap actually creates the files for the data keys. You don't need the filename in the mountPath or the subPath`$ cat
Ref:
- https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-configmap/
Context
StackExchange DevOps Q#13970, answer score: 2
Revisions (0)
No revisions yet.