Retrieve Cluster Credentials and Configuration
This topic describes how to use the
pks get-credentials command in Pivotal Container Service (PKS) using the PKS Command Line Interface (CLI).
pks get-credentials command performs the following actions:
- Fetch the cluster’s kubeconfig
- Add the cluster’s kubeconfig to the existing kubeconfig
- Create a new kubeconfig, if none exists
- Switch the context to the
When you run
pks get-credentials CLUSTER-NAME, PKS sets the context to the cluster you provide as the
PKS binds your username to the cluster and populates the kubeconfig file on your local workstation with cluster credentials and configuration.
The default path for your kubeconfig is
If you access multiple clusters, you can choose to use a custom kubeconfig file for each cluster.
To save cluster credentials to a custom kubeconfig, use the
KUBECONFIG environment variable when you run
$ KUBECONFIG=/path/to/my-cluster.config pks get-credentials my-cluster
Perform the following steps to populate your local kubeconfig with cluster credentials and configuration:
On the command line, run the following command to log in:
pks login -a PKS_API -u USERNAME -p PASSWORD --ca-cert CERT-PATHSee Log in to the PKS CLI for more information about the
Run the following command:
pks get-credentials CLUSTER-NAMEReplace
CLUSTER-NAMEwith the unique name for your cluster. For example:
$ pks get-credentials my-cluster
After PKS populates your kubeconfig, you can use the Kubernetes Command Line Interface (kubectl) to run commands against your Kubernetes clusters.
See Installing the Kubernetes CLI for information about installing kubectl.
For information about using kubectl, refer to the Kubernetes documentation.
Please send any feedback you have to email@example.com.