# opswat/metadefender-k8s architecture

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

- Interactive diagram: https://gitdiagram.com/opswat/metadefender-k8s
- Repository: https://github.com/opswat/metadefender-k8s

## Overview

##### Main Components
- Infrastructure Provisioning: Represent Terraform modules that span different cloud providers (AWS, Azure, GCloud). These modules include:
- EKS cluster (or equivalent Kubernetes offerings)
- Database provisioning (e.g., aws_rds_postgres_module for Postgres)
- Cloud-functions for Azure (webhook notifications) located under terraform/CloudFunctions.
- Kubernetes Cluster Components: Inside the cluster the deployment is handled via multiple Helm charts:
- “mdcore” chart for MetaDefender Core
- “mdss” chart for MetaDefender Storage Security
- “mdssc” chart (and possibly others) for additional modules
- “icap” chart for the ICAP-related components and the associated ingress configurations (see the separate icap_ingress directory).
- Supporting Scripts and Workflows: Include example scripts and GitHub workflows that automate the CI/CD as well as provider-specific installation scenarios.
- External Integrations: If shown, external services like cloud functions (Azure webhook notifications) and any external ingress controller (provided by icap_ingress configurations).

##### Relationships and Interactions
- Inside the cluster, show the deployment segmentation:
- How the Helm charts deploy various components such as Deployments, Services, Ingresses, and CronJobs.
- Ingress pathway by connecting the “icap_ingress” configuration to frontend exposure of services; this shows how incoming traffic might be routed to the respective internal services.
- Example scripts (under example_scripts) to both the provisioning (script-based installation) and the Kubernetes components (configurations like HPA, role-binding, autoscalers) to show they are used to fine-tune deployment on the cluster.

##### Architectural Patterns and Design Principles
- Infrastructure as Code (IaC): Highlight the Terraform modules and configuration files that provide a repeatable and scalable method to provision cloud resources.
- Declarative Deployment: Stress that Helm charts are used to declaratively manage Kubernetes deployments, configurations and secrets.
- CI/CD Integration: Show the use of GitHub Actions for automating deployments and checks.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Infrastructure Provisioning Layer
    subgraph "Infrastructure Provisioning (Terraform)"
        AWS["AWS: EKS Cluster & RDS"]:::iac
        Azure["Azure: Managed Kubernetes"]:::iac
        GCloud["GCloud Resources"]:::iac
        AzureCF["Azure Cloud Functions (Webhook)"]:::iac
    end

    %% Intermediate node representing the provisioned Kubernetes Cluster
    K8s["Provisioned Kubernetes Cluster"]:::cluster

    %% Kubernetes Cluster Deployment Layer (Helm Charts)
    subgraph "Kubernetes Cluster (Helm Charts)"
        direction TB
        MDCore["MetaDefender Core (mdcore)"]:::helm
        MDSS["MetaDefender Storage Security (mdss)"]:::helm
        MDSSC["Additional Module (mdssc)"]:::helm
        ICAP["ICAP Components"]:::helm
        Ingress["ICAP Ingress Config"]:::ingress
    end

    %% CI/CD & Automation Layer
    subgraph "CI/CD & Automation"
        Workflows["GitHub Actions Workflows"]:::cicd
        Examples["Supporting Example Scripts"]:::scripts
    end

    %% Arrows: Infrastructure Provisioning to Provisioned Kubernetes Cluster
    AWS --> K8s
    Azure --> K8s
    GCloud --> K8s
    AzureCF --> K8s

    %% Arrows: Provisioned Cluster to Helm Chart Deployments
    K8s --> MDCore
    K8s --> MDSS
    K8s --> MDSSC
    K8s --> ICAP
    ICAP -->|"configures"| Ingress

    %% Arrows: CI/CD triggers and automation flows
    Workflows -->|"triggers"| AWS
    Workflows --> Azure
    Workflows --> GCloud
    Workflows --> AzureCF
    Workflows -->|"deploys"| K8s
    Examples -->|"tweaks"| K8s

    %% Click Events for Component Mapping
    click AWS "https://github.com/opswat/metadefender-k8s/tree/main/terraform/aws"
    click Azure "https://github.com/opswat/metadefender-k8s/tree/main/terraform/azure"
    click GCloud "https://github.com/opswat/metadefender-k8s/tree/main/terraform/gcloud"
    click AzureCF "https://github.com/opswat/metadefender-k8s/tree/main/terraform/CloudFunctions/Azure/webhook-notification"
    click MDCore "https://github.com/opswat/metadefender-k8s/tree/main/helm_charts/mdcore"
    click MDSS "https://github.com/opswat/metadefender-k8s/tree/main/helm_charts/mdss"
    click MDSSC "https://github.com/opswat/metadefender-k8s/tree/main/helm_charts/mdssc"
    click ICAP "https://github.com/opswat/metadefender-k8s/tree/main/helm_charts/icap"
    click Ingress "https://github.com/opswat/metadefender-k8s/tree/main/icap_ingress"
    click Workflows "https://github.com/opswat/metadefender-k8s/tree/main/.github/workflows"
    click Examples "https://github.com/opswat/metadefender-k8s/tree/main/example_scripts"

    %% Styles for color coding of layers and components
    classDef iac fill:#f9dede,stroke:#e34a4a,stroke-width:2px;
    classDef cluster fill:#d0e6f7,stroke:#2a9fd6,stroke-width:2px;
    classDef helm fill:#e4f7d6,stroke:#82bf26,stroke-width:2px;
    classDef cicd fill:#fff3cd,stroke:#ffb400,stroke-width:2px;
    classDef scripts fill:#e0d1f9,stroke:#8a2be2,stroke-width:2px;
    classDef ingress fill:#fce3a8,stroke:#f0ad4e,stroke-width:2px;
```
