vSphere Namespace Permissions for VKS
search cancel

vSphere Namespace Permissions for VKS

book

Article ID: 424897

calendar_today

Updated On:

Products

VMware vSphere Kubernetes Service VMware vSphere ESXi

Issue/Introduction

This KB is provided as a supplement to the official documentation below. It details how each vSphere Namespace permission impacts VKS clusters.

Official Document - Configure vSphere Namespace Permissions for vCenter Single Sign-On Users and Groups

Example scenario

Environment

vSphere Kubernetes Service

Resolution

"Can View" privilege

This permission grants read-only access to the Supervisor context.

Supervisor Level: The user can view the Cluster API resources, etc., in the vSphere Namespace

kubectl vsphere login -u [email protected] --server=https://${SUPERVISOR_VIP}
kubectl config use-context vsphere-ns-1

kubectl get cluster,ma,vm # OK
kubectl delete ma <ma_object> # Forbidden
kubeatl edit cluster <cluster> # Forbidden

VKS Cluster Level: The user has no access inside the VKS clusters

kubectl config use-context <TARGET_VKS_CLUSTER>
kubectl get pods  # Forbidden

 

"Can Edit" privilege

This privilege allows the user to manage VKS clusters within the target vSphere Namespace.
Enabling "Can edit" provides the following authorities to the target user:

  • Lifecycle Management: Full control to create, edit, and delete VKS clusters within the target vSphere Namespace via the Supervisor context
  • Cluster-wide Admin Access: Automatically granted the cluster-admin role for all VKS clusters in that vSphere Namespace
  • Full Resource Control: Complete administrative control over all resources (kubectl get/delete/edit Pods, Nodes, etc.) inside the VKS clusters

Logging In & Verifying Access Boundaries:

1. Supervisor Cluster Context Login (${SUPERVISOR_VIP}): Log in to manage vSphere Namespaces and VKS cluster lifecycle operations:

# Authenticate to the Supervisor VIP:
kubectl vsphere login --server=https://${SUPERVISOR_VIP} \
  -u [email protected] \
  --vsphere-namespace <VSPHERE-NAMESPACE> \
  --insecure-skip-tls-verify

# Switch to the Supervisor context generated by the plugin:
kubectl config use-context <VSPHERE-NAMESPACE>-${SUPERVISOR_VIP}

Command Scoping Rules on Supervisor Context: Commands containing --all-namespaces (-A) or requesting global infrastructure objects (such as nodes) will fail because Namespace permissions do not grant global Supervisor admin rights:

# Fails (Global host/node query):
kubectl get no
# Error from server (Forbidden): nodes is forbidden at the cluster scope

# Fails (Querying across all namespaces):
kubectl get po -A
# Error from server (Forbidden): pods is forbidden at the cluster scope

# Succeeds (Explicitly scoped to assigned vSphere Namespace):
kubectl get po -n <VSPHERE-NAMESPACE>
kubectl get cluster,ma,vm -n <VSPHERE-NAMESPACE>

2. VKS Guest Cluster Context Login (<TARGET_VKS_CLUSTER>): Enabling "Can Edit" automatically grants cluster-admin rights inside all VKS workload clusters deployed within that namespace. To execute cluster-wide commands or inspect role bindings inside the workload cluster, log in directly to the VKS cluster context:

# Authenticate directly to the VKS Guest Cluster:
kubectl vsphere login --server=https://${SUPERVISOR_VIP} \
  -u [email protected] \
  --tanzu-kubernetes-cluster-name <TARGET_VKS_CLUSTER> \
  --tanzu-kubernetes-cluster-namespace <VSPHERE-NAMESPACE> \
  --insecure-skip-tls-verify

# Switch to the VKS Guest Cluster context:
kubectl config use-context <TARGET_VKS_CLUSTER>

# Succeeds inside the VKS Guest Cluster:
kubectl get po -A
kubectl get no -o wide

You can verify this automatic cluster role binding with the following command inside a VKS cluster:

kubectl config use-context <TARGET_VKS_CLUSTER>
kubectl get clusterrolebindings | grep cluster-admin
#> vmware-system-auth-sync-wcp:vsphere-ns-1:group:vsphere.local:administrators   ClusterRole/cluster-admin
#> vmware-system-auth-sync-wcp:vsphere-ns-1:group:vsphere.local:test       ClusterRole/cluster-admin

 

Note: Recommendation for "Developer" Access:

"Can edit" might be excessive if you want users to deploy workloads but not delete the cluster itself. 
If you need to grant access to a VKS Cluster without giving "Can edit" (Cluster lifecycle management) permissions on the Namespace, please refer to the following documentation:

Official document - Grant Developer Access to VKS Clusters

Note: The "Can edit" permission is strictly for kubectl operations on the Supervisor. It does not grant permission to modify vSphere Namespace settings in the vSphere Client.

 

"Owner" privilege

From a VKS Cluster perspective, "Owner" is functionally identical to "Can edit," providing the same cluster-admin access and lifecycle control over VKS clusters.

The additional capability of "Owner" is the ability to create new vSphere Namespaces via the Supervisor context (kubectl).
Prerequisite: vSphere Namespace Self-Service (Template) must be configured by an administrator in the vSphere Client in advance.

Official document - Enable vSphere Namespace Creation Using Kubectl

Note: 'Owner' privileges do not grant permission to modify vSphere Namespace configurations via the vSphere Client. Management of the Namespace itself remains restricted to vSphere administrators.

Additional Information

Japanese KB: VKS における vSphere 名前空間の権限について