Get Kubernetes Cluster Configuration
A Kubernetes cluster provisioned by the container infrastructure service exposes its kubeconfig through the vinfra CLI. There is no separate REST endpoint documented for this operation, so the CLI is the supported path.
The command prints a kubeconfig with the API server address, the cluster CA, and a client certificate, key, and token for the admin user.
Prerequisites
vinfrainstalled on the machine that runs the command.- A Vietnix Cloud account with access to the project that owns the cluster.
- The cluster name or ID.
Request
vinfra --vinfra-domain <domain_name> \
--vinfra-project <project_name> \
--vinfra-username <username> \
--vinfra-password <password> \
service compute k8saas config <k8s_cluster_name>
vinfra-domainstringrequiredDomain the account belongs to.
vinfra-projectstringrequiredProject that owns the cluster.
vinfra-usernamestringrequiredAccount username.
vinfra-passwordstringrequiredAccount password.
k8s_cluster_namestringrequiredName or ID of the Kubernetes cluster.
Response
apiVersion: v1
clusters:
- cluster:
certificate-authority-data: <...>
server: https://10.94.129.74:6443
name: k8s1
contexts:
- context:
cluster: k8s1
user: admin
name: default
current-context: default
kind: Config
preferences: {}
users:
- name: admin
user:
client-certificate-data: <...>
client-key-data: <...>
token: <...>
Usage
Save the output to a file and point kubectl at it:
vinfra --vinfra-domain <domain_name> \
--vinfra-project <project_name> \
--vinfra-username <username> \
--vinfra-password <password> \
service compute k8saas config k8s1 > k8s1.kubeconfig
chmod 600 k8s1.kubeconfig
export KUBECONFIG=$PWD/k8s1.kubeconfig
kubectl get nodes
The kubeconfig grants cluster-admin rights. Treat it like a password: keep it out of git and out of shared notes, and rotate the cluster credentials if it leaks.
The API server address in the kubeconfig is a private address. Run kubectl from a network that can reach the cluster network, or set up a route or a jump host first.