-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from minrk/deployment
Deploy JupyterHub with tofu, helm
- Loading branch information
Showing
30 changed files
with
1,517 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
**/secrets/** filter=git-crypt diff=git-crypt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# pre-commit is a tool to perform a predefined set of tasks manually and/or | ||
# automatically before git commits are made. | ||
# | ||
# Config reference: https://pre-commit.com/#pre-commit-configyaml---top-level | ||
# | ||
# Common tasks | ||
# | ||
# - Run on all files: pre-commit run --all-files | ||
# - Register git hooks: pre-commit install --install-hooks | ||
# | ||
|
||
ci: | ||
# pre-commit.ci will open PRs updating our hooks once a month | ||
autoupdate_schedule: monthly | ||
|
||
exclude: "(.*/)?secrets/.*|code_of_conduct.md|rule_of_participation.md" | ||
|
||
repos: | ||
# autoformat and lint Python code | ||
- repo: https://github.com/astral-sh/ruff-pre-commit | ||
rev: v0.1.14 | ||
hooks: | ||
- id: ruff | ||
types_or: [python, jupyter] | ||
args: ["--fix", "--show-fixes"] | ||
- id: ruff-format | ||
types_or: [python, jupyter] | ||
|
||
# Autoformat: markdown, yaml, javascript (see the file .prettierignore) | ||
- repo: https://github.com/pre-commit/mirrors-prettier | ||
rev: v4.0.0-alpha.8 | ||
hooks: | ||
- id: prettier | ||
|
||
# Autoformat and linting, misc. details | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v4.5.0 | ||
hooks: | ||
- id: end-of-file-fixer | ||
- id: requirements-txt-fixer | ||
- id: check-case-conflict | ||
- id: check-executables-have-shebangs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
--- | ||
# File metadata may be provided as frontmatter YAML | ||
title: Global Fish Tracking System (GFTS) | ||
title: Global Fish Tracking System (GFTS) | ||
subtitle: DESP Use case | ||
description: Making fishing more sustainable | ||
description: Making fishing more sustainable | ||
date: 2023-12-12 | ||
authors: | ||
- id: yellowcap | ||
name: Daniel Wiesmann | ||
orcid: 0000-0002-3190-4278 | ||
corresponding: true | ||
email: [email protected] | ||
email: [email protected] | ||
roles: | ||
- Lead | ||
- User Interface | ||
|
@@ -71,7 +71,7 @@ authors: | |
- Modelling | ||
affiliations: | ||
- ifremer | ||
- id: emmanuelleautret | ||
- id: emmanuelleautret | ||
name: Emmanuelle Autret | ||
orcid: 0000-0002-0979-9192 | ||
corresponding: false | ||
|
@@ -103,7 +103,6 @@ tags: | |
thumbnail: images/gfts.png | ||
--- | ||
|
||
|
||
+++ {"part":"abstract"} | ||
|
||
% The article should include an abstract block at the beginning. The block is delimited by `+++` before and after, and you must specify `"part": "abstract"` as JSON metadata on the block opener. This metadata is required for recognizing the content of this cell as the abstract. | ||
|
@@ -113,15 +112,14 @@ This project entails the implementation of an advanced fish tracking system util | |
|
||
+++ | ||
|
||
<a href="https://w3id.org/ro-id/2edcfa66-0f59-42f4-aa29-1c5681466424"> <img alt="RoHub" src="https://img.shields.io/badge/RoHub-FAIR_Executable_Research_Object-2ea44f?logo=Open+Access&logoColor=blue"></a> | ||
<a href="https://w3id.org/ro-id/2edcfa66-0f59-42f4-aa29-1c5681466424"> <img alt="RoHub" src="https://img.shields.io/badge/RoHub-FAIR_Executable_Research_Object-2ea44f?logo=Open+Access&logoColor=blue"></a> | ||
|
||
# Overview of GFTS DESP use case | ||
|
||
The presentation below has been presented by Mathieu Woillez at the [Roadshow Webinar: DestinE in action – meet the first DESP use cases](https://destination-earth.eu/event/destine-in-action-meet-the-first-desp-use-cases/) (13 December 2023) | ||
|
||
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.10372387.svg)](https://doi.org/10.5281/zenodo.10372387) | ||
|
||
|
||
<style> | ||
.responsive-wrap iframe{ max-width: 100%;} | ||
</style> | ||
|
@@ -130,5 +128,3 @@ The presentation below has been presented by Mathieu Woillez at the [Roadshow We | |
<iframe src="https://docs.google.com/presentation/d/1DMa__GRQXhpkqx4VNWDgHdYr_Z2SsWkc_j3m2E01GUs/embed?start=false&loop=false&delayms=3000" frameborder="0" width="960" height="569" allowfullscreen="true" mozallowfullscreen="true" webkitallowfullscreen="true"></iframe> | ||
<!-- Google embed ends --> | ||
</div> | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
images/user/conda-linux-64.lock: images/user/environment.yml images/user/virtual-packages.yaml | ||
conda-lock lock -k explicit --mamba --channel conda-forge --platform linux-64 --virtual-package-spec images/user/virtual-packages.yaml --filename-template $@ -f $< | ||
|
||
cert-manager: | ||
helm repo add jetstack https://charts.jetstack.io --force-update | ||
helm install --upgrade --namespace cert-manager jetstack/cert-manager --create-namespace --version v1.13.3 --set installCRDs=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
# Deploying GFTS Hub | ||
|
||
This is a log and record of deploying JupyterHub for GFTS | ||
|
||
As much as possible, deployment uses automation via [OpenTofu][], [helm][], but there are always some manual steps. | ||
|
||
[OpenTofu]: https://opentofu.org | ||
[helm]: https://helm.sh | ||
|
||
Initial manual steps: | ||
|
||
1. create bucket for storing tofu state. Create user and store in `secrets/ovh-creds.sh`, and put bucket name in s3 backend configuration | ||
2. create API token for OVH API, store in `secrets/ovh-creds.sh` | ||
|
||
Next, run tofu, which will create the kubernetes cluster | ||
|
||
```bash | ||
tofu init | ||
tofu plan | ||
tofu apply | ||
``` | ||
|
||
At this point, we have a kubernetes cluster. Export the kubernetes cluster config: | ||
|
||
```bash | ||
export KUBECONFIG=$PWD/../jupyterhub/secrets/kubeconfig.yaml | ||
tofu output -raw kubeconfig > $KUBECONFIG | ||
chmod 600 $KUBECONFIG | ||
kubectl config rename-context kubernetes-admin@gfts gfts | ||
kubectl config use-context gfts | ||
``` | ||
|
||
And login to the private image registry: | ||
|
||
```bash | ||
echo $(tofu output -raw registry_builder_token) | docker login $(tofu output -raw registry_url) --username $(tofu output -raw registry_builder_name) --password-stdin | ||
``` | ||
|
||
Now we move to the `jupyterhub` directory. | ||
|
||
Build the image with [chartpress](https://github.com/jupyterhub/chartpress): | ||
|
||
``` | ||
chartpress --push | ||
``` | ||
|
||
and deploy the chart with: | ||
|
||
``` | ||
python deploy.py | ||
``` | ||
|
||
Now jupyterhub should be running at https://gfts.minrk.net | ||
|
||
## Background | ||
|
||
`tofu` is used to deploy cloud resources. | ||
Its configuration is in the `terraform` directory. | ||
We only need to use `tofu` | ||
Once we have kubernetes running, we don't use `tofu` much anymore. | ||
`tofu` is not run on CI, because its actions can be quite destructive. | ||
|
||
`helm` is used to deploy things on kubernetes. | ||
This is the main mechanism by which we modify our jupyterhub deployment. | ||
This can be done on CI (but isn't yet). | ||
|
||
There are two configuration files: | ||
|
||
- gfts-hub/values.yaml is the main configuration file | ||
- secrets/config.yaml is the file containing | ||
|
||
`chartpress` is used to build our user image and update the helm chart | ||
|
||
Deploying updates is two steps: | ||
|
||
1. `chartpress` to ensure the image is up-to-date | ||
2. `helm upgrade` to apply the changes | ||
|
||
To deploy an update: | ||
|
||
``` | ||
python3 deploy.py chartpress | ||
python3 deploy.py helm | ||
``` | ||
|
||
and cleanup your local files: | ||
|
||
``` | ||
chartpress --reset | ||
``` | ||
|
||
## The user image | ||
|
||
The user image is defined in `images/user`. | ||
To change what's in the image, modify `images/user/environment.yml` and run `make images/user/conda-linux-64.lock`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
charts: | ||
- name: gfts-hub | ||
imagePrefix: c63eqfuv.c1.gra9.container-registry.ovh.net/gfts/jupyterhub- | ||
images: | ||
user: | ||
valuesPath: jupyterhub.singleuser.image |
Oops, something went wrong.