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

248
Vistas
Share local directory with Kind Kubernetes Cluster using hostpath

I want to share my non-empty local directory with kind cluster.

Based on answer here: How to reference a local volume in Kind (kubernetes in docker)

I tried few variations of the following:

Kind Cluster yaml:

kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
  extraMounts:
  - hostPath: /Users/xyz/documents/k8_automation/data/manual/
    containerPath: /host_manual
  extraPortMappings:
  - containerPort: 30000
    hostPort: 10000

Pod yaml:

apiVersion: v1
kind: Pod
metadata:
  name: manual 
spec:
  serviceAccountName: manual-sa
  containers:
  - name: tools 
    image: tools:latest 
    imagePullPolicy: Never
    command:
    - bash
    tty: true
    volumeMounts:
    - mountPath: /home/jenkins/agent/data
      name: data
  volumes:
  - name: data
    hostPath: 
      path: /host_manual
      type: Directory
---

I see that the directory /home/jenkins/agent/data does exist when the pod gets created. However, the folder is empty.

kinds documentation here: https://kind.sigs.k8s.io/docs/user/configuration/#extra-mounts

It should be the case that whatever is in the local machine at hostpath (/Users/xyz/documents/k8_automation/data/manual/) in extraMounts in the cluster yaml be available to the node at containerPath (/host_manual), which then gets mounted at container volume mounthPath (/home/jenkins/agent/data).

I should add that even if I change the hostPath in the cluster yaml file to a non-existent folder, the empty "data" folder still gets mounted in the container, so I think it's the connection from my local to kind cluster that's the issue.

  1. Why am I not getting the contents of /Users/xyz/documents/k8_automation/data/manual/ with it's many files also available at /home/jenkins/agent/data in the container?
  2. How can I fix this?
  3. Any alternatives if there is no fix?
over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Turns out these yaml configuration was just fine.

The reason the directory was not showing up in the container was related with docker settings. And because "kind is a tool for running local Kubernetes clusters using Docker container “nodes”", it matters.

It seems docker restricts resource sharing and allows only specific directories to be bind mounted into Docker containers by default. Once I added the specific directory I wanted to show up in the container to the list of directories under Preferences -> Resources -> File sharing, it worked!

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