Skip to content

Instantly share code, notes, and snippets.

@arunjayakumar01
Last active August 9, 2020 18:43
Show Gist options
  • Save arunjayakumar01/8c7342a03df0b83e51e8414d200223b9 to your computer and use it in GitHub Desktop.
Save arunjayakumar01/8c7342a03df0b83e51e8414d200223b9 to your computer and use it in GitHub Desktop.

kubernetes dashboard deployment - AWS EKS

Dashboard is a web-based Kubernetes user interface. You can use Dashboard to deploy containerized applications to a Kubernetes cluster, troubleshoot your containerized application, and manage the cluster resources. You can use Dashboard to get an overview of applications running on your cluster, as well as for creating or modifying individual Kubernetes resources (such as Deployments, Jobs, DaemonSets, etc). For example, you can scale a Deployment, initiate a rolling update, restart a pod or deploy new applications using a deploy wizard.

Dashboard also provides information on the state of Kubernetes resources in your cluster and on any errors that may have occurred.

  • Check metric server is installed in your cluster
     kubectl get deployment metrics-server -n kube-system
    
  • If above commands returns nothing, Install metric server by
     kubectl apply -f https://github.com/kubernetes-sigs/metrics-server/releases/download/v0.3.6/components.yaml
    
  • Deploy Kubernetes dashboard
     kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.0.0-beta8/aio/deploy/recommended.yaml
    
  • Create a file called eks-admin-service-account.yaml with the text below. This manifest defines a service account and cluster role binding called eks-admin.
apiVersion: v1
kind: ServiceAccount
metadata:
  name: eks-admin
  namespace: kube-system
---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRoleBinding
metadata:
  name: eks-admin
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: cluster-admin
subjects:
- kind: ServiceAccount
  name: eks-admin
  namespace: kube-system

Expose dashboard

  • To expose the dasboard through a domain, edit the service and add the ingress by editing the domain name
    • Edit the kubernetes dashboard
       KUBE_EDITOR="nano" kubectl edit svc kubernetes-dashboard -n kubernetes-dashboard
      
    • Change type ClusterIP to NodePort and save
    • Create a file called kubernetes-dashboard-ingresss.yaml with the text below
apiVersion: extensions/v1beta1  
kind: Ingress  
metadata:  
  annotations:  
    kubernetes.io/ingress.class: nginx  
    nginx.ingress.kubernetes.io/backend-protocol: "HTTPS"  
  # type of authentication  
  nginx.ingress.kubernetes.io/auth-type: basic  
    # name of the secret that contains the user/password definitions  
  nginx.ingress.kubernetes.io/auth-secret: basic-auth-kube-dashboard  
    # message to display with an appropriate context why the authentication is required  
  nginx.ingress.kubernetes.io/auth-realm: 'Authentication Required - '  
  
  name: ingress-kubernetes-dashboard  
  namespace: kubernetes-dashboard  
  labels:  
    k8s-app: kubernetes-dashboard  
spec:  
  rules:  
    - host: kubernetes-dashboard.domain.com  
      http:  
        paths:  
          - backend:  
              serviceName: kubernetes-dashboard  
              servicePort: 443  
            path: /  
  tls:  
    - hosts:  
        - mapclub-kubernetes-dashboard.accubits.com  
      secretName: kubernetes-dashboard.domain.com-tls
  • Replace the secret with the domain SSL secret .Comment out TLS section, if you want to disable HTTPS ,
  • A basic auth is aaded to the ingress , disable it by commenting out the annotations
  • Add ingress to the cluster
     kubectl apply -f kubernetes-dashboard-ingresss.yaml
    
  • To get the token for login
     kubectl -n kube-system describe secret $(kubectl -n kube-system get secret | grep eks-admin | awk '{print $1}')
    

Reference

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment