Docs / Kubernetes & Orchestration / Kubernetes Persistent Volumes with Longhorn

Kubernetes Persistent Volumes with Longhorn

By Admin · Mar 27, 2026 · Updated Apr 24, 2026 · 7 views · 3 min read

Getting persistent-volumes right from the start saves hours of debugging later. In this comprehensive guide, we'll cover everything from initial setup to production-ready configuration, including longhorn and storage considerations.

Deploying the Application

Regular maintenance is essential for keeping your persistent-volumes installation running smoothly. Schedule periodic reviews of log files, disk usage, and security updates to prevent issues before they occur.


# deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: persistent-volumes-app
  labels:
    app: persistent-volumes
spec:
  replicas: 2
  selector:
    matchLabels:
      app: persistent-volumes
  template:
    metadata:
      labels:
        app: persistent-volumes
    spec:
      containers:
      - name: persistent-volumes
        image: persistent-volumes:latest
        ports:
        - containerPort: 8080
        resources:
          requests:
            memory: "128Mi"
            cpu: "250m"
          limits:
            memory: "256Mi"
            cpu: "500m"

The output should show the service running without errors. If you see any warning messages, address them before proceeding to the next step.

Configuring Services and Ingress

If you encounter issues during setup, check the system logs first. Most problems can be diagnosed by examining the output of journalctl or the application-specific log files in /var/log/.


# Apply the configuration
kubectl apply -f deployment.yaml
kubectl apply -f service.yaml

# Verify the deployment
kubectl get pods -l app=persistent-volumes
kubectl describe deployment persistent-volumes-app
kubectl logs -f deployment/persistent-volumes-app

The configuration above sets the recommended values for a VPS with 2-4GB of RAM. Adjust the memory-related settings proportionally if your server has different specifications.

Setting Up Persistent Storage

Before making changes to the configuration, always create a backup of the existing files. This ensures you can quickly roll back if something goes wrong during the setup process.


# service.yaml
apiVersion: v1
kind: Service
metadata:
  name: persistent-volumes-service
spec:
  selector:
    app: persistent-volumes
  ports:
  - port: 80
    targetPort: 8080
  type: ClusterIP

The output should show the service running without errors. If you see any warning messages, address them before proceeding to the next step.

Scaling and Resource Management

The persistent-volumes configuration requires careful attention to resource limits and security settings. On a VPS with limited resources, it's important to tune these parameters according to your available RAM and CPU cores.


# deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: persistent-volumes-app
  labels:
    app: persistent-volumes
spec:
  replicas: 2
  selector:
    matchLabels:
      app: persistent-volumes
  template:
    metadata:
      labels:
        app: persistent-volumes
    spec:
      containers:
      - name: persistent-volumes
        image: persistent-volumes:latest
        ports:
        - containerPort: 8080
        resources:
          requests:
            memory: "128Mi"
            cpu: "250m"
          limits:
            memory: "256Mi"
            cpu: "500m"

The output should show the service running without errors. If you see any warning messages, address them before proceeding to the next step.

Common Issues and Solutions

  • Permission denied errors: Ensure files and directories have the correct ownership. Use chown -R to fix ownership and chmod for permissions.
  • High memory usage: Review the configuration for memory-related settings. Reduce worker counts or buffer sizes if running on a low-RAM VPS.
  • Connection timeout: Verify your firewall rules allow traffic on the required ports. Use ss -tlnp to confirm the service is listening on the expected port.

Summary

You've successfully configured persistent-volumes on your VPS. Remember to monitor performance, keep your software updated, and maintain regular backups. If you run into issues, consult the official documentation or open a support ticket for assistance.

Was this article helpful?