Get Kubeconfig File
You can either manually construct a kubeconfig to access your namespace or use the vCluster CLI to automatically create a kubeconfig.
Retrieve via CLI​
You can update your current kube-config by running the following command:
vcluster platform connect namespace my-namespace --project my-project
If you want to print the kubeconfig, you can append --print to the command:
vcluster platform connect namespace my-namespace --project my-project --print
info
Depending on if you have direct cluster endpoints enabled, the kubeconfig will look different.
Kubeconfig without CLI​
You can create the kubeconfig also manually by creating an access key for your user first and then using the following template, with the following placeholders:
$PROJECT: the project the namespace is in$SPACE: the space name to connect to$NAMESPACE: the target namespace (check thespec.clusterRef.namespacefield in the SpaceInstance object)$PLATFORM_URL: the platform host you connect to$ACCESS_KEY: the access key to use
Then replace these placeholders in the following template and save it as my-kubeconfig.yaml:
apiVersion: v1
kind: Config
clusters:
- cluster:
server: https://$PLATFORM_URL/kubernetes/project/$PROJECT/space/$SPACE
# Optional: if the server uses an insecure certificate
# insecure-skip-tls-verify: true
name: loft
contexts:
- context:
cluster: loft
namespace: $NAMESPACE
user: loft
name: loft
current-context: loft
users:
- name: loft
user:
token: $ACCESS_KEY
Access your namespace with:
KUBECONFIG=my-kubeconfig.yaml kubectl get pods