Skip to content
Merged
Show file tree
Hide file tree
Changes from 47 commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
16d83b8
allow creation of pg-stac secrets from azure secret vault, refs #186
batpad Mar 12, 2025
122d7ff
bump version in chart
batpad Mar 13, 2025
a0e2a41
add serviceAccount to create azure service account from values
batpad Mar 13, 2025
bec9d40
change version in chart yaml
batpad Mar 13, 2025
46da4cb
fix secret order since we need multiple secrets derived from a single…
batpad Mar 13, 2025
d38a5e8
bump chart version to 0.5.3-azure-test-3 and add support for Azure AK…
emmanuelmathot Mar 13, 2025
d8c2440
refactor deployment templates to properly handle Azure AKS secrets pr…
emmanuelmathot Mar 13, 2025
6e2b57d
bump chart version to 0.5.3-azure-test-4
emmanuelmathot Mar 13, 2025
6d43e78
fix: update template to use correct context for Azure AKS secrets pro…
emmanuelmathot Mar 13, 2025
18a707f
fix: adjust secret reference formatting and add service account confi…
emmanuelmathot Mar 13, 2025
788c163
fix: add volume mounts for Azure AKS secrets provider in deployment t…
emmanuelmathot Mar 13, 2025
752b097
bump chart version to 0.5.3-azure-test-7
emmanuelmathot Mar 13, 2025
497e686
bump chart version to 0.5.3-azure-test-8 and add Azure AKS secrets pr…
emmanuelmathot Mar 13, 2025
adb7db8
bump chart version to 0.5.3-azure-test-9 and add Azure workload ident…
emmanuelmathot Mar 13, 2025
30e8b03
bump chart version to 0.5.3-azure-test-10 and add service account con…
emmanuelmathot Mar 13, 2025
103993b
use the service account name from values
geohacker Mar 13, 2025
b8414ee
name in the deploy for service account should match values
geohacker Mar 13, 2025
e018acb
key names in vault still not working, try replacing _ with -
batpad Mar 13, 2025
6bad923
bump version in Chart.yaml
batpad Mar 13, 2025
b6724b3
oops, replace _ with - everywhere
batpad Mar 13, 2025
ca25162
bump chart version to azure-test-14
batpad Mar 13, 2025
5986eca
bump chart version to 0.5.3-azure-test-15 and update job.yaml for Azu…
emmanuelmathot Mar 17, 2025
258c428
bump chart version to 0.5.3-azure-test-16 and update job.yaml for con…
emmanuelmathot Mar 17, 2025
7afd2e4
bump chart version to 0.5.3-azure-test-17 and update job.yaml for env…
emmanuelmathot Mar 17, 2025
8f61225
bump chart version to 0.5.3-azure-test-18 and update job.yaml for Pos…
emmanuelmathot Mar 17, 2025
8741207
bump chart version to 0.5.3-azure-test-19 and update job.yaml and con…
emmanuelmathot Mar 17, 2025
7a947c9
bump chart version to 0.5.3-azure-test-20 and update configmap.yaml t…
emmanuelmathot Mar 17, 2025
96f665c
bump chart version to 0.5.3-azure-test-21 and update PGADMIN_URI init…
emmanuelmathot Mar 17, 2025
f01823f
bump chart version to 0.5.3-azure-test-21 and update job.yaml and con…
emmanuelmathot Mar 21, 2025
075d382
Merge branch 'feature/azure-secrets' of https://github.com/developmen…
emmanuelmathot Mar 21, 2025
8f67933
update deployment.yaml to allow forwarded IPs in root path configuration
emmanuelmathot Apr 8, 2025
fca2f76
Refactor Azure integration: deprecate specific service account config…
emmanuelmathot Apr 8, 2025
2bdc64d
Add support for additional labels, environment variables, and volume …
emmanuelmathot Apr 8, 2025
fadfb82
Remove redundant value assignment for KEEP_ALIVE in pgstacbootstrap j…
emmanuelmathot Apr 8, 2025
99725bc
Enable backups in PostgreSQL operator installation
emmanuelmathot Apr 8, 2025
2527aee
Enable backups for PostgreSQL cluster in test configuration
emmanuelmathot Apr 8, 2025
7c1bbe8
Enhance cleanup step to extract and display pod logs for debugging on…
emmanuelmathot Apr 8, 2025
07efaf2
Enhance cleanup step to extract and display logs from PGSTACBootstrap…
emmanuelmathot Apr 8, 2025
54dbbdb
Refactor ServiceAccount name in RBAC configuration to use template fu…
emmanuelmathot Apr 8, 2025
b921b18
Refactor endpoint exports in helm-tests workflow for consistency and …
emmanuelmathot Apr 8, 2025
02b73f1
Fix endpoint URLs in helm-tests workflow to include release name for …
emmanuelmathot Apr 8, 2025
64695d0
Enhance error handling in test execution by extracting and displaying…
emmanuelmathot Apr 8, 2025
c1c7461
remove azure specifics
emmanuelmathot Apr 8, 2025
8d92172
Update PGO_VERSION to 5.7.0 and remove backupsEnabled comment from te…
emmanuelmathot Apr 8, 2025
ca5fe8f
Revert chart version to 0.5.3-azure-test-21 for consistency with appl…
emmanuelmathot Apr 8, 2025
2332237
Update chart version to 0.5.3-azure-test-21 for consistency with appl…
emmanuelmathot Apr 8, 2025
136deb2
Add service account configuration and update values.yaml with ingress…
emmanuelmathot Apr 8, 2025
2cb1dbe
Update database connection wait command to use POSTGRES_HOST variable
emmanuelmathot Apr 8, 2025
3824b07
Add environment variables to wait-for-db init container
emmanuelmathot Apr 8, 2025
62873a3
Enable pgstacBootstrap and update environment variables for database …
emmanuelmathot Apr 8, 2025
14c8f00
Fix wait-for-db command to correctly reference POSTGRES_PORT environm…
emmanuelmathot Apr 8, 2025
434c2d3
Enhance pgstacbootstrap job configuration by adding extra volume moun…
emmanuelmathot Apr 8, 2025
94aeeaf
Refactor pgstacBootstrap to support additional environment variables …
emmanuelmathot Apr 8, 2025
83997cd
Refactor deployment.yaml to correctly reference extraEnvVars in pgsta…
emmanuelmathot Apr 8, 2025
9be81f7
Refactor pgstacBootstrap job configuration to use extraEnvFrom and ex…
emmanuelmathot Apr 8, 2025
0027863
Fix reference to extraEnvFrom in pgstacBootstrap job configuration
emmanuelmathot Apr 8, 2025
0aadc9d
Refactor pgstacBootstrap configuration to add extraEnvFrom, extraVolu…
emmanuelmathot Apr 8, 2025
bc7dfad
Fix DUMMY_ENV_VAR value type in deployment.yaml to use string format
emmanuelmathot Apr 8, 2025
8e52252
Refactor PostgreSQL configuration and remove deprecated database setup
emmanuelmathot Apr 17, 2025
637dc91
Add PostgreSQL host reader and writer environment variables, and incl…
emmanuelmathot Apr 17, 2025
9b6b092
Merge remote-tracking branch 'origin/main' into unified_pg
emmanuelmathot Apr 18, 2025
5f45f50
Merge branch 'main' into unified_pg
emmanuelmathot Apr 28, 2025
ee41f4b
Added a clarifying comment in values.yaml to explain that values in t…
emmanuelmathot Apr 28, 2025
db8fd56
Merge branch 'unified_pg' into feature/azure-secrets
emmanuelmathot Apr 28, 2025
4810aa9
Enhance Azure PostgreSQL setup documentation with detailed setup inst…
emmanuelmathot Apr 28, 2025
fb23fa0
Remove unused ingress and values.yaml configurations
emmanuelmathot Apr 28, 2025
d941a76
Merge branch 'main' into feature/azure-secrets
emmanuelmathot Apr 29, 2025
360303d
Bump chart version to 0.6.0 for release
emmanuelmathot Apr 29, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 72 additions & 6 deletions .github/workflows/helm-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:

env:
HELM_VERSION: v3.15.2
PGO_VERSION: 5.5.2
PGO_VERSION: 5.7.0

jobs:
helm-tests:
Expand Down Expand Up @@ -118,7 +118,40 @@ jobs:
- name: cleanup if services fail to boot
if: steps.watchservices.outcome == 'failure'
run: |
echo "The previous step failed or timed out."
echo "The watchservices step failed or timed out. Extracting pod logs for debugging..."

# Get and display all pods status
echo "===== Pod Status ====="
kubectl get pods

# Extract logs from database pod
echo "===== Database Pod Logs ====="
kubectl get pod | grep "^db-$RELEASE_NAME" | cut -d' ' -f1 | xargs -I{} kubectl logs pod/{} --tail=100 || echo "Could not get database logs"

# Extract logs from pgstacbootstrap pod
echo "===== PGSTACBootstrap Pod Logs ====="
kubectl get pod | grep "^pgstacbootstrap-$RELEASE_NAME" | cut -d' ' -f1 | xargs -I{} kubectl logs pod/{} --tail=100 || echo "Could not get pgstacbootstrap logs"

# Extract logs from raster pod init container (wait-for-pgstacbootstrap)
echo "===== Raster Pod Init Container Logs (wait-for-pgstacbootstrap) ====="
kubectl get pod | grep "^raster-$RELEASE_NAME" | cut -d' ' -f1 | xargs -I{} kubectl logs pod/{} -c wait-for-pgstacbootstrap --tail=100 || echo "Could not get raster init container logs"

# Extract logs from raster pod main container
echo "===== Raster Pod Main Container Logs ====="
kubectl get pod | grep "^raster-$RELEASE_NAME" | cut -d' ' -f1 | xargs -I{} kubectl logs pod/{} --tail=100 || echo "Could not get raster main container logs"

# Extract logs from vector pod
echo "===== Vector Pod Logs ====="
kubectl get pod | grep "^vector-$RELEASE_NAME" | cut -d' ' -f1 | xargs -I{} kubectl logs pod/{} --tail=100 || echo "Could not get vector logs"

# Extract logs from stac pod
echo "===== STAC Pod Logs ====="
kubectl get pod | grep "^stac-$RELEASE_NAME" | cut -d' ' -f1 | xargs -I{} kubectl logs pod/{} --tail=100 || echo "Could not get STAC logs"

# Check if pods are in pending state or have issues
echo "===== Pod Descriptions for Troubleshooting ====="
kubectl get pod | grep "$RELEASE_NAME" | cut -d' ' -f1 | xargs -I{} kubectl describe pod/{} || echo "Could not describe pods"

# force GH action to show failed result
exit 128

Expand All @@ -145,15 +178,48 @@ jobs:
echo $RASTER_ENDPOINT
echo '#################################'

pytest .github/workflows/tests/test_vector.py || kubectl logs svc/vector-$RELEASE_NAME
pytest .github/workflows/tests/test_stac.py
pytest .github/workflows/tests/test_vector.py || kubectl logs svc/vector
pytest .github/workflows/tests/test_stac.py || kubectl logs svc/stac
# TODO: fix raster tests
#pytest .github/workflows/tests/test_raster.py
#pytest .github/workflows/tests/test_raster.py || kubectl logs svc/raster

- name: error if tests failed
if: steps.testrunner.outcome == 'failure'
run: |
echo "The previous step failed or timed out."
echo "The tests failed. Extracting pod logs for debugging..."

# Get and display all pods status
echo "===== Pod Status ====="
kubectl get pods

# Extract logs from database pod
echo "===== Database Pod Logs ====="
kubectl get pod | grep "^db-$RELEASE_NAME" | cut -d' ' -f1 | xargs -I{} kubectl logs pod/{} --tail=100 || echo "Could not get database logs"

# Extract logs from pgstacbootstrap pod
echo "===== PGSTACBootstrap Pod Logs ====="
kubectl get pod | grep "^pgstacbootstrap-$RELEASE_NAME" | cut -d' ' -f1 | xargs -I{} kubectl logs pod/{} --tail=100 || echo "Could not get pgstacbootstrap logs"

# Extract logs from raster pod init container (wait-for-pgstacbootstrap)
echo "===== Raster Pod Init Container Logs (wait-for-pgstacbootstrap) ====="
kubectl get pod | grep "^raster-$RELEASE_NAME" | cut -d' ' -f1 | xargs -I{} kubectl logs pod/{} -c wait-for-pgstacbootstrap --tail=100 || echo "Could not get raster init container logs"

# Extract logs from raster pod main container
echo "===== Raster Pod Main Container Logs ====="
kubectl get pod | grep "^raster-$RELEASE_NAME" | cut -d' ' -f1 | xargs -I{} kubectl logs pod/{} --tail=100 || echo "Could not get raster main container logs"

# Extract logs from vector pod
echo "===== Vector Pod Logs ====="
kubectl get pod | grep "^vector-$RELEASE_NAME" | cut -d' ' -f1 | xargs -I{} kubectl logs pod/{} --tail=100 || echo "Could not get vector logs"

# Extract logs from stac pod
echo "===== STAC Pod Logs ====="
kubectl get pod | grep "^stac-$RELEASE_NAME" | cut -d' ' -f1 | xargs -I{} kubectl logs pod/{} --tail=100 || echo "Could not get STAC logs"

# Check if pods are in pending state or have issues
echo "===== Pod Descriptions for Troubleshooting ====="
kubectl get pod | grep "$RELEASE_NAME" | cut -d' ' -f1 | xargs -I{} kubectl describe pod/{} || echo "Could not describe pods"

# force GH action to show failed result
exit 128

Expand Down
Empty file.
234 changes: 234 additions & 0 deletions docs/azure.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,234 @@
# Microsoft Azure Setup

## Using Azure managed PostgreSQL
To use Azure managed PostgreSQL with the `eoapi-k8s` chart, you need to set up the following:
1. **Create an Azure PostgreSQL server**: You can create a PostgreSQL server using the Azure portal or the Azure CLI. Make sure to note down the server name, username, and password.
2. **Create a PostgreSQL database**: After creating the server, create a database that will be used by the `eoapi-k8s` chart.
3. **Configure firewall rules**: Ensure that the PostgreSQL server allows connections from your Kubernetes cluster's IP address. You can do this by adding a firewall rule in the Azure portal or using the Azure CLI.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@geohacker I need your review on this part or a link to a reference documentation to setup an azure managed postgres with postgis and the related keyvault creation and access


## Azure Configuration for eoapi-k8s

When deploying on Azure, you'll need to configure several settings in your values.yaml file. Below are the configurations needed for proper integration with Azure services.

### Common Azure Configuration

Add the following to your values.yaml:

```yaml
# Main Azure Configuration
azure:
aksSecretsProviderAvailable: true # set to true when using Azure Key Vault
keyvault:
name: "your-keyvault-name"
clientId: "your-client-id"
tenantId: "your-tenant-id"
# Mapping of name inside Azure Vault to name inside k8s secret object
secretKeys:
pgpassword: POSTGRES_PASSWORD
pghost: POSTGRES_HOST
dbname: POSTGRES_DBNAME
# Add any other secrets your services need

# Service Account Configuration
serviceAccount:
create: true
annotations:
azure.workload.identity/client-id: "your-client-id"
azure.workload.identity/tenant-id: "your-tenant-id"
```
### PostgreSQL Configuration
Disable the internal PostgreSQL cluster when using Azure's managed PostgreSQL:
```yaml
postgrescluster:
enabled: false
```
### PgSTAC Bootstrap Configuration
Configure the pgstacBootstrap service for Azure:
```yaml
pgstacBootstrap:
enabled: true
settings:
labels:
azure.workload.identity/use: "true"
extraEnvVars:
- name: POSTGRES_USER
value: postgres
- name: POSTGRES_PORT
value: "5432"
extraEnvFrom:
- secretRef:
name: pgstac-secrets-{{ $.Release.Name }}
extraVolumeMounts:
- name: azure-keyvault-secrets
mountPath: /mnt/secrets-store
readOnly: true
extraVolumes:
- name: azure-keyvault-secrets
csi:
driver: secrets-store.csi.k8s.io
readOnly: true
volumeAttributes:
secretProviderClass: azure-secret-provider-{{ $.Release.Name }}
```
### API Services Configuration
For each API service (raster, multidim, stac, vector), add the following configuration:
```yaml
# Example for the raster service
raster:
enabled: true
settings:
labels:
azure.workload.identity/use: "true"
extraEnvFrom:
- secretRef:
name: pgstac-secrets-{{ $.Release.Name }}
extraVolumeMounts:
- name: azure-keyvault-secrets
mountPath: /mnt/secrets-store
readOnly: true
extraVolumes:
- name: azure-keyvault-secrets
csi:
driver: secrets-store.csi.k8s.io
readOnly: true
volumeAttributes:
secretProviderClass: azure-secret-provider-{{ $.Release.Name }}

# Example for the stac service
stac:
enabled: true
settings:
labels:
azure.workload.identity/use: "true"
extraEnvFrom:
- secretRef:
name: pgstac-secrets-{{ $.Release.Name }}
extraVolumeMounts:
- name: azure-keyvault-secrets
mountPath: /mnt/secrets-store
readOnly: true
extraVolumes:
- name: azure-keyvault-secrets
csi:
driver: secrets-store.csi.k8s.io
readOnly: true
volumeAttributes:
secretProviderClass: azure-secret-provider-{{ $.Release.Name }}

# Example for the vector service
vector:
enabled: true
settings:
labels:
azure.workload.identity/use: "true"
extraEnvFrom:
- secretRef:
name: pgstac-secrets-{{ $.Release.Name }}
extraVolumeMounts:
- name: azure-keyvault-secrets
mountPath: /mnt/secrets-store
readOnly: true
extraVolumes:
- name: azure-keyvault-secrets
csi:
driver: secrets-store.csi.k8s.io
readOnly: true
volumeAttributes:
secretProviderClass: azure-secret-provider-{{ $.Release.Name }}

# Example for the multidim service (if enabled)
multidim:
enabled: false # set to true if needed
settings:
labels:
azure.workload.identity/use: "true"
extraEnvFrom:
- secretRef:
name: pgstac-secrets-{{ $.Release.Name }}
extraVolumeMounts:
- name: azure-keyvault-secrets
mountPath: /mnt/secrets-store
readOnly: true
extraVolumes:
- name: azure-keyvault-secrets
csi:
driver: secrets-store.csi.k8s.io
readOnly: true
volumeAttributes:
secretProviderClass: azure-secret-provider-{{ $.Release.Name }}
```
## Azure Key Vault Secret Provider Configuration
Create the following Secret Provider Class to access the secrets in Azure Key Vault:
```yaml
apiVersion: secrets-store.csi.x-k8s.io/v1
kind: SecretProviderClass
metadata:
name: azure-secret-provider-{{ $.Release.Name }}
spec:
provider: azure
parameters:
usePodIdentity: "false"
clientID: {{ .Values.azure.keyvault.clientId }}
keyvaultName: {{ .Values.azure.keyvault.name }}
tenantId: {{ .Values.azure.keyvault.tenantId }}
objects: |
array:
{{- range $name, $value := .Values.azure.secretKeys }}
- |
objectName: {{ $value | replace "_" "-" }}
objectType: secret
{{- end }}
secretObjects:
- secretName: pgstac-secrets-{{ $.Release.Name }}
type: Opaque
data:
{{- range $name, $value := .Values.azure.secretKeys }}
- objectName: {{ $value | replace "_" "-" }}
key: {{ $name }}
{{- end }}
```

## Azure Managed Identity Setup

To use Azure Managed Identity with your Kubernetes cluster:

1. **Enable Workload Identity on your AKS cluster**:
```bash
az aks update -g <resource-group> -n <cluster-name> --enable-workload-identity
```

2. **Create a Managed Identity**:
```bash
az identity create -g <resource-group> -n eoapi-identity
```

3. **Configure Key Vault access**:
```bash
# Get the client ID of the managed identity
CLIENT_ID=$(az identity show -g <resource-group> -n eoapi-identity --query clientId -o tsv)

# Grant access to Key Vault
az keyvault set-policy -n <keyvault-name> --secret-permissions get list --spn $CLIENT_ID
```

4. **Create a federated identity credential** to connect the Kubernetes service account to the Azure managed identity:
```bash
az identity federated-credential create \
--name eoapi-federated-credential \
--identity-name eoapi-identity \
--resource-group <resource-group> \
--issuer <aks-oidc-issuer> \
--subject system:serviceaccount:<namespace>:eoapi-sa
```
2 changes: 1 addition & 1 deletion helm-chart/eoapi/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ kubeVersion: ">=1.23.0-0"
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: "0.6.0"
version: "0.5.3-azure-test-21"

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
Expand Down
4 changes: 4 additions & 0 deletions helm-chart/eoapi/templates/pgstacboostrap/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ data:
#!/bin/bash
bash /opt/initdb/apt-and-pip-install.sh
# make sure crunchydata postgresql operator has seeded our secrets and we're ready to go
# init PGADMIN_URI if not set
if [ -z "$PGADMIN_URI" ]; then
export PGADMIN_URI="postgresql://$POSTGRES_USER:'$POSTGRES_PASSWORD'@$POSTGRES_HOST:$POSTGRES_PORT/$POSTGRES_DB"
fi
pypgstac pgready --dsn $PGADMIN_URI
# run migrations
python3 /opt/initdb/python-scripts/pgstac-migrate.py
Expand Down
Loading