Skip to main content
Redhat Developers  Logo
  • Products

    Platforms

    • Red Hat Enterprise Linux
      Red Hat Enterprise Linux Icon
    • Red Hat AI
      Red Hat AI
    • Red Hat OpenShift
      Openshift icon
    • Red Hat Ansible Automation Platform
      Ansible icon
    • View All Red Hat Products

    Featured

    • Red Hat build of OpenJDK
    • Red Hat Developer Hub
    • Red Hat JBoss Enterprise Application Platform
    • Red Hat OpenShift Dev Spaces
    • Red Hat OpenShift Local
    • Red Hat Developer Sandbox

      Try Red Hat products and technologies without setup or configuration fees for 30 days with this shared Openshift and Kubernetes cluster.
    • Try at no cost
  • Technologies

    Featured

    • AI/ML
      AI/ML Icon
    • Linux
      Linux Icon
    • Kubernetes
      Cloud icon
    • Automation
      Automation Icon showing arrows moving in a circle around a gear
    • View All Technologies
    • Programming Languages & Frameworks

      • Java
      • Python
      • JavaScript
    • System Design & Architecture

      • Red Hat architecture and design patterns
      • Microservices
      • Event-Driven Architecture
      • Databases
    • Developer Productivity

      • Developer productivity
      • Developer Tools
      • GitOps
    • Automated Data Processing

      • AI/ML
      • Data Science
      • Apache Kafka on Kubernetes
    • Platform Engineering

      • DevOps
      • DevSecOps
      • Ansible automation for applications and services
    • Secure Development & Architectures

      • Security
      • Secure coding
  • Learn

    Featured

    • Kubernetes & Cloud Native
      Openshift icon
    • Linux
      Rhel icon
    • Automation
      Ansible cloud icon
    • AI/ML
      AI/ML Icon
    • View All Learning Resources

    E-Books

    • GitOps Cookbook
    • Podman in Action
    • Kubernetes Operators
    • The Path to GitOps
    • View All E-books

    Cheat Sheets

    • Linux Commands
    • Bash Commands
    • Git
    • systemd Commands
    • View All Cheat Sheets

    Documentation

    • Product Documentation
    • API Catalog
    • Legacy Documentation
  • Developer Sandbox

    Developer Sandbox

    • Access Red Hat’s products and technologies without setup or configuration, and start developing quicker than ever before with our new, no-cost sandbox environments.
    • Explore Developer Sandbox

    Featured Developer Sandbox activities

    • Get started with your Developer Sandbox
    • OpenShift virtualization and application modernization using the Developer Sandbox
    • Explore all Developer Sandbox activities

    Ready to start developing apps?

    • Try at no cost
  • Blog
  • Events
  • Videos

Adding Persistent Storage to Minishift / CDK 3 in Minutes

April 5, 2017
Alessandro Arrichiello
Related topics:
Developer ToolsKubernetesContainersDevOps
Related products:
Developer ToolsRed Hat OpenShift Container Platform

Share:

    Hi there! It's been a while since I last wrote an article. Today, I want to show you how to easily setup some persistent storage for your projects in minishift / CDK 3 (Red Hat's Containers Development Kit 3).

    Prerequisites

    First, let's start planning what you'll need:

    • A working minishift or CDK 3.

    That's all, I swear!

    I won't go deep into how to set up a minishift or CDK 3, there are many articles on the Internet to cover this. Anyway I'll recap some useful links below, just to make sure you'll get a working minishift/CDK3 before proceeding:

    https://developers.redhat.com/blog/2017/02/28/using-red-hat-container-development-kit-3-beta/

    Minishift Github page - https://github.com/minishift/minishift

    Let's start!

    Once you've successfully set up a working minishift/CDK3, you're now ready to move forward, creating the underlying storage for your Persistent Volumes (PVs).

    First of all, connect to your running minishift/CDK3:

    $ minishift ssh
    [docker@minishift ~]$ sudo -i
    [root@minishift ~]#

    Ok, now we're ready to create our first persistent volume backend directory for hosting Docker Registry files:

    [root@minishift ~]# mkdir -p /mnt/sda1/var/lib/minishift/openshift.local.volumes/pv
     [root@minishift ~]# mkdir /mnt/sda1/var/lib/minishift/openshift.local.volumes/pv/registry
     [root@minishift ~]# chmod 777 -R /mnt/sda1/var/lib/minishift/openshift.local.volumes/pv

    Perfect! We can now move to the PersistentVolume creation for our Docker Registry container.

    First, log out from your minishift/CDK3 vm and then log in to your Openshift via oc-client:

    $ oc login -u system:admin
    Logged into "https://192.168.42.58:8443" as "system:admin" using existing credentials.
    
    You have access to the following projects and can switch between them with 'oc project <projectname>':
    
     default
     kube-system
     * myproject
     openshift
     openshift-infra
    
    Using project "myproject".
    

    Let's switch to project "default":

    $ oc project default
    Now using project "default" on server "https://192.168.42.69:8443".

    Finally, create your first PersistentVolume:

    $ cat << PV | oc create -f -
    apiVersion: v1
    kind: PersistentVolume
    metadata:
     name: registry
    spec:
     capacity:
      storage: 5Gi
     accessModes:
      - ReadWriteOnce
     storageClassName: slow
     hostPath:
      path: /mnt/sda1/var/lib/minishift/openshift.local.volumes/pv/registry
    PV

    Pay attention to two things here:

    1. Storage capacity: it's not calculated automatically! You should care about disk size and free space.
    2. Usage of Volume type "hostPath", the storage is on the minishift/CDK3 virtual disk, you should take care of permissions!

    Ok, now we're ready to create our first PersistentVolumeClaim, to be bound with a PersistentVolume resource:

    $ cat << PVC | oc create -f -
    kind: PersistentVolumeClaim
    apiVersion: v1
    metadata:
     name: registryclaim
    spec:
     accessModes:
      - ReadWriteOnce
     resources:
      requests:
       storage: 5Gi
     storageClassName: slow
     selector:
      name: registry
    PVC

    As you can see from the PersistentVolumeClaim definition, we match the PersistentVolume by the name "registry".

    We can now look at the result by checking the output of the following commands:

    $ oc get pvc
    NAME          STATUS VOLUME   CAPACITY ACCESSMODES AGE
    registryclaim Bound  registry 5Gi      RWO         8s

    Finally, we can patch the current registry DeploymentConfig adding the just created storage:

    $ oc volume dc/docker-registry --add --name=registry-storage -t pvc --claim-name=registryclaim --overwrite
    deploymentconfig "docker-registry" updated
    

    That's all! You can repeat these steps as many times as you want! But, pay attention to your vm's free space!


    About Alessandro

    Alessandro Arrichiello is a Solution Architect for Red Hat Inc. He has a passion for GNU/Linux systems, that began at age 14 and continues today. He worked with tools for automating Enterprise IT: configuration management and continuous integration through virtual platforms. He’s now working on distributed cloud environment involving PaaS (OpenShift), IaaS (OpenStack) and Processes Management (CloudForms), Containers building, instances creation, HA services management, workflows build.


    Register to download the Red Hat Container Development Kit and accept the terms and conditions of the Red Hat Developer Program, which provides no-cost subscriptions for development use only.

    Last updated: April 6, 2017

    Recent Posts

    • A deep dive into Apache Kafka's KRaft protocol

    • Staying ahead of artificial intelligence threats

    • Strengthen privacy and security with encrypted DNS in RHEL

    • How to enable Ansible Lightspeed intelligent assistant

    • Why some agentic AI developers are moving code from Python to Rust

    Red Hat Developers logo LinkedIn YouTube Twitter Facebook

    Products

    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform

    Build

    • Developer Sandbox
    • Developer Tools
    • Interactive Tutorials
    • API Catalog

    Quicklinks

    • Learning Resources
    • E-books
    • Cheat Sheets
    • Blog
    • Events
    • Newsletter

    Communicate

    • About us
    • Contact sales
    • Find a partner
    • Report a website issue
    • Site Status Dashboard
    • Report a security problem

    RED HAT DEVELOPER

    Build here. Go anywhere.

    We serve the builders. The problem solvers who create careers with code.

    Join us if you’re a developer, software engineer, web designer, front-end designer, UX designer, computer scientist, architect, tester, product manager, project manager or team lead.

    Sign me up

    Red Hat legal and privacy links

    • About Red Hat
    • Jobs
    • Events
    • Locations
    • Contact Red Hat
    • Red Hat Blog
    • Inclusion at Red Hat
    • Cool Stuff Store
    • Red Hat Summit
    © 2025 Red Hat

    Red Hat legal and privacy links

    • Privacy statement
    • Terms of use
    • All policies and guidelines
    • Digital accessibility

    Report a website issue