Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

267
Views
Kubernetes: mounted file is a... directory?

I've created a secret and when I deploy an application intended to read the secret, the application complains that the secret is a directory.

What am I doing wrong? The file is intended to be read as, well, a file.

kc logs <pod>
(error) /var/config/my-file.yaml: is a directory.

The secret is created like this.

kubectl create secret generic my-file.yaml --from-file=my-file.yaml

And here is the deployment.

apiVersion: apps/v1
kind: Deployment
metadata:
  name: a-name
spec:
  replicas: 1
  selector:
    matchLabels:
      name: a-name
  template:
    metadata:
      labels:
        name: a-name
    spec:
      volumes:
        - name: my-secret-volume
          secret:
            secretName: my-file.yaml
      containers:
        - name: a-name
          image: test/image:v1.0.0
          volumeMounts:
            - name: my-secret-volume
              mountPath: /var/config/my-file.yaml
              subPath: my-file.yaml
              readOnly: true
          ports:
            - containerPort: 1234
            - containerPort: 5678
          imagePullPolicy: Always
          args:
            - run
            - --config
            - /var/config/my-file.yaml 
  revisionHistoryLimit: 1

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

You are using subPath in the volume mount section. According to Kubernetes volume doc, when you need same volume for different purpose in the same pod then you should use subPath.

But here you are using the volume for only single use. But I'll give you both yaml file with subPath and without subPath.

With SubPath

          volumeMounts:
            - name: my-secret-volume
              mountPath: /var/config
              subPath: config
              readOnly: true

WithOut SubPath

          volumeMounts:
            - name: my-secret-volume
              mountPath: /var/config
              readOnly: true

Rest of the manifest file will be same in both cases.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!