Skip to content

Instantly share code, notes, and snippets.

@lequi
Forked from superseb/README.md
Created April 1, 2019 17:03
Show Gist options
  • Select an option

  • Save lequi/bfb04bf61015834319d2a47864bfea75 to your computer and use it in GitHub Desktop.

Select an option

Save lequi/bfb04bf61015834319d2a47864bfea75 to your computer and use it in GitHub Desktop.

Revisions

  1. @superseb superseb revised this gist Mar 18, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -13,7 +13,7 @@ Save the generated file as `$HOME/.kube/config` and run `kubectl get nodes` to v
    Deploy the kubernetes dashboard by using the recommended deployment definition.

    ```
    kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/master/src/deploy/recommended/kubernetes-dashboard.yaml
    kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v1.10.1/src/deploy/recommended/kubernetes-dashboard.yaml
    kubectl rollout status deploy/kubernetes-dashboard -n kube-system
    ```

  2. @superseb superseb revised this gist Jul 13, 2018. 1 changed file with 10 additions and 0 deletions.
    10 changes: 10 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -102,3 +102,13 @@ Use one of the printed URLs to visit the kubernetes dashboard in your browser.

    When prompted to sign in, choose **Token** and use the token you saved in step 4.


    ## Extra: kubectl proxy

    ```
    kubectl proxy
    ```

    Access dashboard this URL, replacing CLUSTERID with your clusterid (shown in the address bar of your browser):

    http://localhost:8001/k8s/clusters/CLUSTERID/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy/
  3. @superseb superseb revised this gist Jun 28, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -95,7 +95,7 @@ Below are two command to automatically find these parameters:

    ```
    NODEPORT=`kubectl get services/kubernetes-dashboard -n kube-system -o jsonpath="{.spec.ports[0].nodePort}"`
    for NODE in `kubectl get no -o jsonpath='{range.items[*].status.addresses[?(@.type=="InternalIP")]}{"https://"}{.address}{end}'`; do echo $NODE:$NODEPORT; done
    for NODE in `kubectl get no -o jsonpath='{range.items[*].status.addresses[?(@.type=="InternalIP")]}{"https://"}{.address}{"\n"}{end}'`; do echo $NODE:$NODEPORT; done
    ```

    Use one of the printed URLs to visit the kubernetes dashboard in your browser.
  4. @superseb superseb revised this gist Jun 21, 2018. 1 changed file with 1 addition and 2 deletions.
    3 changes: 1 addition & 2 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -1,8 +1,7 @@
    # Deploy kubernetes-dashboard on Rancher 2.0 cluster exposed using NodePort

    ## Requirements
    - `git`
    - `kubectl`
    - `kubectl` (https://kubernetes.io/docs/tasks/tools/install-kubectl/)

    ## Step 1: Generate kubeconfig from the UI

  5. @superseb superseb created this gist Jun 21, 2018.
    105 changes: 105 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,105 @@
    # Deploy kubernetes-dashboard on Rancher 2.0 cluster exposed using NodePort

    ## Requirements
    - `git`
    - `kubectl`

    ## Step 1: Generate kubeconfig from the UI

    Generate the kubeconfig file for your cluster using the `Kubeconfig File` button in the Cluster view of your cluster.
    Save the generated file as `$HOME/.kube/config` and run `kubectl get nodes` to verify it works.

    ## Step 2: Deploy kubernetes dashboard

    Deploy the kubernetes dashboard by using the recommended deployment definition.

    ```
    kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/master/src/deploy/recommended/kubernetes-dashboard.yaml
    kubectl rollout status deploy/kubernetes-dashboard -n kube-system
    ```

    Reference: https://github.com/kubernetes/dashboard/blob/master/README.md

    ## Step 3: Change Service Type to NodePort

    For this guide, we are using a NodePort to access the kubernetes dashboard. By default, the Service gets created as `ClusterIP`.
    You can change that by using the following command:

    ```
    kubectl get svc/kubernetes-dashboard -n kube-system -o yaml | sed 's/ClusterIP/NodePort/g' | kubectl apply -f -
    service "kubernetes-dashboard" configured
    ```

    ## Step 4: Create ServiceAccount and token to login

    Copy the following YAML content and save it as `dashboard.yml`:

    ```
    ---
    apiVersion: v1
    kind: ServiceAccount
    metadata:
    name: admin-user
    namespace: kube-system
    ---
    apiVersion: rbac.authorization.k8s.io/v1beta1
    kind: ClusterRoleBinding
    metadata:
    name: admin-user
    roleRef:
    apiGroup: rbac.authorization.k8s.io
    kind: ClusterRole
    name: cluster-admin
    subjects:
    - kind: ServiceAccount
    name: admin-user
    namespace: kube-system
    ```

    Run the following command to create the needed resources:

    ```
    kubectl create -f dashboard.yml
    ```

    Retrieve the token which can be used to login:

    ```
    kubectl -n kube-system describe secret $(kubectl -n kube-system get secret | grep admin-user | awk '{print $1}')
    ```
    Save the string after `token:` so you can login into the dashboard.

    Example output:

    ```
    Name: admin-user-token-6gl6l
    Namespace: kube-system
    Labels: <none>
    Annotations: kubernetes.io/service-account.name=admin-user
    kubernetes.io/service-account.uid=b16afba9-dfec-11e7-bbb9-901b0e532516
    Type: kubernetes.io/service-account-token
    Data
    ====
    ca.crt: 1025 bytes
    namespace: 11 bytes
    token: eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJrdWJlLXN5c3RlbSIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VjcmV0Lm5hbWUiOiJhZG1pbi11c2VyLXRva2VuLTZnbDZsIiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9zZXJ2aWNlLWFjY291bnQubmFtZSI6ImFkbWluLXVzZXIiLCJrdWJlcm5ldGVzLmlvL3NlcnZpY2VhY2NvdW50L3NlcnZpY2UtYWNjb3VudC51aWQiOiJiMTZhZmJhOS1kZmVjLTExZTctYmJiOS05MDFiMGU1MzI1MTYiLCJzdWIiOiJzeXN0ZW06c2VydmljZWFjY291bnQ6a3ViZS1zeXN0ZW06YWRtaW4tdXNlciJ9.M70CU3lbu3PP4OjhFms8PVL5pQKj-jj4RNSLA4YmQfTXpPUuxqXjiTf094_Rzr0fgN_IVX6gC4fiNUL5ynx9KU-lkPfk0HnX8scxfJNzypL039mpGt0bbe1IXKSIRaq_9VW59Xz-yBUhycYcKPO9RM2Qa1Ax29nqNVko4vLn1_1wPqJ6XSq3GYI8anTzV8Fku4jasUwjrws6Cn6_sPEGmL54sq5R4Z5afUtv-mItTmqZZdxnkRqcJLlg2Y8WbCPogErbsaCDJoABQ7ppaqHetwfM_0yMun6ABOQbIwwl8pspJhpplKwyo700OSpvTT9zlBsu-b35lzXGBRHzv5g_RA
    ```

    Reference: https://github.com/kubernetes/dashboard/wiki/Creating-sample-user

    ## Step 5: Login to the dashboard

    We need to access the IP of one of the nodes added to your cluster, on the randomly chosen `NodePort` we configured earlier.
    Below are two command to automatically find these parameters:

    ```
    NODEPORT=`kubectl get services/kubernetes-dashboard -n kube-system -o jsonpath="{.spec.ports[0].nodePort}"`
    for NODE in `kubectl get no -o jsonpath='{range.items[*].status.addresses[?(@.type=="InternalIP")]}{"https://"}{.address}{end}'`; do echo $NODE:$NODEPORT; done
    ```

    Use one of the printed URLs to visit the kubernetes dashboard in your browser.

    When prompted to sign in, choose **Token** and use the token you saved in step 4.