# n8n-io/n8n-kubernetes-hosting architecture

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

- Interactive diagram: https://gitdiagram.com/n8n-io/n8n-kubernetes-hosting
- Repository: https://github.com/n8n-io/n8n-kubernetes-hosting

## Overview

##### Main Components
- n8n Application Components:
- n8n Deployment: Represents the pod(s) running the n8n container.
- n8n Service: Exposes the n8n deployment (likely for internal or external access).
- n8n Persistent Volume Claim: Represents the persistent storage for n8n, ensuring that any state or configuration data is retained.
- PostgreSQL Database Components:
- PostgreSQL Deployment: Represents the pod(s) running the PostgreSQL container.
- PostgreSQL Service: Exposes the Postgres pod for internal communication from n8n (and possibly external access, if needed).
- PostgreSQL Persistent Volume Claim: Ensures data persistence for the database.
- PostgreSQL ConfigMap and Secret: Represent configuration settings and sensitive data (like passwords) required to properly configure and secure the PostgreSQL instance.
- Namespace:
- A dedicated namespace in Kubernetes as defined by the namespace.yaml, which logically groups the n8n and PostgreSQL resources.

##### Relationships and Interactions
- Illustrating how the persistent volume claims attach to their respective deployments, showing the persistence layer for both the n8n application and the database.
- The ConfigMap and Secret for PostgreSQL should be shown as configuration dependencies for the PostgreSQL deployment.
- Optionally, include an outline of how these components fit within a Kubernetes namespace which encapsulates the resource management boundary.

##### Architectural Patterns and Design Principles
- Containerization: Both n8n and PostgreSQL are deployed as containers managed by Kubernetes.
- Separation of Concerns: There is a clear separation between the application layer (n8n) and the data layer (PostgreSQL), with each component having dedicated resources and configuration files.
- Declarative Infrastructure: The entire architecture is described through Kubernetes YAML files, reflecting a declarative approach to infrastructure management.

##### Incorporate Relevant Technologies
- Kubernetes: The primary platform used for deployment; the YAML files define deployments, services, persistent volume claims, etc.
- n8n: The application or automation tool being deployed.
- PostgreSQL: The relational database system serving as the backend.
- Configuration Management: Use of ConfigMaps and Secrets is critical for managing environment-specific settings and secure configuration data.

## Diagram (Mermaid)

```mermaid
graph TD
  subgraph "Kubernetes Namespace"
    direction TB
    ns["Kubernetes Namespace"]:::namespace
    subgraph "n8n Components"
      direction TB
      n8nPVC["n8n Persistent Volume Claim"]:::pvc
      n8nDeployment["n8n Deployment"]:::deployment
      n8nService["n8n Service"]:::service
      n8nPVC --> n8nDeployment
      n8nDeployment --> n8nService
    end
    subgraph "PostgreSQL Components"
      direction TB
      pgPVC["PostgreSQL Persistent Volume Claim"]:::pvc
      pgConfig["PostgreSQL ConfigMap"]:::config
      pgSecret["PostgreSQL Secret"]:::config
      pgDeployment["PostgreSQL Deployment"]:::deployment
      pgService["PostgreSQL Service"]:::service
      pgPVC --> pgDeployment
      pgConfig --> pgDeployment
      pgSecret --> pgDeployment
      pgDeployment --> pgService
    end
    n8nService -->|"connects-to"| pgService
  end

click ns "https://github.com/n8n-io/n8n-kubernetes-hosting/blob/main/namespace.yaml"
click n8nDeployment "https://github.com/n8n-io/n8n-kubernetes-hosting/blob/main/n8n-deployment.yaml"
click n8nService "https://github.com/n8n-io/n8n-kubernetes-hosting/blob/main/n8n-service.yaml"
click n8nPVC "https://github.com/n8n-io/n8n-kubernetes-hosting/blob/main/n8n-claim0-persistentvolumeclaim.yaml"
click pgDeployment "https://github.com/n8n-io/n8n-kubernetes-hosting/blob/main/postgres-deployment.yaml"
click pgService "https://github.com/n8n-io/n8n-kubernetes-hosting/blob/main/postgres-service.yaml"
click pgPVC "https://github.com/n8n-io/n8n-kubernetes-hosting/blob/main/postgres-claim0-persistentvolumeclaim.yaml"
click pgConfig "https://github.com/n8n-io/n8n-kubernetes-hosting/blob/main/postgres-configmap.yaml"
click pgSecret "https://github.com/n8n-io/n8n-kubernetes-hosting/blob/main/postgres-secret.yaml"

classDef deployment fill:#ffcc99,stroke:#333,stroke-width:2px;
classDef service fill:#ccf,stroke:#333,stroke-width:2px;
classDef pvc fill:#cfc,stroke:#333,stroke-width:2px;
classDef config fill:#fcf,stroke:#333,stroke-width:2px;
classDef namespace fill:#ffe680,stroke:#333,stroke-width:2px;
```
