https://github.com/anqorithm/fastapi-helm-chart
This repository contains a Helm chart for a FastAPI application to be deployed on OpenShift clusters with minimal effort with customizable configurations.
https://github.com/anqorithm/fastapi-helm-chart
automation cicd deployment devops docker fastapi helm k8s kubernetes oc openshift poetry python sre
Last synced: about 1 month ago
JSON representation
This repository contains a Helm chart for a FastAPI application to be deployed on OpenShift clusters with minimal effort with customizable configurations.
- Host: GitHub
- URL: https://github.com/anqorithm/fastapi-helm-chart
- Owner: anqorithm
- License: mit
- Created: 2025-02-14T09:16:06.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-02-15T07:40:17.000Z (about 1 year ago)
- Last Synced: 2025-10-13T09:28:42.839Z (5 months ago)
- Topics: automation, cicd, deployment, devops, docker, fastapi, helm, k8s, kubernetes, oc, openshift, poetry, python, sre
- Language: Smarty
- Homepage:
- Size: 685 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://artifacthub.io/packages/search?repo=fastapi-helm-chart)
[](https://helm.sh)
[](https://www.openshift.com)
[](https://kubernetes.io)
[](https://fastapi.tiangolo.com)
[](https://www.docker.com)
[](https://python-poetry.org)
[](LICENSE)

[](https://github.com/anqorithm/fastapi-helm-chart/issues)
[](https://github.com/anqorithm/fastapi-helm-chart/pulls)
[](https://github.com/anqorithm/fastapi-helm-chart/graphs/contributors)
[](https://github.com/anqorithm/fastapi-helm-chart/network)
[](https://github.com/anqorithm/fastapi-helm-chart/stargazers)
[](https://github.com/anqorithm/fastapi-helm-chart/watchers)
# FastAPI Helm Chart
This repository contains a Helm chart for a FastAPI application to be deployed on OpenShift clusters with minimal effort with customizable configurations.
## Prerequisites
- Helm CLI (version 3+)
- OpenShift Cluster (version 4.x recommended)
- Docker (for building application images)
- Poetry (for Python dependency management)

## Configuration
The following tables describe the configurable parameters of the FastAPI Helm chart. You can override these values by creating your own values.yaml file.
### Core Configuration
| Parameter | Description | Default |
|-----------|-------------|---------|
| `replicaCount` | Number of replicas of the FastAPI application | `1` |
### Image Configuration
| Parameter | Description | Default |
|-----------|-------------|---------|
| `image.registry` | Docker registry for the FastAPI image | `""` |
| `image.repository` | Docker image repository | `""` |
| `image.tag` | Docker image tag | `""` |
| `image.pullPolicy` | Image pull policy (Always, IfNotPresent, Never) | `IfNotPresent` |
| `imagePullSecrets` | Image pull secrets for private registries | `[]` |
### Network Configuration
| Parameter | Description | Default |
|-----------|-------------|---------|
| `service.type` | Kubernetes service type (ClusterIP, LoadBalancer, NodePort) | `ClusterIP` |
| `service.port` | Service port for accessing the application | `80` |
### Environment Variables (ConfigMap)
You can define as many environment variables as needed in the configMap. The chart comes with some default FastAPI application environment variables. These variables will be available to your FastAPI application at runtime.
| Parameter | Description | Default |
|-----------|-------------|---------|
| `configMap.data.APP_NAME` | Name of the FastAPI application | `"Example FastAPI App"` |
| `configMap.data.DEBUG` | Enable debug mode (true/false) | `false` |
| `configMap.data.VERSION` | Application version | `"0.1.0"` |
To add or modify environment variables, you can update the `configMap.data` section in your values.yaml file. For example:
```yaml
configMap:
data:
APP_NAME: "My FastAPI Application"
DEBUG: "false"
VERSION: "1.0.0"
CUSTOM_VAR: "custom-value" # Add your custom variables here
```
### OpenShift Route Configuration
| Parameter | Description | Default |
|-----------|-------------|---------|
| `route.enabled` | Enable OpenShift route for external access | `false` |
| `route.host` | Route hostname (e.g., myapp.apps.cluster.com) | `""` |
| `route.path` | Route path | `/` |
| `route.tls.enabled` | Enable TLS for secure routes | `false` |
| `route.tls.termination` | TLS termination type (edge, passthrough, reencrypt) | `edge` |
| `route.tls.insecureEdgeTerminationPolicy` | How to handle insecure traffic | `Allow` |
### Resource Management
| Parameter | Description | Default |
|-----------|-------------|---------|
| `resources.limits.cpu` | Maximum CPU allocation | `""` |
| `resources.limits.memory` | Maximum memory allocation | `""` |
| `resources.requests.cpu` | Minimum CPU requirement | `""` |
| `resources.requests.memory` | Minimum memory requirement | `""` |
### Scheduling Configuration
| Parameter | Description | Default |
|-----------|-------------|---------|
| `nodeSelector` | Node labels for pod assignment | `{}` |
| `tolerations` | Pod tolerations for node taints | `[]` |
| `affinity` | Pod affinity/anti-affinity rules | `{}` |
## Build the Docker image
### Build
```bash
docker build -t {YOUR_DOCKER_REGISTRY}/{YOUR_DOCKER_IMAGE_NAME}:{YOUR_DOCKER_TAG} .
```

### Tag
```bash
docker tag {YOUR_DOCKER_IMAGE_NAME}:{YOUR_DOCKER_TAG} {YOUR_DOCKER_REGISTRY}/{YOUR_DOCKER_IMAGE_NAME}:{YOUR_DOCKER_TAG}
```

### Push
```bash
docker push {YOUR_DOCKER_REGISTRY}/{YOUR_DOCKER_IMAGE_NAME}:{YOUR_DOCKER_TAG}
```

## Example of Implemented Values.yaml file
```yaml
# Number of application replicas to run
replicaCount: 1
# Container image configuration
image:
repository: {YOUR_DOCKER_REGISTRY} # e.g., quay.io/myorg/myapp
tag: {YOUR_DOCKER_TAG} # e.g., latest, v1.0.0
pullPolicy: {YOUR_DOCKER_PULL_POLICY} # Usually IfNotPresent or Always
# Secrets for pulling images from private registries
imagePullSecrets:
- name: {YOUR_IMAGE_PULL_SECRET_NAME}
# Optional name overrides
nameOverride: ""
fullnameOverride: ""
# Service configuration for accessing your application
service:
type: LoadBalancer # Can be ClusterIP, LoadBalancer, or NodePort
port: 80 # Port your service will listen on
# Environment variables for your application
configMap:
data:
APP_NAME: {YOUR_APP_NAME} # e.g., "My FastAPI App"
DEBUG: {YOUR_DEBUG_VALUE} # e.g., "false"
VERSION: {YOUR_VERSION} # e.g., "1.0.0"
# Add your custom environment variables here
# Resource limits and requests
resources:
limits:
cpu: 100m # 100 millicores = 0.1 CPU
memory: 128Mi # 128 megabytes
requests:
cpu: 100m
memory: 128Mi
# Pod scheduling configurations
nodeSelector: {} # Add node selectors if needed
tolerations: [] # Add tolerations if needed
affinity: {} # Add affinity rules if needed
```
## Add the repository to your Helm CLI
```bash
helm repo add fastapi-helm-chart https://anqorithm.github.io/fastapi-helm-chart/charts/fastapi
```
## Install the chart
```bash
helm install my-fastapi-helm-chart fastapi-helm-chart/fastapi-helm-chart --version 0.0.4
```
## Installation
To install the chart with the release name "fastapi-chart":
#### Clone the repository
```bash
git clone https://github.com/anqorithm/fastapi-helm-chart.git
```
#### Install the chart
```bash
helm install fastapi-chart ./charts/fastapi
```

#### Open OpenShift to see the application

#### Create a route to access the application

#### Access the application


This will deploy your FastAPI application to the OpenShift cluster using the default configuration values. For custom configurations, create a values.yaml file with your desired settings and use:
```bash
helm install fastapi-chart ./charts/fastapi -f values.yaml
```
## Contributing
Contributions are welcome! Please feel free to submit a PR.
## Contributors
- [Abdullah Alqahtani](https://github.com/anqorithm)
## License
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
## Acknowledgments
- [FastAPI](https://fastapi.tiangolo.com)
- [OpenShift](https://www.openshift.com)
- [Kubernetes](https://kubernetes.io)
- [Helm](https://helm.sh)
- [Artifact Hub](https://artifacthub.io)
- [Poetry](https://python-poetry.org)
- [Docker](https://www.docker.com)
- [GitHub](https://github.com)
- [Bitbucket](https://bitbucket.org)