configure persistent volume storage

The Post Created(Updated) On 04/22/2022,Please note the timeliness of the article!

Recently understand this k8s in PVC storage here stuck for two days, today finally considered probably understand what is going on.

The following is a summary of the process.

  • Create a PersistentVolume backed by physical storage. you will not associate the volume with any Pod.

  • Create a PersistentVolumeClaim that will be automatically bound to the appropriate PersistentVolume.

  • Create a deployment that uses a PersistentVolumeClaim as storage.

  • [https://kubernetes.io/zh/docs/tasks/configure-pod-container/configure-persistent-volume-storage/](https://kubernetes.io/zh/docs/ tasks/configure-pod-container/configure-persistent-volume-storage/)

Schematic

Explanation

Explanation Path
/mnt/data directory on localhost
/app/wiz path in minikube container !
/wiz/storage/ path to pod

Steps

Mirror pulling

docker pull wiznote/wizserver

minikube mount local directory

  • Start the mount
minikube start --mount --mount-string="/mnt/data:/app/wiz"
  • Verify
minikube ssh
cd /app/wiz
# Just create a file and go to /mnt/data on the host to see if it exists

PV creation

  • configuration file “ wiz-pv.yaml
    “`.
apiVersion: v1
type. persistentVolume
Metadata.
  name: wiz-pv-volume
  tag.
    type: local
specification.
  storageClassName: manual
  capacity.
    Storage. 10Gi
  Access mode.
    - One-time read/write
  hostPath:
    Path." /app/wiz"
  • Deploy
kubectl create -f wiz-pv.yaml
  • View
kubectl get pv
  • Delete
kubectl delete pv wiz-pv-volume

PVC creation

  • Configuration file wiz-pvc.yaml.
apiVersion: v1
type. persistentVolumeClaim
Metadata.
  name: wiz-pv-claim
specification.
  storageClassName: manual
  accessModes:
    - ReadWriteOnce
  resource.
    Request.
      Storage. 3Gi
  • Deployment
kubectl create -f wiz-pvc.yaml
  • View
kubectl get pvc
  • Delete
kubectl delete pvc wiz-pv-claim

Deployment creation

  • configuration file wiz.yaml.
kind. Deploy
apiVersion: apps/v1
Metadata.
  name: wiz #Deployment name
  tag.
    Application: wiz
spec.
  replicas: 2 #Number of target replicas
  selector.
    matchLabels:
      Application: wiz
  template.
    metadata:
      Tags.
        Application: wiz
    specification.    
      volume.
      - name: wiz-pv-storage
        persistentVolumeClaim:
          claimName: wiz-pv-claim #PVC storage name
      container.
        - name: wizserver
          image: wiznote/wizserver:newly        
          resource. {}
          imagePullPolicy. always           
          volumeMounts: # mount points inside the container
            - mountPath: "/wiz/storage/"
              name: wiz-pv-storage # Must have name     
          port.                                #Define port
            - name: container-port #Define pod name
              container-port: 80 #Define pod port
              protocol. tcp #define tcp       
      Restart policy. always
      terminationGracePeriodSeconds: 30
  Policy.
    Type. rollingUpdate.
    RollingUpdate:
      maxUnavailability: 25
      maxSurge: 25%
  revisionHistoryLimit: 10
  progressDeadlineSeconds: 600
  • Deployment
kubectl create -f wiz.yaml

Create the service

  • Configuration file wiz-service.yaml.
apiVersion: v1
type: service
metadata:
  name: wiz-service
spec:
  type: node port
  selector.
    application: wiz
  ports:
  - Protocol: TCP
    port. 8888
    Target port: 80
  • Deploy
kubectl create -f wiz-service.yaml

Copyright

Unless otherwise noted, all work on this blog is licensed under a Attribution-NonCommercial-NoDerivatives 4.0 International (CC BY-NC-ND 4.0) License. Reprinted with permission from -
https://blog.emperinter.info/2022/04/22/configure-persistent-volume-storage


CouPon

alibaba cloud20 dollars
Vultr10 Dollars
Bandwagon HostMaybe some Coupon?
Domain | namesiloemperinter 1Dollars