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

[WIP] Add simple architecture diagram #22

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
35 changes: 35 additions & 0 deletions docs/architecture-diagrams.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/usr/bin/env python3
"""
Generate architecture diagrams for the documentation
"""
from diagrams import Diagram, Edge, Cluster
from diagrams.k8s.compute import Deployment, Pod
from diagrams.k8s.network import Service
from diagrams.k8s.storage import PVC

IMAGES_DIR = "source/_static/images"

with Diagram("JupyterHub + SSH + SFTP", show=False, outformat="png", filename=f"{IMAGES_DIR}/architecture") as diag:
Copy link
Collaborator

Choose a reason for hiding this comment

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

It would be good to clarify this is assuming we have deployed jupyterhub ssh alongside z2jh.

autohttps = Deployment("autohttps")
ssh = autohttps >> Edge(label="port 22") >> Deployment("jupyterhub-ssh")
sftp = autohttps >> Edge(label="port 2222") >> Deployment("jupyterhub-sftp")
Copy link
Collaborator

Choose a reason for hiding this comment

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

  1. The SFTP k8s service expose a port with name ssh and number 22 (Recent change by me from number 2222)
  2. The SFTP k8s service targets a port with the name ssh on the pod (Recent change by me from targeting port 2222 by number rather than name)
  3. The SFTP k8s pod expose a port with name ssh and number 2222

Services can have sensible numbers <1000, pods should stay above 1000 though to comply with pod security policies etc.

Suggested change
sftp = autohttps >> Edge(label="port 2222") >> Deployment("jupyterhub-sftp")
sftp = autohttps >> Edge(label="port 22") >> Deployment("jupyterhub-sftp")


homedirs = PVC("home directories")

sftp - homedirs

with Cluster("jupyterhub"):
hub = Deployment("hub/proxy")

hub_svc = autohttps >> Edge(label="port 80") >> hub

ssh >> Edge(label="start server if needed", style="bold") >> hub

users = [Pod(f"user{i}") for i in range(2)]

for user in users:
user - homedirs

for user in users:
ssh - Edge(label="console via terminado", color="red", style="bold") - user
hub >> users
1 change: 1 addition & 0 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ sphinx-book-theme
myst_parser[sphinx]
sphinx-copybutton
sphinx<3
diagrams
Binary file added docs/source/_static/images/architecture.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.