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

Member

by ethelyn , in category: General Help , a year ago

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

Facebook Twitter LinkedIn Telegram Whatsapp

2 answers

by alyson_bogan , a year 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.

Member

by mose , 8 months ago

@ethelyn 

  1. Start the Minikube cluster:
1
minikube start


  1. Enable the ingress addon:
1
minikube addons enable ingress


  1. Create a Kubernetes deployment file (e.g., nginx-deployment.yaml) with the following contents:
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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.

  1. Apply the deployment to your Minikube cluster:
1
kubectl apply -f nginx-deployment.yaml


  1. Create a Kubernetes ingress file (e.g., nginx-ingress.yaml) with the following contents:
1
2
3
4
5
6
7
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: nginx-ingress
spec:
  rules:
  - host: <ingress-hostname>


  1. Apply the ingress to your Minikube cluster:
1
kubectl apply -f nginx-ingress.yaml


  1. Update your hosts file to map to the IP address of your Minikube cluster. Find the IP address by running minikube ip in the terminal.


By following these steps, you will have a volume mapped inside the ingress (nginx) pod in Minikube.