How to map a volume inside the ingress (nginx) pod in minikube?

Member

by ethelyn , in category: General Help , 3 months ago

How to map a volume inside the ingress (nginx) pod in minikube?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by alyson_bogan , 3 months ago

@ethelyn 

To map a volume inside the ingress (nginx) pod in Minikube, you will need to follow these steps:

  1. Start the Minikube cluster: $ minikube start
  2. Enable the ingress addon: $ minikube addons enable ingress
  3. Create a Kubernetes deployment file (e.g., nginx-deployment.yaml) with the following contents: apiVersion: apps/v1 kind: Deployment metadata: name: nginx-deployment spec: replicas: 1 selector: matchLabels: app: nginx template: metadata: labels: app: nginx spec: containers: - name: nginx image: nginx ports: - containerPort: 80 volumeMounts: - mountPath: /usr/share/nginx/html name: html-volume volumes: - name: html-volume hostPath: path: /path/on/host/for/html Update the path field in the hostPath section with the desired directory path on the host machine.
  4. Apply the deployment to your Minikube cluster: $ kubectl apply -f nginx-deployment.yaml
  5. Create a Kubernetes ingress file (e.g., nginx-ingress.yaml) with the following contents: apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: nginx-ingress spec: rules: - host:
  6. Apply the ingress to your Minikube cluster: $ kubectl apply -f nginx-ingress.yaml
  7. Update your hosts file to map :


By following these steps, you will have a volume mapped inside the ingress (nginx) pod, which will be accessible through the configured <ingress-hostname> and will serve files from the specified host path.