Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

253
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda