mirror of
https://github.com/hanzoai/deploy.git
synced 2026-10-07 08:44:50 +00:00
Two corrections on top of the naming pass, both found by checking the live cluster rather than the source. The rename had silently changed the user-facing annotation key from argocd.argoproj.io/sync-wave to cd.argoproj.io/sync-wave — 63 live Applications carry the old key, so deploying that would have ignored every sync-wave and broken fleet deploy ordering. The key is now cd.hanzo.ai/*, and universe 575650286 moves the ApplicationSet template that stamps it, so the controller regenerates all 63 consistently. The API group in code said argoproj.io/v1alpha1 in 157 places while the cluster has served apps.hanzo.ai/v1alpha1 since 2026-07-23 (the CRDs are applications.apps.hanzo.ai). Code now matches what is actually served. The legacy applications.argoproj.io/app-name label had ZERO live users, so it went with the rest. foo.argoproj.io test fixtures became foo.example.com — arbitrary test domains should not carry a vendor name. go build ./... exit 0. Co-authored-by: Hanzo Dev <[email protected]>
88 lines
3.8 KiB
Markdown
88 lines
3.8 KiB
Markdown
# Debugging a Remote Hanzo CD Environment
|
|
|
|
In this guide, we will describe how to debug a remote Hanzo CD environment with [Telepresence](https://telepresence.io/).
|
|
|
|
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:
|
|
|
|
* Reduce resource footprint on the local machine
|
|
* Decrease the feedback loop time
|
|
* Result in more confidence about the delivered code.
|
|
|
|
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).
|
|
|
|
## Install Hanzo CD
|
|
First of all, install Hanzo CD on your cluster
|
|
```shell
|
|
kubectl create ns cd
|
|
curl -sSfL https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml | kubectl apply -n cd -f -
|
|
```
|
|
|
|
## Connect
|
|
Connect to one of the services, for example, to debug the main Hanzo CD server run:
|
|
```shell
|
|
kubectl config set-context --current --namespace cd
|
|
telepresence helm install --set-json agent.securityContext={} # Installs telepresence into your cluster
|
|
telepresence connect # Starts the connection to your cluster (bound to the current namespace)
|
|
telepresence intercept cd-server --port 8080:http --env-file .envrc.remote # Starts the interception
|
|
```
|
|
* `--port` forwards traffic of remote port http to 8080 locally (use `--port 8080:https` if cd-server terminates TLS)
|
|
* `--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
|
|
|
|
With this, any traffic that hits your cd-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 cd-server locally to debug or test new code. If you launch cd-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.
|
|
|
|
List current status of Telepresence using:
|
|
```shell
|
|
telepresence status
|
|
```
|
|
|
|
Stop the intercept using:
|
|
```shell
|
|
telepresence leave cd-server
|
|
```
|
|
|
|
And uninstall telepresence from your cluster:
|
|
```shell
|
|
telepresence helm uninstall
|
|
```
|
|
|
|
See [this quickstart](https://www.telepresence.io/docs/latest/quick-start/) for more information on how to intercept services using Telepresence.
|
|
|
|
### Connect (telepresence v1)
|
|
Use the following command instead:
|
|
```shell
|
|
telepresence --swap-deployment cd-server --namespace cd --env-file .envrc.remote --expose 8080:8080 --expose 8083:8083 --run bash
|
|
```
|
|
* `--swap-deployment` changes the cd-server deployment
|
|
* `--expose` forwards traffic of remote ports 8080 and 8083 to the same ports locally
|
|
* `--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
|
|
* `--run` defines which command to run once a connection is established, use `bash`, `zsh` or others
|
|
|
|
## Debug
|
|
Once a connection is established, use your favorite tools to start the server locally.
|
|
|
|
### Terminal
|
|
* Compile `make server`
|
|
* Run `./dist/cd-server`
|
|
|
|
### VSCode
|
|
In VSCode use the following launch configuration to run cd-server:
|
|
|
|
```json
|
|
{
|
|
"name": "Launch cd-server",
|
|
"type": "go",
|
|
"request": "launch",
|
|
"mode": "auto",
|
|
"program": "${workspaceFolder}/cmd/main.go",
|
|
"envFile": [
|
|
"${workspaceFolder}/.envrc.remote",
|
|
],
|
|
"env": {
|
|
"CD_BINARY_NAME": "cd-server",
|
|
"CGO_ENABLED": "0",
|
|
"KUBECONFIG": "/path/to/kube/config"
|
|
}
|
|
}
|
|
```
|
|
|