---
title: How to add a Kubernetes Cluster to Hyperglance
description: Whether it is EKS, AKS, GKE or your own standalone cluster Hyperglance can help you.
---

[Skip to content](https://support.hyperglance.com/knowledge/adding-a-kubernetes-cluster-to-hyperglance#main-content)

English

Show submenu for translations

[More support](https://support.hyperglance.com/knowledge/kb-tickets/new?hsLang=en)

![](https://support.hyperglance.com/hs-fs/hubfs/hyperglance.png?width=100&height=75&name=hyperglance.png)

Open main navigation

Close main navigation

- English
  
  Show submenu for translations
- [More support](https://support.hyperglance.com/knowledge/kb-tickets/new)
- [Contact Us](https://www.hyperglance.com/contact/)

[Contact Us](https://www.hyperglance.com/contact/)

 How can we help you?

- There are no suggestions because the search field is empty.

1. [Hyperglance Support](https://support.hyperglance.com/knowledge?hsLang=en)
2. [Setup & Configuration](https://support.hyperglance.com/knowledge/setup-configuration?hsLang=en)
3. [Kubernetes](https://support.hyperglance.com/knowledge/setup-configuration?hsLang=en#kubernetes)

# How to add a Kubernetes Cluster to Hyperglance

## Whether it is EKS, AKS, GKE or your own standalone cluster Hyperglance can help you.

### **Prerequisites:**

- [kubectl command line tool](https://kubernetes.io/docs/tasks/tools/install-kubectl/) installed. V1.21 or higher required.
- [jq command line tool](https://stedolan.github.io/jq/download/) installed.

**For clusters hosted on AWS or Azure (including EKS and AKS):**

Hyperglance can automatically embed [Kubernetes](https://www.hyperglance.com/platforms/kubernetes/) resources into a broader diagram of your [AWS](https://www.hyperglance.com/platforms/aws/) or [Azure cloud](https://www.hyperglance.com/platforms/azure/).

To do this first add your AWS Account or Azure Subscription to Hyperglance:

- See how to [Add AWS Accounts to Hyperglance](https://support.hyperglance.com/knowledge/adding-new-aws-accounts-to-hyperglance?hsLang=en)
- See how to [Add Azure Subscriptions to Hyperglance](https://support.hyperglance.com/knowledge/azure-collector-setup?hsLang=en)

### Setup Guide:

**Step 1) Associate kubectl with the cluster you wish to add to Hyperglance.**

Pick the appropriate option for you...

- **Option 1) "I already have kubectl pointed at the cluster I wish to use"**

Then you can move onto step 2.

- **Option 2) "My kubectl manages multiple clusters in a kubeconfig file"**

Then switch to the correct cluster using this command:

```
kubectl config use-context <your-context-name>
```

- **Option 3) "I am new and need to setup kubectl from scratch"**

For EKS and AKS users we have outlined some steps below, otherwise you may need to follow instructions specific to your environment or Kubernetes distribution. The Kubernetes website has some helpful links for [getting started with kubectl](https://kubernetes.io/docs/tasks/administer-cluster/access-cluster-api/#accessing-the-kubernetes-api).

**For AWS EKS:**

1. [Install the right version of kubectl](https://docs.aws.amazon.com/eks/latest/userguide/install-kubectl.html).
2. [Install the AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/install-cliv1.html)
3. [Install the aws-iam-authenticator](https://docs.aws.amazon.com/eks/latest/userguide/install-aws-iam-authenticator.html)
4. Authenticate to AWS in a terminal by running this command:  
   **aws configure**
5. Configure kubectl to use your EKS cluster by running this command:  
   **aws eks --region \<region\> update-kubeconfig --name \<your-cluster-name\>**

**For Azure AKS:**

1. [Install kubectl](https://kubernetes.io/docs/tasks/tools/install-kubectl/) (note it is preinstalled on the Azure Cloud Shell)
2. [Install the Azure CLI](https://docs.microsoft.com/en-us/cli/azure/install-azure-cli?view=azure-cli-latest) (note it is preinstalled on the Azure Cloud Shell)
3. Authenticate to Azure in a terminal by running this command:  
   **az login**
4. Configure kubectl to use your AKS cluster by running this command:  
   **az aks get-credentials --resource-group \<your-resource-group\> --name \<your-cluster-name\>**

 

**Step 2) Create read-only access tokens in your cluster for Hyperglance to use**

Download and run the [**hyperglance-config.sh** script at the bottom of this article](https://support.hyperglance.com/knowledge/adding-a-kubernetes-cluster-to-hyperglance#hyperglance-config.sh) to create access tokens.

This script creates a new service account in your Kubernetes cluster and writes the account certificate and token into a new (or existing) kubeconfig file in the same directory called **hyperglance-kubeconfig.conf**

 

**Step 3) Add your Kubernetes cluster details to Hyperglance**

a) In your browser visit the Hyperglance Settings  [https://IP\_address](https://IP_address?hsLang=en). **Make sure you use https as the protocol (not http).**

b) Select **Settings** \> **Platforms**, then click **CONNECT CLUSTER:**

![](https://support.hyperglance.com/hubfs/image-png-Dec-05-2022-06-21-25-8169-PM.png)

c) Fill in the dialog as described below and click submit...

![](https://support.hyperglance.com/hubfs/image-png-Dec-05-2022-06-22-17-7212-PM.png)

- **Cluster Alias**:  Enter a memorable alias to name your cluster within Hyperglance.
- **Kubernetes URL**: Paste in the cluster URL you get from the **hyperglance-kubeconfig.conf** file we generated earlier using the hyperglance\_config.sh script.
- **Kubernetes Token**: Paste in the user token found in the **hyperglance-kubeconfig.conf** file we generated earlier using the hyperglance\_config.sh script.

All being well you should see a new entry created with "Connected" as a status:

![](https://support.hyperglance.com/hubfs/image-png-Dec-05-2022-06-23-43-0551-PM.png)

 

**Step 4) That's it!**

Switch to the Diagram page via the navigation panel on the left:

![](https://support.hyperglance.com/hubfs/image-png-Dec-05-2022-06-24-16-6641-PM.png)

It may take Hyperglance a few minutes to collect all the data but when it's ready it will show in the inventory & diagram.

If you wish to embed your Kubernetes resources within a broader diagram of AWS or Azure cloud then you can [Add your AWS Account](https://support.hyperglance.com/knowledge/adding-new-aws-accounts-to-hyperglance?hsLang=en) or [Add your Azure Subscription](https://support.hyperglance.com/knowledge/azure-collector-setup?hsLang=en) and Hyperglance will automatically work out how to embed Kubernetes resources within your cloud resources.

#### **hyperglance\_config.sh**

This script requires the **jq** command to be available on your PATH. [Instructions to install jq can be found here.](https://stedolan.github.io/jq/download/)

Please Note: Kubectl version 1.21 or higher is required.

```
#!/bin/bashexport SVC_ACT="hyperglance-user"export NAMESPACE="default"export KUBECFG_FILE_NAME="./hyperglance-kubeconfig.conf"export TARGET_FOLDER="test"create_target_folder() {  echo -n "Creating target directory to hold files in ${TARGET_FOLDER}..."  mkdir -p "${TARGET_FOLDER}"  printf "done"}create_service_account() {  echo -e "\\nCreating a service account: ${SVC_ACT}"  kubectl create sa "${SVC_ACT}" --namespace "${NAMESPACE}"}get_secret_name_from_service_account() {  echo -e "\\nGetting secret of service account ${SVC_ACT}-${NAMESPACE}"  SECRET_NAME=$(kubectl get secret/"${SVC_ACT}" --namespace "${NAMESPACE}" -o json | jq -r '.metadata.name')  echo "Secret name: secret/${SECRET_NAME}"}extract_ca_crt_from_secret() {  echo -e -n "\\nExtracting ca.crt from secret..."  kubectl get secret "${SECRET_NAME}" --namespace "${NAMESPACE}" -o json | jq -r '.data["ca.crt"]' | base64 -d > "${TARGET_FOLDER}/ca.crt"  printf "done"}get_user_token_from_secret() {  echo -e -n "\\nGetting user token from secret..."  USER_TOKEN=$(kubectl get secret "${SECRET_NAME}" --namespace "${NAMESPACE}" -o json | jq -r '.data["token"]' | base64 -d)  printf "done"}create_secret_for_new_kubernetes_api() {  cat <<EOF | kubectl apply -f -  apiVersion: v1  kind: Secret  metadata:    name: "${SVC_ACT}"    annotations:      kubernetes.io/service-account.name: "${SVC_ACT}"  type: kubernetes.io/service-account-tokenEOF}set_kube_config_values() {  context=$(kubectl config current-context)  echo -e "\\nSetting current context to: $context"    CLUSTER_NAME=$(kubectl config get-contexts "$context" | awk '{print $3}' | tail -n 1)  echo "Cluster name: ${CLUSTER_NAME}"    ENDPOINT=$(kubectl config view \  -o jsonpath="{.clusters[?(@.name == \"${CLUSTER_NAME}\")].cluster.server}")  echo "Endpoint: ${ENDPOINT}"    # Set up the config  echo -e "\\nPreparing k8s-${SVC_ACT}-${NAMESPACE}-conf"  echo -n "Start a new entry in kubeconfig"  kubectl config set-cluster "${CLUSTER_NAME}" \  --kubeconfig="${KUBECFG_FILE_NAME}" \  --server="${ENDPOINT}" \  --certificate-authority="${TARGET_FOLDER}/ca.crt" \  --embed-certs=true    echo -n "Add tokens to Kubeconfig - the Hyperglance API will use this to access your cluster resources."  kubectl config set-credentials \  "${SVC_ACT}-${NAMESPACE}-${CLUSTER_NAME}" \  --kubeconfig="${KUBECFG_FILE_NAME}" \  --token="${USER_TOKEN}"    echo -n "Add context entry to kubeconfig, this will be used by hyperglance."  kubectl config set-context \  "${SVC_ACT}-${NAMESPACE}-${CLUSTER_NAME}" \  --kubeconfig="${KUBECFG_FILE_NAME}" \  --cluster="${CLUSTER_NAME}" \  --user="${SVC_ACT}-${NAMESPACE}-${CLUSTER_NAME}" \  --namespace="${NAMESPACE}"}create_cluster_role() {cat <<EOF | kubectl apply -f -  apiVersion: rbac.authorization.k8s.io/v1  kind: ClusterRole  metadata:    name: hyperglance-cluster-role  rules:  -    apiGroups:      - ""      - apps      - autoscaling      - batch      - extensions      - policy      - rbac.authorization.k8s.io      - networking.k8s.io    resources:      - componentstatuses      - configmaps      - daemonsets      - deployments      - events      - endpoints      - horizontalpodautoscalers      - ingresses      - jobs      - limitranges      - namespaces      - nodes      - pods      - persistentvolumes      - persistentvolumeclaims      - resourcequotas      - replicasets      - replicationcontrollers      - serviceaccounts      - services    verbs:      - get      - watch      - list  - nonResourceURLs: ["*"]    verbs:      - get      - watch      - listEOF}create_cluster_role_binding() {  cat <<EOF | kubectl apply -f -  apiVersion: rbac.authorization.k8s.io/v1  kind: ClusterRoleBinding  metadata:    name: hyperglance-cluster-role-binding    namespace: "${NAMESPACE}"  roleRef:    apiGroup: rbac.authorization.k8s.io    kind: ClusterRole    name: hyperglance-cluster-role  subjects:  - kind: ServiceAccount    name: ${SVC_ACT}    namespace: "${NAMESPACE}"EOF}create_target_foldercreate_service_accountcreate_secret_for_new_kubernetes_apiget_secret_name_from_service_accountextract_ca_crt_from_secretget_user_token_from_secret  set_kube_config_valuesecho -e "Now Creating RBAC permissions with your current Kubeconfig"create_cluster_rolecreate_cluster_role_bindingecho -n "Now, you can copy the newly generated Kubeconfig file to Hyperglance.  It is called ${KUBECFG_FILE_NAME}"
```

 

- [Before You Start](https://support.hyperglance.com/knowledge/before-you-start?hsLang=en#main-content)

    - [Kubernetes](https://support.hyperglance.com/knowledge/before-you-start?hsLang=en#kubernetes)
    - [GCP](https://support.hyperglance.com/knowledge/before-you-start?hsLang=en#gcp)
    - [AWS](https://support.hyperglance.com/knowledge/before-you-start?hsLang=en#aws)
    - [Azure](https://support.hyperglance.com/knowledge/before-you-start?hsLang=en#azure)
- [Using Hyperglance](https://support.hyperglance.com/knowledge/using-hyperglance?hsLang=en#main-content)

    - [Automations](https://support.hyperglance.com/knowledge/using-hyperglance?hsLang=en#automations)
    - [Inventory & Diagrams](https://support.hyperglance.com/knowledge/using-hyperglance?hsLang=en#inventory-diagrams)
    - [Rules](https://support.hyperglance.com/knowledge/using-hyperglance?hsLang=en#rules)
    - [Cost Management](https://support.hyperglance.com/knowledge/using-hyperglance?hsLang=en#cost-management)
    - [Dashboards](https://support.hyperglance.com/knowledge/using-hyperglance?hsLang=en#dashboards)
    - [Security & Compliance](https://support.hyperglance.com/knowledge/using-hyperglance?hsLang=en#security-compliance)
- [Setup & Configuration](https://support.hyperglance.com/knowledge/setup-configuration?hsLang=en#main-content)

    - [Updating & Migrating](https://support.hyperglance.com/knowledge/setup-configuration?hsLang=en#updating-migrating)
    - [General](https://support.hyperglance.com/knowledge/setup-configuration?hsLang=en#general)
    - [RBAC & Users](https://support.hyperglance.com/knowledge/setup-configuration?hsLang=en#rbac-users)
    - [STIGS & FIPS](https://support.hyperglance.com/knowledge/setup-configuration?hsLang=en#stigs-fips)
    - [AWS](https://support.hyperglance.com/knowledge/setup-configuration?hsLang=en#aws)
    - [Azure](https://support.hyperglance.com/knowledge/setup-configuration?hsLang=en#azure)
    - [Kubernetes](https://support.hyperglance.com/knowledge/setup-configuration?hsLang=en#kubernetes)
    - [GCP](https://support.hyperglance.com/knowledge/setup-configuration?hsLang=en#gcp)
    - [API](https://support.hyperglance.com/knowledge/setup-configuration?hsLang=en#api)
    - [Legacy Docker-based deployments](https://support.hyperglance.com/knowledge/setup-configuration?hsLang=en#legacy-docker-based-deployments)
    - [AI](https://support.hyperglance.com/knowledge/setup-configuration?hsLang=en#ai)

[![Chill listening crop-3](https://support.hyperglance.com/hs-fs/hubfs/hyperglance.png?width=134&height=24&name=hyperglance.png "Chill listening crop-3")](https://www.hyperglance.com/)

2880 Zanker Road, Suite 203, San Jose, CA 95134

<https://www.linkedin.com/company/hyperglance/>

Copyright © 2025 Hyperglance. All rights reserved.