Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HARMONY-1942: Add optional use of krelay for port forwarding #682

Merged
merged 3 commits into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resort typo

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

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
Loading