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 the spec.clusterRef.namespacefield in the SpaceInstance object)
- $LOFT_HOST: the loft 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://$LOFT_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