Devtron K8s Dashboard
  • Getting Started
    • Overview of Dashboard
    • Prerequisites
    • Install Modern Kubernetes Dashboard
  • User Guide
    • Explore Kubernetes Resources
      • Overview Page
      • Discover and Manage Resources
      • Nodes and Operations
      • Pod Management and Debugging
      • Cluster Terminal
      • Add Monitoring Dashboards/Graphs
      • Run Kubectl Commands Locally
    • Use Resource Watcher
    • Manage Helm Apps
    • Manage Argo CD Apps
    • Manage Flux CD Apps
    • Chart Store
      • Examples
        • Deploying MySQL Helm Chart
        • Deploying MongoDB Helm Chart
  • Operator Guide
    • Projects
    • Clusters
    • OCI Registry
    • Chart Repositories
    • Manage Authorization (RBAC)
      • SSO Login Services
        • Google
        • GitHub
        • GitLab
        • Microsoft
        • LDAP
        • OIDC
          • Keycloak
          • Okta
        • OpenShift
      • User Permissions
      • Permission Groups
      • API Tokens
    • External Links
    • Catalog Framework
    • Charts and Chart Store
    • Show/Hide Argo CD App Listing
    • Show/Hide Flux CD App Listing
    • Configure GUI Schema for Manifests
    • Configure Lock Schema for Manifests
  • Resources
    • Glossary
    • FAQ
Powered by GitBook
On this page
  • Introduction
  • Challenges in Kubeconfig
  • Our Solution
  • Steps
  • Quick Method
  • Manual Method
  • Use Case - Port Forwarding
Export as PDF
  1. User Guide
  2. Explore Kubernetes Resources

Run Kubectl Commands Locally

PreviousAdd Monitoring Dashboards/GraphsNextUse Resource Watcher

Last updated 6 months ago

Introduction

If you wish to run kubectl commands from your local system, you need to have access to your cluster. Traditionally, the kubeconfig file (./kube/config) helps you connect with the cluster from your local system.

Figure 21: Kubeconfig File

Challenges in Kubeconfig

Kubeconfig becomes painstakingly difficult to maintain especially when it comes to:

  • Granting or revoking access to the cluster for multiple people

  • Changing the permissions and subsequently the access token

  • Adding/Updating/Deleting the entries of cluster URLs and tokens

  • Keeping a record of multiple kubeconfig files


Our Solution

Devtron helps in reducing the challenges and simplifying the maintenance of kubeconfig file through:

  • Devtron's Proxy URL for Cluster - A standardized URL that you can use in place of your Kubernetes cluster URL.


Steps

If you are not a super-admin and can't generate a token yourself, you can find the session token (argocd.token) using the Developer Tools available in your web browser as shown below.

There are 2 methods of getting kubeconfig in your system:

Quick Method

  1. In Resource Browser, hover on the cluster name and click the Get kubeconfig icon.

  1. Copy the commands and run them on your terminal.

Manual Method

  1. Go to ~/.kube folder on your local machine and open the config file. Or you may create one with the following content:

kubeconfig
apiVersion: v1
kind: Config
clusters:
- cluster:
    insecure-skip-tls-verify: true
    server: https://<devtron_host_name>/orchestrator/k8s/proxy/cluster/<cluster_name>
  name: devtron-cluster
contexts:
- context:
    cluster: devtron-cluster
    user: admin
  name: devtron-cluster
current-context: devtron-cluster
users:
- name: admin
  user:
    token: <devtron_token>
  1. Edit the following placeholders in the server field and the token field:

Placeholder
Description
Example
Where to Find

<devtron_host_name>

Hostname of the Devtron server

demo.devtron.ai

<cluster_name>

Name of the cluster (or cluster ID)

devtron-cluster

<devtron_token>

API token or session token

-

  1. Test the connection to the cluster by running any kubectl command, e.g., kubectl get ns or kubectl get po -A

Additional References


Devtron's Access Token - A kubectl-compatible token which can be generated and centrally maintained from .

Prerequisite: An for the user(s) to access the cluster.

Figure 22: Using Session Token

Figure 23: Get Kubeconfig

Figure 23: Editing Kubeconfig File

Once the connection is successful, you may run any from your system.

Use Case - Port Forwarding

Assume your applications are running in a Kubernetes cluster on cloud. Now, if you wish to test or debug them on your local machine, you can perform . It creates a tunnel between a port on your machine and a port on a resource within your cluster. Therefore, you can access applications running inside the cluster as though they are running locally on your machine.

Once you have successfully connected to the cluster, you may run the port-forward command. Refer to see a few examples.

Figure 24: Example - Port Forwarding
Global Configurations → Authorization → API tokens
API token with necessary permissions
kubectl operations
port forwarding
kubectl port-forward
Quick Method
Manual Method
Host URL Page
Applications Page
Authorization Page