github.com/argoproj/argo-cd/v2@v2.10.9/docs/developer-guide/debugging-remote-environment.md (about)

     1  # Debugging a Remote ArgoCD Environment
     2  
     3  In this guide, we will describe how to debug a remote ArgoCD environment with [Telepresence](https://telepresence.io/).
     4  
     5  Telepresence allows you to connect & debug a service deployed in a remote environment and to "cherry-pick" one service to run locally, staying connected to the remote cluster. This will:
     6  
     7  * Reduce resource footprint on the local machine
     8  * Decrease the feedback loop time
     9  * Result in more confidence about the delivered code.
    10  
    11  To read more about it, refer to the official documentation at [telepresence.io](https://telepresence.io/) or [Medium](https://medium.com/containers-101/development-environment-using-telepresence-634bd7210c26).
    12  
    13  ## Install ArgoCD
    14  First of all, install ArgoCD on your cluster
    15  ```shell
    16  kubectl create ns argocd
    17  curl -sSfL https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml | kubectl apply -n argocd -f -
    18  ```
    19  
    20  ## Connect
    21  Connect to one of the services, for example, to debug the main ArgoCD server run:
    22  ```shell
    23  kubectl config set-context --current --namespace argocd
    24  telepresence helm install # Installs telepresence into your cluster
    25  telepresence connect # Starts the connection to your cluster (bound to the current namespace)
    26  telepresence intercept argocd-server --port 8080:http --env-file .envrc.remote # Starts the interception
    27  ```
    28  * `--port` forwards traffic of remote port http to 8080 locally (use `--port 8080:https` if argocd-server terminates TLS)
    29  * `--env-file` writes all the environment variables of the remote pod into a local file, the variables are also set on the subprocess of the `--run` command
    30  
    31  With this, any traffic that hits your argocd-server service in the cluster (e.g. through a LB / ingress) will be forwarded to your laptop on port 8080. So that you can now start argocd-server locally to debug or test new code. If you launch argocd-server using the environment variables in `.envrc.remote`, it is able to fetch all the configmaps, secrets and so on from the cluster and transparently connect to the other microservices so that no further configuration should be necessary, and it behaves exactly the same as in the cluster.
    32  
    33  List current status of Telepresence using:
    34  ```shell
    35  telepresence status
    36  ```
    37  
    38  Stop the intercept using:
    39  ```shell
    40  telepresence leave argocd-server-argocd
    41  ```
    42  
    43  And uninstall telepresence from your cluster:
    44  ```shell
    45  telepresence helm uninstall
    46  ```
    47  
    48  See [this quickstart](https://www.telepresence.io/docs/latest/quick-start/) for more information on how to intercept services using Telepresence.
    49  
    50  ### Connect (telepresence v1)
    51  Use the following command instead:
    52  ```shell
    53  telepresence --swap-deployment argocd-server --namespace argocd --env-file .envrc.remote --expose 8080:8080 --expose 8083:8083 --run bash
    54  ```
    55  * `--swap-deployment` changes the argocd-server deployment
    56  * `--expose` forwards traffic of remote ports 8080 and 8083 to the same ports locally
    57  * `--env-file` writes all the environment variables of the remote pod into a local file, the variables are also set on the subprocess of the `--run` command
    58  * `--run` defines which command to run once a connection is established, use `bash`, `zsh` or others
    59  
    60  ## Debug
    61  Once a connection is established, use your favorite tools to start the server locally.
    62  
    63  ### Terminal
    64  * Compile `make server`
    65  * Run `./dist/argocd-server`
    66  
    67  ### VSCode
    68  In VSCode use the following launch configuration to run argocd-server:
    69  
    70  ```json
    71          {
    72              "name": "Launch argocd-server",
    73              "type": "go",
    74              "request": "launch",
    75              "mode": "auto",
    76              "program": "${workspaceFolder}/cmd/main.go",
    77              "envFile": [
    78                  "${workspaceFolder}/.envrc.remote",
    79              ],
    80              "env": {
    81                  "ARGOCD_BINARY_NAME": "argocd-server",
    82                  "CGO_ENABLED": "0",
    83                  "KUBECONFIG": "/path/to/kube/config"
    84              }
    85          }
    86  ```
    87