Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

268
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda