Get a kubeconfig file for your tenant cluster
To connect to a tenant cluster's Kubernetes API server, you can either manually create a kubeconfig file or use the vCluster CLI to generate and update it automatically.
Retrieve using the vCluster CLI​
The easiest way to retrieve a kubeconfig for your tenant cluster is by using the vCluster CLI.
You can update your current kubeconfig on your local machine by running the following command:
vcluster platform connect vcluster my-vcluster
If you want to print the kubeconfig file, you can append --print to the command:
vcluster platform connect vcluster my-vcluster --print
If you have multiple tenant clusters with the same name, a sub-menu allows you to specify the vCluster by project.
If you have regional cluster endpoints or ingress endpoints for tenant clusters enabled, the resulting kubeconfig will look different.
Create kubeconfig without the CLI​
You can also create a kubeconfig manually by creating an access key for your user first and then using the following template, with the following placeholders:
- $PROJECT: the project the tenant cluster is in
- $VIRTUAL_CLUSTER: the tenant cluster name to connect to
- $PLATFORM_URL: the platform host you connect to
- $ACCESS_KEY: the access key to use
Then replace the placeholders in the following template and save the configuration as my-kubeconfig.yaml:
apiVersion: v1
kind: Config
clusters:
- cluster:
server: https://$PLATFORM_URL/kubernetes/project/$PROJECT/virtualcluster/$VIRTUAL_CLUSTER
# Optional: if the server uses an insecure certificate
# insecure-skip-tls-verify: true
name: loft
contexts:
- context:
cluster: loft
user: loft
name: loft
current-context: loft
users:
- name: loft
user:
token: $ACCESS_KEY
You can access your tenant cluster by using the freshly created kubeconfig file:
KUBECONFIG=my-kubeconfig.yaml kubectl get namespaces