good to know that vcf context use can refresh the existing context without recreating it. Does this also work reliably after a password change.Chengwei Semiconductor
Original Message:
Sent: Jul 31, 2026 11:29 AM
From: Shachar Ben David
Subject: a replacement for kubectl vsphere login
What I didn't find is how to update the context list with new vcf namespaces that were created after running "vcf context create"
my solution is to create all contexts again with a new name.. but i don't like it - there must be a more elegant way to do it.
Original Message:
Sent: Jul 29, 2026 09:46 AM
From: Allan Solomon Mejia
Subject: a replacement for kubectl vsphere login
Nice find, and thanks for sharing. It'll definitely save others some time.
Using vcf context use <context-name> is a much cleaner approach than recreating or deleting contexts. When the authentication token has expired or the kubeconfig is no longer valid, switching back to the existing context prompts for re-authentication and refreshes the associated credentials without having to rebuild the context.
This is especially useful for long-lived environments where you want to preserve existing context names and avoid unnecessary cleanup.
Original Message:
Sent: Jul 29, 2026 09:31 AM
From: Shachar Ben David
Subject: a replacement for kubectl vsphere login
I have found the solution.
When the authentication token expires or the kubeconfig becomes invalid , and kubectl should display "couldn't get current server api group list : the server has asked for the client to provide credentials"
The solution is to run vcf context use <context name>
The vcf utility will ask to sign in again, and will automatically refresh all related contexts.
BR,
Shachar
Original Message:
Sent: Jul 29, 2026 01:36 AM
From: Shachar Ben David
Subject: a replacement for kubectl vsphere login
Thanks for the detailed answer.
The caveat is that running the same "vcf context create" command will ended with "context "xyz" already exists".
I can, of course, create a new context name, and delete the old entries, but I wonder if there is a better way to do it?
Shachar
Original Message:
Sent: Jul 28, 2026 04:29 PM
From: Allan Solomon Mejia
Subject: a replacement for kubectl vsphere login
Hello @Shachar
You're correct that kubectl vsphere login was deprecated starting with VCF 9.x. The recommended replacement is to use the VCF CLI to create a kubeconfig context once, and then use the standard Kubernetes context management commands thereafter.
A typical workflow is:
vcf context create \
--endpoint <SUPERVISOR_ENDPOINT> \
--workload-cluster-name <WORKLOAD_CLUSTER_NAME> \
--workload-cluster-namespace <WORKLOAD_CLUSTER_NAMESPACE>
After the context has been created, users don't need to recreate it every time. They can simply switch between existing contexts using:
kubectl config get-contexts
kubectl config use-context <context_name>
If the authentication token expires or the kubeconfig becomes invalid (for example, after credential changes), you'll need to run vcf context create again to refresh the context.
So the equivalent of the old kubectl vsphere login experience is:
- One-time (or occasional): vcf context create
- Day-to-day: kubectl config use-context <context_name>