Migrate datastore to SPBM

This document shows how to migrate a vSphere datastore to Storage Policy Based Management (SPBM).

Context

There are four places where you can specify a datastore in cluster configuration files:

The inheritance for these fields is as follows:

adminCluster.vCenter.datastore ->
  userCluster.vCenter.datastore ->
    (userCluster.masterNode.vsphere.datastore and userCluster.nodePools[i].vsphere.datastore

Examples:

  • If userCluster.vCenter.datastore is empty, it inherits the value from adminCluster.vCenter.datastore.

  • If userCluster.nodePools[i].vsphere.datastore is empty, it inherits the value from userCluster.vCenter.datastore.

Similarly, there are four places to specify a storage policy:

The inheritance for the storagePolicyName fields is the same as it is for the datastore fields.

Before you begin

This is a one-way migration. We don't support migrating back to the previous state.

Perform a migration for a user cluster

  1. Get the current cluster configuration:

    gkectl get-config cluster --kubeconfig ADMIN_CLUSTER_KUBECONFIG \
        --cluster-name USER_CLUSTER_NAME \
        --output-dir ./gen-files
    

    Replace the following:

    • ADMIN_CLUSTER_KUBECONFIG: the path of the kubeconfig file for the admin cluster

    • USER_CLUSTER_NAME: the name of the user cluster

    In ./gen-files, locate user-cluster.yaml.

    For more information about getting the configuration file, see Generate configuration files from a cluster.

  2. To perform a migration for one of the datastore fields:

    1. Set the datastore field to the empty string.
    2. Specify a value for storagePolicyName.
    3. Run gkectl update.

    Here's an example of performing a migration for masterNode.vsphere.datastore:

    Adjust the recently generated user-cluster.yaml:

    masterNode.vsphere.datastore=""
    masterNode.vsphere.masterNode.vsphere.storagePolicyName="control-plane-storage-policy"
    

    Update the user cluster:

    gkectl update cluster --kubeconfig ADMIN_CLUSTER_KUBECONFIG --config USER_CLUSTER_CONFIG
    

    Replace the following:

    • ADMIN_CLUSTER_KUBECONFIG: the path of the admin cluster kubeconfig file

    • USER_CLUSTER_CONFIG: the path of user-cluster.yaml that you generated in the previous step.

Notes

If you create a new node pool after a migration, the new pool follows the rules of inheritance according the updated cluster.

For example, suppose you migrated vCenter.datastore to a storage policy.

Now if you create a new node pool and leave both nodePools[i].vsphere.datastoreand nodePools[i].vsphere.storagePolicyName empty, the new node pool inherits the storage policy specified in vCenter.storagePolicyName.