Kubeconfig UI Download

Kubectl is a command line interface for running commands against Kubernetes clusters. For more detailed information on using kubectl, you can refer to the Kubectl 101 Tutorial. If you intend to use kubectl in your day-to-day, Critical Stack has provided a simple way to download your kubeconfig directly from the platform UI.

A config file, typically stored in ~/.kube/config, defines the cluster, user, and namespace to use for each kubectl command.

Download Kubeconfig

After logging into the UI, navigate to the settings drop down and select the Download Kubeconfig option. This will download the a file called kubeconfig.txt

dc main

Move Kubeconfig File

At this point you’ll want to make sure this file is moved to the ~/.kube/config directory, and that it is added to the KUBECONFIG environmental variable. To do this first move the file from the downloads directory to the .kube/ directory. Note that the .txt is removed during the move operation:

mv ~/Downloads/kubeconfig.txt ~/.kube/kubeconfig

Once it’s in the /.kube directory, you can add it to your KUBECONFIG environmental variable. To do this run:

export KUBECONFIG=$KUBECONFIG:~/.kube/kubeconfig

To confirm you can use the new kubeconfig, restart your terminal session, and use the kubectl config view command. Your output should be an aggregation of the files located in ~/.kube/ AND that have been added to the KUBECONFIG environmental variable. Example output:

user@host % kubectl config view
apiVersion: v1
- cluster:
    server: https://server1:80
  name: critical-stack
- cluster:
    certificate-authority: /Users/dot302/.minikube/ca.crt
    server: https://server2:80
  name: minikube
- cluster:
- context:
    cluster: critical-stack
    namespace: dev
    user: dev-criticalstack
  name: dev-criticalstack@critical-stack
    cluster: minikube
    user: minikube
  name: minikube
current-context: dev-criticalstack@critical-stack
kind: Config
preferences: {}
- name: dev-criticalstack
- name: minikube