Skip to content

Commit

Permalink
HARMONY-1942: Add optional use of krelay for port forwarding
Browse files Browse the repository at this point in the history
  • Loading branch information
indiejames committed Jan 17, 2025
1 parent dada91f commit 7e7aa6a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ built-in Kubernetes cluster (including `kubectl`) which can be enabled in prefer
* [openssl](https://www.openssl.org/) Read [this installation guide](https://github.com/openssl/openssl/blob/master/NOTES-WINDOWS.md) if you're a Windows user and openssl is not installed on your machine already.
* [envsubst](https://pypi.org/project/envsubst) - Used to substitute environment variable placeholders inside configuration files.
* [Earthdata Login token in UAT](https://uat.urs.earthdata.nasa.gov) - You will need to create an account and then use the "Generate Token" link from your profile page to obtain a token.
* (optional) [k9s](https://k9scli.io/) - An easy to use GUI for `kubectl`. `k9s` makes it easy to monitor and control your local kubernetes cluster.
* (optional) [krelay](https://github.com/knight42/krelay?tab=readme-ov-file#installation) - If you are running into problems with port forwarding, `krelay` may help.

2. Download this repository (or download the zip file from GitHub)
```bash
Expand All @@ -36,7 +38,12 @@ git clone https://github.com/nasa/harmony.git
```
Edit the `.env` file if you want to add any image tags for a custom service (see the `env-defaults` file). You can skip this step for now if you just want to use the default service tags.

4. Run the bootstrap script and answer the prompts (if any)
4. (optional) Tell Harmony to use `krelay` for port forwarding. You must have installed `krelay` using the link above. This is only advised if you are having issues with the standard port forwarding. One advantage to `krelay` over the standard port forwarding is that with `krelay` the port forwarding will survive pod restarts.
```bash
export USE_KRELAY=true
```

5. Run the bootstrap script and answer the prompts (if any)
```bash
cd harmony && ./bin/bootstrap-harmony
```
Expand Down
9 changes: 8 additions & 1 deletion bin/port-forward
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,14 @@ function start_port_forwarding() {
fi

kubectl wait -n harmony --for=condition=ready pod -l app="$service_name" --timeout=120s
nohup kubectl -n harmony port-forward "service/${service_name}" "${args[@]}" > "logs/port-forward-${service_name}.log" 2>&1 &
if [ "$USE_KRELAY" == "true" ]; then
echo "Using krelay to set up port forwarding for $service_name"
nohup kubectl relay "service/${service_name}" "${args[@]}" -n harmony > "logs/port-forward-${service_name}.log" 2>&1 &
# krelay does not have a good way to indicate that it is ready, so we have to restort to this for right now
sleep 3
else
nohup kubectl -n harmony port-forward "service/${service_name}" "${args[@]}" > "logs/port-forward-${service_name}.log" 2>&1 &
fi
echo "Port forwarding started for service: ${service_name}, port pairs: ${port_pairs[*]}"
}

Expand Down

0 comments on commit 7e7aa6a

Please sign in to comment.