Hardening cloud-provider-vsphere credential in TKGm workload clusters
search cancel

Hardening cloud-provider-vsphere credential in TKGm workload clusters

book

Article ID: 429218

calendar_today

Updated On:

Products

VMware Tanzu Kubernetes Grid VMware Telco Cloud Automation VMware Telco Cloud Platform VMware vSphere ESXi

Issue/Introduction

After applying credential hardening for the Cloud Provider Interface (CPI) in Telco Cloud Automation (TCA) managed TKG clusters, you may encounter the following issues:

  • Persistent Volume Claims (PVC) stuck in Pending state.
  • Pods failing to start with FailedAttachVolume errors.
  • Log errors in vCenter or CSI controller: ServerFaultCode: Permission to perform this operation was denied during ReconfigVM_Task.
  • Errors on ESXi 7.0u3+ hosts: failed to attach disk: "####" err ServerFaultCode: Permission to perform this operation was denied.

Environment

TKG 2.5.x, 2.5.1, 2.5.2, 2.5.3, 2.5.4

TCA 3.x, 3.1, 3.1.1, 3.2, 3.4

TCP 5.0, 5.0.1, 5.1

Cause

  • This issue occurs because the hardened TKG-CPI-Role may be missing required privileges or assigned at an incorrect scope. Specifically:

    1. Scope: vCenter checks for VirtualMachine.Config.AddExistingDisk at the VM Folder level, not the Resource Pool level.
    2. Privileges: ESXi 7.0u3+ requires VirtualMachine.Interact.DeviceConnection for the hot-add operations performed by the CSI driver.

Resolution

Workaround

Update the CPI user credentials

  1. Create the TKG-CPI-Role role in vCenter Server with the following privileges:

    • Cns

      • Searchable

    • Datastore

      • Browse datastore

    • Sessions

      • Message

      • Validate session

    • Storage views

      • View

    • Virtual Machine

      • Provisioning

        • Allow read-only disk access

  2. Create a local cpi user with vsphere.local as the domain name, and set an appropriate password.

  3. Assign Permissions to Objects 

    1. Go to the Hosts and Clusters view.

    2. Right-click the Datacenter where TKG cluster will be deployed.

    3. Select Permissions and click Add.

    4. Enter the [email protected] user.

    5. Select the TKG-CPI-Role role.

    6. Check the Propagate to children checkbox.

  4. SSH into the management cluster Control Plane node using the capv user.

  5. Download the attached update_cpi_vcenter_credential script

  6. Apply executable permissions

    • chmod +x ./update_cpi_vcenter_credential

  7. Prepare an input CSV file containing the workload cluster names and the new vCenter credentials (username and password);

    Note: Ensure all passwords are provided in base64-encoded format:

    • echo -n '<vcenter_user_password>' | base64

  8. Generate a CSV file that includes the workload cluster name, username, and base64 encoded password:

    • echo '<workload_cluster_name>,<vcenter_user_name>,<base64_encoded_vcenter_user_password>' > clusters.csv

  9. Run the update_cpi_vcenter_credential script with the parameters of csv files:

    • ./update_cpi_vcenter_credential {csv_file_path}

      Example:

      ./update_cpi_vcenter_credential /tmp/clusters.csv

  10. Clear Stale Attachments (If Required)
    • If volumes remain stuck, check for stale VolumeAttachment objects in the workload cluster:

      kubectl get volumeattachment
      kubectl delete volumeattachment <attachment-name> --force --grace-period=0

Known Limitations

  • When running a standard (legacy plan-based) cluster, certain cluster operations require the update_cpi_vcenter_credential script to be reapplied.
    Refer to the following chart:
Cluster OperationStandard cluster
Add Control planeReapply script required
Delete Control planeReapply script required
Modify Control planeReapply script required
Add worker nodeNot needed
Delete worker nodeNot needed
Modify worker nodeNot needed
Deploy NFNot needed
Upgrade clusterReapply script required
Certificate renew immediately from UIReapply script required
Certificate renew auto rotationNot needed

Note: Updating the credentials for a classy (ClusterClass-based) clusters is a one-time operation and will not require the script to be re-applied. 

Additional Information

  • There is no visibility/monitoring on expiring CPI passwords. The administrator is solely responsible for rotating this password. If the password expires or is changed in vCenter without a corresponding update to the Management Cluster secret, the CPI will be unable to access vCenter. In this event, you will need to re-run the update_cpi_vcenter_credential script with the new password for the user.
  • There are no UI/API methods to perform to change the CPI username/password.
 

Attachments

update_cpi_vcenter_credential get_app