Skip to main content
Redhat Developers  Logo
  • AI

    Get started with AI

    • Red Hat AI
      Accelerate the development and deployment of enterprise AI solutions.
    • AI learning hub
      Explore learning materials and tools, organized by task.
    • AI interactive demos
      Click through scenarios with Red Hat AI, including training LLMs and more.
    • AI/ML learning paths
      Expand your OpenShift AI knowledge using these learning resources.
    • AI quickstarts
      Focused AI use cases designed for fast deployment on Red Hat AI platforms.
    • No-cost AI training
      Foundational Red Hat AI training.

    Featured resources

    • OpenShift AI learning
    • Open source AI for developers
    • AI product application development
    • Open source-powered AI/ML for hybrid cloud
    • AI and Node.js cheat sheet

    Red Hat AI Factory with NVIDIA

    • Red Hat AI Factory with NVIDIA is a co-engineered, enterprise-grade AI solution for building, deploying, and managing AI at scale across hybrid cloud environments.
    • Explore the solution
  • Learn

    Self-guided

    • Documentation
      Find answers, get step-by-step guidance, and learn how to use Red Hat products.
    • Learning paths
      Explore curated walkthroughs for common development tasks.
    • Guided learning
      Receive custom learning paths powered by our AI assistant.
    • See all learning

    Hands-on

    • Developer Sandbox
      Spin up Red Hat's products and technologies without setup or configuration.
    • Interactive labs
      Learn by doing in these hands-on, browser-based experiences.
    • Interactive demos
      Click through product features in these guided tours.

    Browse by topic

    • AI/ML
    • Automation
    • Java
    • Kubernetes
    • Linux
    • See all topics

    Training & certifications

    • Courses and exams
    • Certifications
    • Skills assessments
    • Red Hat Academy
    • Learning subscription
    • Explore training
  • Build

    Get started

    • Red Hat build of Podman Desktop
      A downloadable, local development hub to experiment with our products and builds.
    • Developer Sandbox
      Spin up Red Hat's products and technologies without setup or configuration.

    Download products

    • Access product downloads to start building and testing right away.
    • Red Hat Enterprise Linux
    • Red Hat AI
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products

    Featured

    • Red Hat build of OpenJDK
    • Red Hat JBoss Enterprise Application Platform
    • Red Hat OpenShift Dev Spaces
    • Red Hat Developer Toolset

    References

    • E-books
    • Documentation
    • Cheat sheets
    • Architecture center
  • Community

    Get involved

    • Events
    • Live AI events
    • Red Hat Summit
    • Red Hat Accelerators
    • Community discussions

    Follow along

    • Articles & blogs
    • Developer newsletter
    • Videos
    • Github

    Get help

    • Customer service
    • Customer support
    • Regional contacts
    • Find a partner

    Join the Red Hat Developer program

    • Download Red Hat products and project builds, access support documentation, learning content, and more.
    • Explore the benefits

vSphere Cloud provider and VMDK dynamic provisioning

<p>&nbsp;</p> <quillbot-extension-portal></quillbot-extension-portal>

October 24, 2017
davis phillips
Related topics:
ContainersDeveloper toolsDevOpsLinuxKubernetes
Related products:
Red Hat OpenShiftRed Hat OpenShift Container PlatformRed Hat Enterprise Linux

    The release of OpenShift Container Platform 3.6 brings support for vsphere cloud provider. This provides vsphere VMDK dynamic provisioning for persistent volumes for container workloads. The storage presented to vsphere virtual machines as a VMDK has ReadWriteOnce access mode.

    In the OCP 3.6 on vSphere reference architecture, much of this process is automated and can be implemented easily.

    Virtual Machine Disks or VMDKs exists in virtual machines. Configuring the OCP cluster for vsphere cloud provider support requires:

    • Master Node Configuration
    • Application Node Configuration
    • vCenter or vSphere Requirements

    The kubernetes docs do a great job of highlighting the requirements for vSphere.

    First, both master and nodes need the following parameters set and services restarted:

    • cloud-provider=vsphere
    • cloud-config=path_to_config.conf

    Master configuration

    $ vi /etc/origin/master/master-config.yaml
    
    kubernetesMasterConfig:
      apiServerArguments: 
        cloud-config:
        - /etc/vsphere/vsphere.conf
        cloud-provider:
        - vsphere
      controllerArguments: 
        cloud-config:
        - /etc/vsphere/vsphere.conf
        cloud-provider:
        - vsphere
    
    $ sudo systemctl restart atomic-openshift-master.service

    Node configuration

    $ vi /etc/origin/node/node-config.yaml
    
    kubeletArguments:
      cloud-config:
      - /etc/vsphere/vsphere.conf
      cloud-provider:
      - vsphere
    
    $ sudo systemctl restart atomic-openshift-node.service

    Next, the vsphere.conf file should loosely resemble this:

    $ cat /etc/vsphere/vsphere.conf 
    [Global]
    user = "administrator@vsphere.local"
    password = "vcenter_password"
    server = "10.*.*.25" 
    port = 443
    insecure-flag = 1
    datacenter = Boston
    datastore = ose3-vmware-prod
    working-dir = /Boston/vm/ocp36/
    [Disk]
    scsicontrollertype = pvscsi

    The variables are discussed more in the Kubernetes document. The working-dir variable is the folder that houses the OpenShift guest machines. In vSphere, the folder syntax will be /Datacenter/vm/foldername.

    Using GOVC

    The tool govc is a GO-based application for interacting with vSphere and vCenter.

    The documentation for govc is located in github:

    https://github.com/vmware/govmomi/tree/master/govc

    First, download govc then export the vars that govc needs to query vCenter:

    curl -LO https://github.com/vmware/govmomi/releases/download/v0.15.0/govc_linux_amd64.gz
    gunzip govc_linux_amd64.gz
    chmod +x govc_linux_amd64
    cp govc_linux_amd64 /usr/bin/
    
    export GOVC_URL='vCenter IP OR FQDN'
    export GOVC_USERNAME='administrator@vsphere.local'
    export GOVC_PASSWORD='vCenter Password'
    export GOVC_INSECURE=1
    
    $ govc ls
    /Boston/vm
    /Boston/network
    /Boston/host
    /Boston/datastore
    
    $ govc ls /Boston/vm
    /Boston/vm/ocp36
    
    $ govc ls /Boston/vm/ocp36
    /Boston/vm/ocp36/haproxy-0
    /Boston/vm/ocp36/app-0
    /Boston/vm/ocp36/infra-0
    /Boston/vm/ocp36/haproxy-1
    /Boston/vm/ocp36/master-0
    /Boston/vm/ocp36/nfs-0

    vSphere Pre-requisites

    • disk.enableUUID

    Next, the enableUUID parameter needs to be set on all virtual machines in the OCP cluster. The option is necessary so that the VMDK always presents a consistent UUID to the VM, this allows the new disk to be mounted properly.

    enableUUID

    The enableUUID option can be set at the template or VM in the vCenter client. Next, the template would then be used to deploy the OpenShift VMs.

    Additionally, govc can be used to set this as well:

    for each VM in `govc ls /Boston/vm/ocp36/`;do govc vm.change -e="disk.enableUUID=1" -vm="$VM"

    Lastly, with the cloud provider configuration in place a new storage class to deploy VMDKs can be created.

    Storage Classes and VMDK Provisioning

    The datastore storage class can be created with the following yaml file:

    $ vi cloud-provider-storage-class.yaml
    kind: StorageClass
    apiVersion: storage.k8s.io/v1
    metadata:
      name: "ose3-vmware-prod"
    provisioner: kubernetes.io/vsphere-volume
    parameters:
        diskformat: zeroedthick
        datastore: "ose3-vmware-prod"
    
    oc create -f cloud-provider-storage-class.yaml

    Now that the StorageClass object is created. The oc command can be used to verify the StorageClass exists.

    $ oc get sc
    NAME               TYPE
    ose3-vmware-prod   kubernetes.io/vsphere-volume
    
    $ oc describe sc ose3-vmware-prod
    Name:           ose3-vmware-prod
    IsDefaultClass: No
    Annotations:    &lt;none&gt;
    Provisioner:    kubernetes.io/vsphere-volume
    Parameters:     datastore=ose3-vmware-prod,diskformat=zeroedthick
    Events:         &lt;none&gt;

    OpenShift can now dynamically provision VMDKs for persistent container storage within the OpenShift environment.

    $ vi storage-class-vmware-claim.yaml
    
    kind: PersistentVolumeClaim
    apiVersion: v1
    metadata:
      name: ose3-vmware-prod
      annotations:
        volume.beta.kubernetes.io/storage-class: ose3-vmware-prod
    spec:
      accessModes:
        - ReadWriteOnce
      resources:
        requests:
          storage: 2Gi
    
    $ oc create -f storage-class-vmware-claim.yaml
    
    $ oc describe pvc ose3-vmware-prod
    
    Name:           ose3-vmware-prod
    Namespace:      default
    StorageClass:   ose3-vmware-prod
    Status:         Bound
    Volume:         pvc-cc8a9970-7c76-11e7-ae86-005056a571ee
    Labels:         &lt;none&gt;
    Annotations:    pv.kubernetes.io/bind-completed=yes
                    pv.kubernetes.io/bound-by-controller=yes
                    volume.beta.kubernetes.io/storage-class=vmware-datastore-ssd
                    volume.beta.kubernetes.io/storage-provisioner=kubernetes.io/vsphere-volume
    Capacity:       2Gi
    Access Modes:   RWO
    Events:
      FirstSeen LastSeen    Count   From                SubObjectPath   Type        Reason          Message
      --------- --------    -----   ----                -------------   --------    ------          -------
      19s       19s     1   persistentvolume-controller         Normal      ProvisioningSucceeded   Successfully provisioned volume pvc-cc8a9970-7c76-11e7-ae86-005056a571ee using kubernetes.io/vsphere-volume

    Now, in vCenter, a couple of changes are initiated:

    First, the new disk is created.

    ocp-new-disk

    Secondly, the disk is ready to be consumed by a VM to be attached to a POD.

    Lastly, while datastores are generally accessible via shared storage across a vCenter cluster, the VMDKs are tied to a specific machine. This explains the 'ReadWriteOnce' limitation of the persistent storage.


     

    Last updated: November 2, 2023

    Recent Posts

    • Every layer counts: Defense in depth for AI agents with Red Hat AI

    • Fun in the RUN instruction: Why container builds with distroless images can surprise you

    • Trusted software factory: Building trust in the agentic AI era

    • Build a zero trust AI pipeline with OpenShift and RHEL CVMs

    • Red Hat Hardened Images: Top 5 benefits for software developers

    Red Hat Developers logo LinkedIn YouTube Twitter Facebook

    Platforms

    • Red Hat AI
    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products

    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
    © 2026 Red Hat

    Red Hat legal and privacy links

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

    Chat Support

    Please log in with your Red Hat account to access chat support.