Skip to content

Commit 01e1e4f

Browse files
Refactor service templates and tests for improved organization and clarity
1 parent 4710419 commit 01e1e4f

File tree

4 files changed

+41
-34
lines changed

4 files changed

+41
-34
lines changed
Lines changed: 29 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,53 @@
1-
# Helm Chart Structure Refactoring
1+
# Service-Specific Templates
22

3-
This directory contains the refactored Helm chart templates for the EOAPI services.
4-
5-
## Overview
6-
7-
The templates have been refactored from a loop-based approach to a service-specific approach where each service has its own dedicated template files. This improves readability, maintainability, and flexibility.
3+
This directory contains service-specific templates organized to improve readability, maintainability, and flexibility.
84

95
## Directory Structure
106

117
```
128
services/
13-
├── _common.tpl # Limited common helper functions
14-
├── ingress.yaml # Single ingress for all services
15-
├── traefik-middleware.yaml # Traefik middleware for path stripping
16-
├── raster/ # One directory per service
9+
├── _common.tpl # Limited common helper functions
10+
├── ingress.yaml # Single shared ingress for all services
11+
├── raster/ # Raster service templates
12+
│ ├── deployment.yaml # Deployment definition
13+
│ ├── service.yaml # Service definition
14+
│ ├── configmap.yaml # ConfigMap definition
15+
│ └── hpa.yaml # HorizontalPodAutoscaler definition
16+
├── stac/ # STAC service templates
1717
│ ├── deployment.yaml
1818
│ ├── service.yaml
1919
│ ├── configmap.yaml
2020
│ └── hpa.yaml
21-
├── stac/
21+
├── vector/ # Vector service templates
2222
│ ├── deployment.yaml
2323
│ ├── service.yaml
2424
│ ├── configmap.yaml
2525
│ └── hpa.yaml
26-
├── vector/
27-
│ ├── deployment.yaml
28-
│ ├── service.yaml
29-
│ ├── configmap.yaml
30-
│ └── hpa.yaml
31-
└── multidim/
26+
└── multidim/ # Multidimensional service templates
3227
├── deployment.yaml
3328
├── service.yaml
3429
├── configmap.yaml
3530
└── hpa.yaml
3631
```
3732

38-
## Key Improvements
33+
## Common Helpers
34+
35+
The `_common.tpl` file provides limited helper functions for truly common elements:
36+
37+
- `eoapi.mountServiceSecrets`: For mounting service secrets
38+
- `eoapi.commonEnvVars`: For common environment variables like SERVICE_NAME, RELEASE_NAME, GIT_SHA
39+
- `eoapi.pgstacInitContainers`: For init containers that wait for pgstac jobs
40+
41+
For database environment variables, we leverage the existing `eoapi.postgresqlEnv` helper from the main `_helpers.tpl` file.
3942

40-
1. **Enhanced Readability**: Each service's configuration is explicitly defined in its own files, making it easier to understand.
41-
2. **Improved Debugging**: Errors are isolated to specific service files, making troubleshooting simpler.
42-
3. **Lower Risk Changes**: Changes intended for one service are contained within its files, reducing the risk of affecting other services.
43-
4. **True Flexibility**: Each service can evolve independently, and new services can be added by copying and modifying existing patterns.
44-
5. **Limited Helper Functions**: Common logic is extracted into the `_common.tpl` file but only for the most mechanical, repetitive parts.
43+
## Refactoring Benefits
4544

46-
## How to Use
45+
1. **Improved Readability**: Service configurations are explicit and clearly visible
46+
2. **Better Maintainability**: Changes to one service don't affect others
47+
3. **Enhanced Flexibility**: Each service can evolve independently
48+
4. **Easier Debugging**: Errors are isolated to specific service files
49+
5. **Safer Changes**: Template modifications can be tested on individual services
4750

48-
The chart maintains the same values.yaml structure but templates are now organized by service. The original looping templates have been preserved with `.old` extensions for reference.
51+
## Usage
4952

50-
For adding a new service:
51-
1. Create a new directory with the service name
52-
2. Copy and adapt the deployment, service, configmap, and hpa templates
53-
3. Add an entry to ingress.yaml and traefik-middleware.yaml if needed
54-
4. Update values.yaml with the new service configuration
53+
No changes to `values.yaml` structure were required. The chart maintains full backward compatibility with existing deployments.

helm-chart/eoapi/tests/config_tests.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
suite: service defaults configmap
22
templates:
3-
- templates/services/configmap.yaml
3+
- templates/services/raster/configmap.yaml
4+
- templates/services/stac/configmap.yaml
5+
- templates/services/vector/configmap.yaml
6+
- templates/services/multidim/configmap.yaml
47
tests:
58
- it: "vector configmap defaults"
69
set:

helm-chart/eoapi/tests/deploy_tests.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
suite: service defaults deployment
22
templates:
3-
- templates/services/deployment.yaml
3+
- templates/services/raster/deployment.yaml
4+
- templates/services/stac/deployment.yaml
5+
- templates/services/vector/deployment.yaml
6+
- templates/services/multidim/deployment.yaml
47
tests:
58
- it: "vector deploy defaults"
69
set:

helm-chart/eoapi/tests/hpa_tests.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
suite: autoscaling feedback when className is not nginx
22
templates:
3-
- templates/services/hpa.yaml
3+
- templates/services/raster/hpa.yaml
4+
- templates/services/stac/hpa.yaml
5+
- templates/services/vector/hpa.yaml
6+
- templates/services/multidim/hpa.yaml
47
tests:
58
- it: "vector hpa fail for requestRate"
69
set:
@@ -13,4 +16,3 @@ tests:
1316
asserts:
1417
- failedTemplate:
1518
errorMessage: When using an 'ingress.className' other than 'nginx' you cannot enable autoscaling by 'requestRate' at this time b/c it's solely an nginx metric
16-

0 commit comments

Comments
 (0)