Pivotal Knowledge Base

Follow

How to Access Kubernetes Dashboard in Pivotal Container Service

Environment

Pivotal Container Service (PKS) Version 1.0

Purpose

Kubernetes provides a built-in web-based UI for clusters. This interface can be used to manage cluster as well as applications running in the cluster. This article describes how to get credentials to access this web-based UI. We will use kubectl proxy to create a proxy server or application-level gateway between localhost and the Kubernetes API server.

Prerequisites

Procedure

In this example cluster name is pks-bosh. Please substitute it with your respective cluster name.

  • Get credentials using PKS CLI

    pks get-credentials pks-bosh
    
    Fetching credentials for cluster pks-bosh.  
    Context set for cluster pks-bosh. 

    OR

    KUBECONFIG=dashboard_kube_config pks get-credentials pks-bosh

    Fetching credentials for cluster pks-bosh
    Context set for cluster pks-bosh.
  • Start proxy server

    kubectl proxy & 
    [1] 51837
    Starting to serve on 127.0.0.1:8001
    
  • Access the dashboard in browser using - http://127.0.0.1:8001/ui

  • When redirected to the sign in page you can either select Kubeconfig or select Token.

  • If you select kubeconfig browse and select the kubeconfig file saved during the get-credentials step.  

         kubeconfig_kube_dash.png       

To use token follow these steps:

         kubernetes_dashboard.png

  • Get user name

    kubectl config view -o jsonpath='{.contexts[?(@.name == "pks-bosh")].context.user}'
    dcbaac0d-ac11-43f9-96a7-87e3e4fbe48b
    
  • Using user name(dcbaac0d-ac11-43f9-96a7-87e3e4fbe48b) from the previous command derive token to login to UI

    kubectl describe secret $(kubectl get secret | grep dcbaac0d-ac11-43f9-96a7-87e3e4fbe48b | awk '{print $1}') | grep "token:"
    
    token:      eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJkZWZhdWx0Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9zZWNyZXQubmFtZSI6ImRjYmFhYzBkLWFjMTEtNDNmOS05NmE3LTg3ZTNlNGZiZTQ4Yi10b2tlbi12OW1qYyIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VydmljZS1hY2NvdW50Lm5hbWUiOiJkY2JhYWMwZC1hYzExLTQzZjktOTZhNy04N2UzZTRmYmU0OGIiLCJrdWJlcm5ldGVzLmlvL3NlcnZpY2VhY2NvdW50L3NlcnZpY2UtYWNjb3VudC51aWQiOiIwYmNhM2FkYy0xOWVhLTExZTgtOGFhMy0wMDUwNTZhYzQ3YjgiLCJzdWIiOiJzeXN0ZW06c2VydmljZWFjY291bnQ6ZGVmYXVsdDpkY2JhYWMwZC1hYzExLTQzZjktOTZhNy04N2UzZTRmYmU0OGIifQ.pCCDi_Z2-48vFHdlkefFFBnquwR6QxCiX7irhw-NMYYhmEWDF3qwXIKzpToh_cYkS1VI3xYxuTs_4IlPsSAJwJ6BpTMwKscEnzobJ8lFJBnUw3LhBAFrTNsU4wI7LiItS_opuOH2N2EfWrbXiGwGgNst1LRZIzzn0tt82LwhKDoawcmNDwdcublkXdRpZ6CCbqr-MC3y3BGgKF-0THdC_lN8T9CY71iSxyUs_hlnKoAspH7apypSm3IQlATD7E0luDNeRoiMbIyePq9EEynukCMvyH-IlIjmZaH93ZU8LaygNagtUFyCSBhPjIV49xIFiI4utgU6-qKDIhwEJw5TQA
    
  • The alternative command to get this token

    kubectl describe secret $(kubectl describe serviceaccounts dcbaac0d-ac11-43f9-96a7-87e3e4fbe48b | grep Tokens | awk '{print $2}') | grep "token:"
    
  • Enter this token to log in to the dashboard.

Dashboard Preview

kubernetes_dashboard_front.png

Click Nodes to View Resource Usage

kubectl_top.png

Comments

Powered by Zendesk