Bobcares

Set up Kubernetes Dashboard on an EKS cluster

by | Sep 2, 2021

Wondering how to set up Kubernetes Dashboard on an EKS cluster? We can help you.

Here, at Bobcares, we assist our customers with several AWS queries as part of our AWS Support Services.

Today, let us see how our Support Techs does this task.

 

How to set up Kubernetes Dashboard on an EKS cluster?

Today, let us see the steps followed by our Support Techs to perform the task.

 

Set up your environment

1.Firstly, install kubectl and aws-iam-authenticator.

2.To configure your kubeconfig file to point to the Amazon EKS control plane, run the following command:

$ aws eks update-kubeconfig --name EKS_ClusterName

Note: Replace EKS_ClusterName with your EKS cluster name.

3.o verify that worker nodes are running in your environment, run the following command:

$ kubectl get nodes

4.To verify that the Kubernetes service is running in your environment, run the following command:

$ kubectl get svc

 

Create a Kubernetes Dashboard

1.Deploy the Kubernetes dashboard 

  • For Regions other than Beijing and Ningxia China, apply the Kubernetes dashboard.
    kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.0.5/aio/deploy/recommended.yaml
  • For the Beijing and Ningxia China Region, download, modify, and apply the Calico manifests to your cluster.
    1. Download the Kubernetes Dashboard manifest with the following command.
      curl -o recommended.yaml https://raw.githubusercontent.com/kubernetes/dashboard/blob/master/aio/deploy/recommended.yaml
    2. Modify the manifest files.
      1. View the manifest file or files that you downloaded and note the name of the image.
      2. Download the image locally with the following command.
        docker pull image:<tag>
      3. Tag the image to be pushed to an Amazon Elastic Container Registry repository in China with the following command.
        docker tag image:<tag> <aws_account_id>.dkr.ecr.<cn-north-1>.amazonaws.com.cn/image:<tag>
      4. Update the recommended.yaml to reference the Amazon ECR image URL in your Region.
      5. Update the recommended.yaml file to reference the Amazon ECR image repository in your Region by adding the following to the spec.registry: <aws_account_id>.dkr.ecr.<cn-north-1>.amazonaws.com.cn
      6. Apply the Kubernetes Dashboard manifest.kubectl apply -f recommended.yaml
    3. Apply the manifest to your cluster with the following command.
      kubectl apply -f recommended.yaml

2.Complete the steps to Create an eks-admin service account and cluster role binding

To create the eks-admin service account and cluster role bindingImportant

The example service account created with this procedure has full cluster-admin (superuser) privileges on the cluster.

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
Apply the service account and cluster role binding to your cluster.kubectl apply -f eks-admin-service-account.yamlOutput:serviceaccount "eks-admin" created clusterrolebinding.rbac.authorization.k8s.io "eks-admin" created

3.To forward all requests from your Amazon EC2 instance localhost port to the Kubernetes Dashboard port, run the following command:

$ kubectl port-forward svc/kubernetes-dashboard -n kubernetes-dashboard 6443:443

4.To access the port from your local machine with an SSH tunnel, run the following command:

ssh -i EC2KeyPair.pem ec2-user@IP -L 6443:127.0.0.1:6443

 

Access the Kubernetes Dashboard in a browser

1.To access your Kubernetes Dashboard in a browser, enter https://127.0.0.1:6443.

Note: The Kubernetes Dashboard loads in the browser and prompts you for input.

2.To get a bearer token for authentication (from the Kubernetes website), return to the command line, and run the following command:

$ kubectl -n kube-system describe secret $(kubectl -n kube-system get secret | grep eks-admin | awk ‘{print $1}’)

3.Copy the token from the command line output.

4.In your browser, in the Kubernetes Dashboard pop-up window, choose Token.

5.Paste the token from the output into the Enter token box, and then choose SIGN-IN.

You now have access to the Kubernetes Dashboard in your browser.

 

[Need help with the resolution? We’d be happy to help you out]

 

Conclusion

In short, we saw how our Support Techs set up Kubernetes Dashboard on an EKS cluster.

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Never again lose customers to poor
server speed! Let us help you.