Skip to content

open-service-portal/service-mongodb-golden-path-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

12 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš€ MongoDB Golden Path Template

The recommended way to provision production-ready MongoDB infrastructure with a single click

What is a Golden Path?

A Golden Path is an opinionated, well-architected solution that represents the best practice for a common use case. Instead of making developers choose between dozens of options and potentially making mistakes, the Golden Path provides a pre-validated, production-ready solution.

🎯 What This Template Does

With one simple request, this template automatically provisions:

Complete Infrastructure Stack

graph TB
    subgraph "What You Get"
        MongoDB["πŸ—„οΈ MongoDB Database<br/>Document Store"]
        Cluster["☸️ Kubernetes Cluster<br/>3 nodes, HA"]
        DNS["🌐 DNS Record<br/>Stable endpoint"]
        Network["πŸ”’ Network Security<br/>Firewall rules"]
    end
    
    subgraph "How It's Connected"
        MongoDB --> Cluster
        DNS --> MongoDB
        Network --> Cluster
    end
    
    Developer["πŸ‘©β€πŸ’» Developer"] -->|"One Template"| MongoDB
    
    style MongoDB fill:#f9f,stroke:#333,stroke-width:4px
    style Developer fill:#bbf,stroke:#333,stroke-width:2px
Loading

πŸ†š Golden Path vs. Individual Components

❌ The Hard Way (Individual Components)

# Step 1: Create a cluster
backstage template:create service-cluster-template

# Step 2: Wait for cluster...
# Step 3: Create DNS
backstage template:create service-dnsrecord-template

# Step 4: Configure DNS to point to cluster...
# Step 5: Create firewall rules
backstage template:create service-firewall-template

# Step 6: Configure network policies...
# Step 7: Finally create MongoDB
backstage template:create service-mongodb-template

# Step 8: Wire everything together...
# Step 9: Hope it all works...

Problems:

  • πŸ”΄ 7+ manual steps
  • πŸ”΄ Complex dependencies to manage
  • πŸ”΄ Easy to misconfigure
  • πŸ”΄ No guarantee components work together
  • πŸ”΄ Time consuming

βœ… The Golden Path (This Template)

# Step 1: Create everything with proper configuration
backstage template:create service-mongodb-golden-path-template

# Done! ✨

Benefits:

  • 🟒 1 step
  • 🟒 Pre-validated configuration
  • 🟒 Guaranteed compatibility
  • 🟒 Production-ready defaults
  • 🟒 5 minutes to production

πŸ“Š Architecture

System Model in Backstage

System: mongodb-stack
β”œβ”€β”€ Resource: mongodb (depends on β†’ cluster, dns)
β”œβ”€β”€ Resource: cluster 
β”œβ”€β”€ Resource: dns (depends on β†’ cluster)
└── Resource: firewall (protects β†’ cluster)

Crossplane Composition

The template uses Crossplane to manage the infrastructure declaratively:

  1. MongoDB XRD defines the API
  2. Composition orchestrates the resource creation:
    • Creates Kubernetes cluster
    • Provisions MongoDB on the cluster
    • Sets up DNS records
    • Configures security rules
  3. Single Claim triggers the entire stack

πŸš€ Quick Start

Prerequisites

  • Backstage instance with this template installed
  • Crossplane installed in your cluster
  • GitHub account for repository creation

Usage

  1. In Backstage UI:

    • Navigate to "Create Component"
    • Select "πŸš€ MongoDB Golden Path"
    • Fill in just 3 fields:
      • Stack name
      • Storage size
      • Team owner
  2. Apply Infrastructure:

    kubectl apply -f https://github.com/open-service-portal/[your-repo]/example.yaml
  3. Get Connection String:

    kubectl get mongodb [stack-name] -o jsonpath='{.status.connString}'

πŸ“ˆ Stacked Services Concept

This template demonstrates the Stacked Services pattern:

Level 1: Base Infrastructure

  • Kubernetes Cluster
  • Network Security

Level 2: Platform Services

  • DNS Management
  • Service Discovery

Level 3: Application Services

  • MongoDB Database
  • Connection Management

Each level depends on the one below, creating a stable, scalable stack.

🎯 When to Use This Template

Use the Golden Path when:

  • βœ… You need a production-ready MongoDB quickly
  • βœ… You want best-practice configuration
  • βœ… You prefer convention over configuration
  • βœ… You're building a standard application

Use Individual Templates when:

  • ⚠️ You have specific infrastructure requirements
  • ⚠️ You need custom networking setup
  • ⚠️ You're integrating with existing infrastructure
  • ⚠️ You need fine-grained control

πŸ“– Backstage Concepts Used

1. Software Templates

  • Defined in template.yaml
  • Uses scaffolder actions to create resources
  • Implements the golden path pattern

2. System Model

  • Groups related components
  • Shows dependencies with dependsOn
  • Creates a system view in the catalog

3. Relations

  • partOf: Components are part of the system
  • dependsOn: Shows resource dependencies
  • ownedBy: Indicates team ownership

4. Catalog Registration

  • Automatically registers all components
  • Creates a unified view in Backstage
  • Enables discovery and documentation

πŸ”§ Customization

While this is an opinionated template, you can customize:

In template.yaml:

  • Adjust parameter defaults
  • Add more configuration options
  • Modify the UI presentation

In composition.yaml:

  • Change cluster size/configuration
  • Adjust MongoDB settings
  • Modify network policies

πŸ“š References & Best Practices

Based on industry best practices and official documentation:

  1. Backstage System Model - How to model infrastructure
  2. Crossplane Compositions - Infrastructure as Code
  3. Golden Path Pattern - Platform engineering concepts
  4. Spotify's Golden Paths - Original concept from Spotify

🀝 Contributing

We welcome contributions! Areas for improvement:

  • Add more cloud provider options
  • Support for different MongoDB configurations
  • Integration with monitoring/observability
  • Cost optimization options
  • Backup and disaster recovery

πŸ“ License

MIT License - See LICENSE file

πŸ†˜ Support


Built with ❀️ by the Platform Engineering Team
Making infrastructure simple, one golden path at a time

About

🎯 Golden Path template - Complete MongoDB stack with frontend, backend, database, and infrastructure

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •