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.
- 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
andproduction
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.
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
-
Install CookieCutter:
Ensure that you have CookieCutter installed:
pip install cookiecutter
-
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/
-
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.
-
Configure Your Deployment:
Inside the generated project directory:
- Customize Values: Modify
values.yaml
under theupstream
directory to adjust Helm chart settings. - Environment-specific Configurations: Edit
secret-generator.yaml
and other overlay configurations inoverlays/production
oroverlays/development
as needed.
- Customize Values: Modify
-
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
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
andvalues.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 initializeshelm-docs
for automatic documentation generation.
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"
}
We welcome contributions to enhance this template. If you have suggestions, feel free to submit a pull request or open an issue.
This project is licensed under the MIT License. See the LICENSE file for more details.
Happy deploying with cookiecutter-kubernetes-deployment! π