# niloysh/open5gs-k8s architecture

> Architecture diagram of the GitHub repository niloysh/open5gs-k8s, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-11). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/niloysh/open5gs-k8s
- Repository: https://github.com/niloysh/open5gs-k8s

## Overview

##### Project type and purpose
- This is a Kubernetes-based deployment project (“open5gs-k8s”) for Open5GS, an open-source 5G Core network.
- It provides microservices manifests (in `open5gs/`), an all-in-one variant (`open5gs-aio/`), a WebUI (`open5gs-webui/`), MongoDB manifests (`mongodb/`), network attachments for Multus (`networks5g/`), RAN simulation via UERANSIM (`ueransim/`), multi-slice overlays (`msd/`), and Python CLI tools (`mongo-tools/`).

##### File structure
- Top-level directories:
- `open5gs/`, `open5gs-aio/`: core network function (NF) deployments
- `open5gs-webui/`: Web UI deployment
- `mongodb/`: persistent subscriber DB
- `networks5g/`: Multus CNI NADs for N2, N3, N4 interfaces
- `ueransim/`: simulated gNB & UE manifests
- `msd/`: Kustomize multi-slice overlays (slice‐specific SMF/UPF)
- `mongo-tools/`: Python scripts for admin/subscriber management
- `bin/`: helper scripts for logs & shells
- Kubernetes config is managed with Kustomize (`kustomization.yaml` files in each directory).
- The project uses Dockerfiles for custom NF images, and shell scripts to deploy/tear down the core and RAN.

##### README insights
- The README spells out a microservices architecture: each NF (AMF, SMF, UPF, UDM, UDR, NRF, NSSF, AUSF, BSF, PCF, SCP) runs as its own pod.
- Two deployment modes: Standard vs. “Monarch” (monitoring overlay).
- Network attachments define three logical networks (n2, n3, n4) via Multus + OVS-CNI.
- A WebUI and Python CLI/scripts manipulate MongoDB subscriber data.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Kubernetes Cluster
    subgraph "Kubernetes Cluster"
        direction TB
        subgraph "open5gs namespace"
            direction TB
            %% Control-plane NFs
            AMF["AMF"]:::cp
            SMF1["SMF-slice1"]:::cp
            SMF2["SMF-slice2"]:::cp
            PCF["PCF"]:::cp
            UDM["UDM"]:::cp
            UDR["UDR"]:::cp
            AUSF["AUSF"]:::cp
            BSF["BSF"]:::cp
            NRF["NRF"]:::cp
            NSSF["NSSF"]:::cp
            SCP["SCP"]:::cp

            %% User-plane NFs
            UPF1["UPF-slice1"]:::up
            UPF2["UPF-slice2"]:::up

            %% Database
            MongoDB["MongoDB\n(StatefulSet + Service)"]:::db

            %% Management interface
            WebUI["WebUI"]:::mgmt

            %% RAN simulation
            GNB["UERANSIM gNB"]:::ran
            subgraph "UERANSIM UEs"
                direction TB
                UE1["UE1"]:::ran
                UE2["UE2"]:::ran
            end

            %% NetworkAttachments
            NADs["NetworkAttachmentDefinitions\n(n2, n3, n4)"]:::ext

            %% Kustomize configs
            subgraph "Kustomize Configs"
                direction TB
                BaseCore["open5gs/kustomization.yaml"]:::ext
                BaseGN{"msd/bases/open5gs-base\n& ueransim-gnb-base"}:::ext
                Overlays["msd/overlays/..."]:::ext
            end
        end
    end

    %% External systems
    Internet["Internet"]:::ext
    CLI["Python CLI Tools"]:::mgmt

    %% Connections
    GNB -->|N2| AMF
    GNB -->|N3| UPF1
    GNB -->|N3| UPF2
    SMF1 -->|N4| UPF1
    SMF2 -->|N4| UPF2
    SMF1 <-->|"SBI API"| AMF
    SMF1 <-->|"SBI API"| NRF
    SMF2 <-->|"SBI API"| NRF
    PCF <-->|"SBI API"| NRF
    UDM <-->|"SBI API"| NRF
    UDR <-->|"SBI API"| NRF
    AUSF <-->|"SBI API"| NRF
    BSF <-->|"SBI API"| NRF
    NSSF <-->|"SBI API"| NRF
    SCP <-->|"SBI API"| NRF

    WebUI -->|reads/writes| MongoDB
    CLI -->|reads/writes| MongoDB

    UE1 -->|PDU Session| Internet
    UE2 -->|PDU Session| Internet

    %% Click events for component mapping
    click AMF "https://github.com/niloysh/open5gs-k8s/blob/main/open5gs/common/amf/amf-deployment.yaml"
    click SMF1 "https://github.com/niloysh/open5gs-k8s/blob/main/open5gs/slices/slice1/smf1/smf-deployment.yaml"
    click SMF2 "https://github.com/niloysh/open5gs-k8s/blob/main/open5gs/slices/slice2/smf2/smf-deployment.yaml"
    click UPF1 "https://github.com/niloysh/open5gs-k8s/blob/main/open5gs/slices/slice1/upf1/upf-deployment.yaml"
    click UPF2 "https://github.com/niloysh/open5gs-k8s/blob/main/open5gs/slices/slice2/upf2/upf-deployment.yaml"
    click PCF "https://github.com/niloysh/open5gs-k8s/blob/main/open5gs/common/pcf/pcf-deployment.yaml"
    click UDM "https://github.com/niloysh/open5gs-k8s/blob/main/open5gs/common/udm/udm-deployment.yaml"
    click UDR "https://github.com/niloysh/open5gs-k8s/blob/main/open5gs/common/udr/udr-deployment.yaml"
    click AUSF "https://github.com/niloysh/open5gs-k8s/blob/main/open5gs/common/ausf/ausf-deployment.yaml"
    click BSF "https://github.com/niloysh/open5gs-k8s/blob/main/open5gs/common/bsf/bsf-deployment.yaml"
    click NRF "https://github.com/niloysh/open5gs-k8s/blob/main/open5gs/common/nrf/nrf-deployment.yaml"
    click NSSF "https://github.com/niloysh/open5gs-k8s/blob/main/open5gs/common/nssf/nssf-deployment.yaml"
    click SCP "https://github.com/niloysh/open5gs-k8s/blob/main/open5gs/common/scp/scp-deployment.yaml"
    click MongoDB "https://github.com/niloysh/open5gs-k8s/blob/main/mongodb/mongodb-deployment.yaml"
    click MongoDB "https://github.com/niloysh/open5gs-k8s/blob/main/mongodb/mongodb-service.yaml"
    click WebUI "https://github.com/niloysh/open5gs-k8s/blob/main/open5gs-webui/webui-deployment.yaml"
    click WebUI "https://github.com/niloysh/open5gs-k8s/blob/main/open5gs-webui/webui-service.yaml"
    click GNB "https://github.com/niloysh/open5gs-k8s/blob/main/ueransim/ueransim-gnb/gnb-deployment.yaml"
    click UE1 "https://github.com/niloysh/open5gs-k8s/blob/main/ueransim/ueransim-ue/ue1/ue-deployment.yaml"
    click UE2 "https://github.com/niloysh/open5gs-k8s/blob/main/ueransim/ueransim-ue/ue1/ue-deployment.yaml"
    click NADs "https://github.com/niloysh/open5gs-k8s/blob/main/networks5g/network-attachments.yaml"
    click Overlays "https://github.com/niloysh/open5gs-k8s/blob/main/msd/overlays/open5gs-demo/kustomization.yaml"
    click BaseCore "https://github.com/niloysh/open5gs-k8s/blob/main/open5gs/kustomization.yaml"
    click BaseGN "https://github.com/niloysh/open5gs-k8s/blob/main/msd/bases/open5gs-base/kustomization.yaml"
    click BaseGN "https://github.com/niloysh/open5gs-k8s/blob/main/msd/bases/ueransim-gnb-base/kustomization.yaml"
    click CLI "https://github.com/niloysh/open5gs-k8s/blob/main/mongo-tools/add-subscribers.py"

    %% Styles
    classDef cp fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef up fill:#90EE90,stroke:#333,stroke-width:1px
    classDef db fill:#FFFF99,stroke:#333,stroke-width:1px
    classDef ran fill:#FFA500,stroke:#333,stroke-width:1px
    classDef mgmt fill:#DDA0DD,stroke:#333,stroke-width:1px
    classDef ext fill:#D3D3D3,stroke:#333,stroke-width:1px
```
