Skip to content

Commit a04b168

Browse files
authored
Merge branch 'main' into run-time-main-and-binary
2 parents 1ecc6cc + 7119c08 commit a04b168

File tree

1 file changed

+75
-0
lines changed

1 file changed

+75
-0
lines changed

docs/user-guide/resource-browser.md

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,3 +449,78 @@ spec:
449449
- containerPort: 80
450450
```
451451
{% endcode %}
452+
453+
---
454+
455+
## Port Forwarding
456+
457+
### Introduction
458+
459+
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 [port forwarding](https://kubernetes.io/docs/tasks/access-application-cluster/port-forward-access-application-cluster/). 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.
460+
461+
But first, you would need access to that cluster. Traditionally, the kubeconfig file (`./kube/config`) helps you connect with the cluster.
462+
463+
![Figure 21: Kubeconfig File](https://devtron-public-asset.s3.us-east-2.amazonaws.com/images/kubernetes-resource-browser/kubeconfig.jpg)
464+
465+
### Challenges in Kubeconfig
466+
467+
Kubeconfig becomes painstakingly difficult to maintain especially when it comes to:
468+
* Granting or revoking access to the cluster for multiple people
469+
* Changing the permissions and subsequently the access token
470+
* Adding/Updating/Deleting the entries of cluster URLs and tokens
471+
* Keeping a record of multiple kubeconfig files
472+
473+
### Our Solution
474+
475+
Devtron helps in reducing the challenges and simplifying the maintenance of kubeconfig file through:
476+
* **Devtron's Proxy URL for Cluster** - A standardized URL that you can use in place of your Kubernetes cluster URL.
477+
* **Devtron's Access Token** - A kubectl-compatible token which can be generated and centrally maintained from [Global Configurations → Authorization → API tokens](./global-configurations/authorization/api-tokens.md).
478+
479+
### Steps
480+
481+
**Prerequisite**: An [API token with necessary permissions](./global-configurations/authorization/api-tokens.md) for the user(s) to access the cluster.
482+
483+
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.
484+
485+
![Figure 22: Using Session Token](https://devtron-public-asset.s3.us-east-2.amazonaws.com/images/kubernetes-resource-browser/argocd-token-v1.gif)
486+
487+
1. Go to `~/.kube` folder on your local machine and open the `config` file. Or you may create one with the following content:
488+
489+
{% code title="kubeconfig" overflow="wrap" lineNumbers="true" %}
490+
```yaml
491+
apiVersion: v1
492+
kind: Config
493+
clusters:
494+
- cluster:
495+
insecure-skip-tls-verify: true
496+
server: https://<devtron_host_name>/orchestrator/k8s/proxy/cluster/<cluster_name>
497+
name: devtron-cluster
498+
contexts:
499+
- context:
500+
cluster: devtron-cluster
501+
user: admin
502+
name: devtron-cluster
503+
current-context: devtron-cluster
504+
users:
505+
- name: admin
506+
user:
507+
token: <devtron_token>
508+
```
509+
{% endcode %}
510+
511+
2. Edit the following placeholders in the `server` field and the `token` field:
512+
513+
| Placeholder | Description | Example |
514+
| ------------------- | ----------------------------------- | ----------------------------------------------- |
515+
| <devtron_host_name> | Hostname of the Devtron server | demo.devtron.ai |
516+
| <cluster_name> | Name of the cluster (or cluster ID) | devtron-cluster |
517+
| <devtron_token> | API token or session token | \- |
518+
519+
![Figure 23: Editing Kubeconfig File](https://devtron-public-asset.s3.us-east-2.amazonaws.com/images/kubernetes-resource-browser/kubeconfig.gif)
520+
521+
3. Test the connection to the cluster by running any kubectl command, e.g., `kubectl get ns` or `kubectl get po -A`
522+
523+
4. Once you have successfully connected to the cluster, you may run the port-forward command. Refer [kubectl port-forward](https://kubernetes.io/docs/reference/kubectl/generated/kubectl_port-forward/) to see a few examples.
524+
525+
![Figure 24: Example - Port Forwarding](https://devtron-public-asset.s3.us-east-2.amazonaws.com/images/kubernetes-resource-browser/port-forward.gif)
526+

0 commit comments

Comments
 (0)