Skip to content

kubectl config set-credentials

kubectl config set-credentials is a command used to modify the kubeconfig file by setting a user entry.^[400-devops__06-Kubernetes__k8s-ithelp__Day5__README.md]

This command is commonly used to configure authentication credentials, such as bearer tokens, for a specific user context within the Kubernetes configuration.^[400-devops__06-Kubernetes__k8s-ithelp__Day5__README.md]

Usage Example

A typical use case involves authenticating to a kubernetes-dashboard or a cluster using a generated service account token. After obtaining a token (e.g., stored in a variable $TOKEN), the command updates the configuration file to associate the token with a specific user identity.

The following example sets the credentials for the user docker-desktop using a token:^[400-devops__06-Kubernetes__k8s-ithelp__Day5__README.md]

kubectl config set-credentials docker-desktop --token="${TOKEN}"

Sources