Skip to content

πŸ“¦ cookiecutter-kubernetes-deployment is a template generator for deploying applications using Helm and Kustomize on Kubernetes.

License

Notifications You must be signed in to change notification settings

goabonga/cookiecutter-kubernetes-deployment

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

17 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš€ cookiecutter-kubernetes-deployment

cookiecutter-kubernetes-deployment is a template generator for deploying applications using Helm and Kustomize on Kubernetes. This template facilitates the creation of environment-specific configurations for any Helm applications, supporting both development and production configurations via Kustomize overlays.

🎯 Features

  • Helm & Kustomize Deployment: Automates the generation of Helm charts and Kustomize overlays, making deployments modular and environment-specific.
  • Dynamic Helm Chart Details: Uses a post-generation script to automatically retrieve the latest chart versions and values, keeping deployments up-to-date.
  • Environment Overlays: Separate development and production overlays to streamline configuration management for different Kubernetes environments.
  • Automated Setup via Post-Generation Hook: Automatically configures Helm and Kustomize files to reduce manual setup, ensuring that the deployment is production-ready out of the box.

πŸ“‚ Project Structure

The generated project includes:

keycloak/
β”œβ”€β”€ base
β”‚   └── kustomization.yaml           # Base configurations for Kustomize
β”œβ”€β”€ overlays
β”‚   β”œβ”€β”€ development
β”‚   β”‚   β”œβ”€β”€ kustomization.yaml       # Development-specific overlay configurations
β”‚   β”‚   └── secret-generator.yaml    # Secrets for development environment
β”‚   └── production
β”‚       β”œβ”€β”€ kustomization.yaml       # Production-specific overlay configurations
β”‚       └── secret-generator.yaml    # Secrets for production environment
β”œβ”€β”€ README.md                        # Project documentation
β”œβ”€β”€ resources
β”‚   β”œβ”€β”€ kustomization.yaml           # Additional Kustomize resources
β”‚   └── upstream.yaml                # Configurations for the Helm chart
β”œβ”€β”€ upstream
β”‚   β”œβ”€β”€ Chart.lock                   # Lock file for Helm dependencies
β”‚   β”œβ”€β”€ charts
β”‚   β”‚   └── keycloak-24.1.0.tgz      # Packaged Helm chart
β”‚   β”œβ”€β”€ Chart.yaml                   # Helm chart metadata
β”‚   β”œβ”€β”€ README.md                    # Documentation for Helm chart
β”‚   └── values.yaml                  # Default Helm values
└── upstream.sh                      # Script to handle Helm and Kustomize setup

πŸ“¦ Getting Started

  1. Install CookieCutter:

    Ensure that you have CookieCutter installed:

    pip install cookiecutter
  2. Install Helm and Helm-Docs:

    Helm and Helm-Docs are required to use this CookieCutter template:

    # Install Helm
    curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash
    
    # Install Helm-Docs
    curl -sSL "https://github.com/norwoodj/helm-docs/releases/download/v1.14.2/helm-docs_1.14.2_Linux_x86_64.tar.gz" | tar xz
    sudo mv helm-docs /usr/local/bin/
    
  3. Generate a New Project:

    Use CookieCutter with this template to initialize a new deployment:

    cookiecutter https://github.com/goabonga/cookiecutter-kubernetes-deployment.git

    This will prompt you for basic project details (e.g., project name, namespace, Helm repository). Once completed, the project structure will be generated.

  4. Configure Your Deployment:

    Inside the generated project directory:

    • Customize Values: Modify values.yaml under the upstream directory to adjust Helm chart settings.
    • Environment-specific Configurations: Edit secret-generator.yaml and other overlay configurations in overlays/production or overlays/development as needed.
  5. Deploy Your Application:

    Use Kustomize and Helm commands to deploy the application, adjusting the environment as needed:

    # For development
    kubectl apply -k overlays/development
    
    # For production
    kubectl apply -k overlays/production

πŸ”§ Post-Generation Script

The template includes a post_gen_project.py hook script that automatically sets up the Helm chart and configures values for Helm deployment. Here’s how it works:

  • Fetch Helm Chart Details: Retrieves the latest version of the Helm chart and populates Chart.yaml and values.yaml accordingly.
  • Chart Customization: Generates a Chart.yaml with the specified app version and alias (if provided).
  • Run Initialization Scripts: Executes upstream.sh to handle any additional setup and initializes helm-docs for automatic documentation generation.

πŸ€‘ Customization Options

The configuration file allows setting the following parameters for project customization:

{
   "name": "keycloak",
  "version": "latest",
  "namespace": "default",
  "alias": null,
  "repository": "https://charts.bitnami.com/bitnami",
  "author_name": "Chris <goabonga@pm.me>",
  "license": "MIT"
}

πŸ€“ Contributing

We welcome contributions to enhance this template. If you have suggestions, feel free to submit a pull request or open an issue.

πŸ“œ License

This project is licensed under the MIT License. See the LICENSE file for more details.


Happy deploying with cookiecutter-kubernetes-deployment! πŸš€

About

πŸ“¦ cookiecutter-kubernetes-deployment is a template generator for deploying applications using Helm and Kustomize on Kubernetes.

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published

Contributors 3

  •  
  •  
  •