A Pulumi Python project for deploying n8n to Azure Kubernetes Service (AKS).
This project provides infrastructure as code for deploying n8n, a workflow automation platform, to Azure Kubernetes Service (AKS) using Pulumi and Python. The deployment includes:
- An AKS cluster
- PostgreSQL database for n8n
- n8n application with persistent storage
- Proper networking and security configuration
- Python 3.9 or later
- Pulumi CLI
- Azure CLI
- kubectl
- uv for Python environment and package management
pu-py-n8n/
├── .gitignore
├── .python-version # Used by uv to specify Python version
├── .venv/ # Virtual environment created by uv
├── pyproject.toml # Project configuration and dependencies
├── uv.lock # Lock file for dependencies
├── README.md # Project documentation
├── src/
│ └── pu_py_n8n/ # Main package
│ ├── __init__.py
│ ├── main.py # Main Pulumi program
│ ├── config.py # Configuration helpers
│ ├── aks_cluster.py # AKS cluster setup
│ └── n8n_deployment.py # n8n deployment resources
└── tests/
├── __init__.py
├── conftest.py # Pytest configuration and fixtures
├── test_aks_cluster.py # Tests for AKS cluster setup
└── test_n8n_deployment.py # Tests for n8n deployment
Create a Python virtual environment and install dependencies:
# Create a new virtual environment
uv venv
# Activate the virtual environment
source .venv/bin/activate # Linux/macOS
.venv\Scripts\activate # Windows
# Install dependencies
uv syncaz login
az account set --subscription <your-subscription-id>pulumi stack init dev
pulumi config set azure-native:location eastusOptional configuration:
# Resource group name (default: n8n-resources)
pulumi config set resourceGroupName your-resource-group-name
# Kubernetes version (default: 1.26.10)
pulumi config set kubernetesVersion 1.26.10
# Node count (default: 1)
pulumi config set nodeCount 2
# Node size (default: Standard_D2_v2)
pulumi config set nodeSize Standard_D4_v2
# PostgreSQL password (auto-generated if not set)
pulumi config set --secret postgresPassword your-postgres-password
# n8n encryption key (auto-generated if not set)
pulumi config set --secret n8nEncryptionKey your-encryption-key
# n8n JWT secret (auto-generated if not set)
pulumi config set --secret n8nJwtSecret your-jwt-secretpulumi upAfter deployment completes, Pulumi will output:
- Resource group name
- Kubernetes cluster name
- n8n service endpoint URL
- Kubeconfig for connecting to the cluster
Access n8n through the URL provided in the n8n_service_endpoint output.
To clean up all resources:
pulumi destroyThis project includes unit tests using pytest. Run tests with:
uv run pytestMIT License