Skip to content

allow creation of pg-stac secrets from azure secret vault, refs #186 #187

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 66 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
66 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
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
318 changes: 318 additions & 0 deletions docs/azure.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,318 @@
# Microsoft Azure Setup

## Using Azure Managed PostgreSQL

With the unified PostgreSQL configuration, connecting to an Azure managed PostgreSQL instance has become more straightforward. Here's how to set it up:

1. **Create an Azure PostgreSQL server**: Create a PostgreSQL server using the Azure portal or the Azure CLI.

```bash
# Example of creating an Azure PostgreSQL flexible server
az postgres flexible-server create \
--resource-group myResourceGroup \
--name mypostgresserver \
--location westus \
--admin-user myusername \
--admin-password mypassword \
--sku-name Standard_B1ms
```

2. **Create a PostgreSQL database**: After creating the server, create a database for your EOAPI deployment.

```bash
# Create a database on the Azure PostgreSQL server
az postgres flexible-server db create \
--resource-group myResourceGroup \
--server-name mypostgresserver \
--database-name eoapi
```

3. **Configure firewall rules**: Ensure that the PostgreSQL server allows connections from your Kubernetes cluster's IP address.

```bash
# Allow connections from your AKS cluster's outbound IP
az postgres flexible-server firewall-rule create \
--resource-group myResourceGroup \
--server-name mypostgresserver \
--name AllowAKS \
--start-ip-address <AKS-outbound-IP> \
--end-ip-address <AKS-outbound-IP>
```

4. **Store PostgreSQL credentials in Azure Key Vault**: Create secrets in your Azure Key Vault to store the database connection information.

```bash
# Create Key Vault secrets for PostgreSQL connection
az keyvault secret set --vault-name your-keyvault-name --name db-host --value "mypostgresserver.postgres.database.azure.com"
az keyvault secret set --vault-name your-keyvault-name --name db-port --value "5432"
az keyvault secret set --vault-name your-keyvault-name --name db-name --value "eoapi"
az keyvault secret set --vault-name your-keyvault-name --name db-username --value "myusername@mypostgresserver"
az keyvault secret set --vault-name your-keyvault-name --name db-password --value "mypassword"
```

## 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

First, configure the service account with Azure Workload Identity:

```yaml
# Service Account Configuration
serviceAccount:
create: true
annotations:
azure.workload.identity/client-id: "your-client-id"
azure.workload.identity/tenant-id: "your-tenant-id"
```

### Unified PostgreSQL Configuration

Use the unified PostgreSQL configuration with the `external-secret` type to connect to your Azure managed PostgreSQL:

```yaml
# Configure PostgreSQL connection to use Azure managed PostgreSQL with secrets from Key Vault
postgresql:
# Use external-secret type to get credentials from a pre-existing secret
type: "external-secret"

# Basic connection information
external:
host: "mypostgresserver.postgres.database.azure.com" # Can be overridden by secret values
port: "5432" # Can be overridden by secret values
database: "eoapi" # Can be overridden by secret values

# Reference to a secret that will be created by Azure Key Vault integration
existingSecret:
name: "azure-pg-credentials"
keys:
username: "username" # Secret key for the username
password: "password" # Secret key for the password
host: "host" # Secret key for the host (optional)
port: "port" # Secret key for the port (optional)
database: "database" # Secret key for the database name (optional)
```

With this configuration, you're telling the PostgreSQL components to use an external PostgreSQL database and to get its connection details from a Kubernetes secret named `azure-pg-credentials`. This secret will be created using Azure Key Vault integration as described below.

### Disable internal PostgreSQL cluster

When using Azure managed PostgreSQL, you should disable the internal PostgreSQL cluster:

```yaml
postgrescluster:
enabled: false
```

### Azure Key Vault Integration

To allow your Kubernetes pods to access PostgreSQL credentials stored in Azure Key Vault, create a SecretProviderClass:

```yaml
apiVersion: secrets-store.csi.x-k8s.io/v1
kind: SecretProviderClass
metadata:
name: azure-pg-secret-provider
spec:
provider: azure
parameters:
usePodIdentity: "false"
clientID: "your-client-id"
keyvaultName: "your-keyvault-name"
tenantId: "your-tenant-id"
objects: |
array:
- |
objectName: db-host
objectType: secret
objectAlias: host
- |
objectName: db-port
objectType: secret
objectAlias: port
- |
objectName: db-name
objectType: secret
objectAlias: database
- |
objectName: db-username
objectType: secret
objectAlias: username
- |
objectName: db-password
objectType: secret
objectAlias: password
secretObjects:
- secretName: azure-pg-credentials
type: Opaque
data:
- objectName: host
key: host
- objectName: port
key: port
- objectName: database
key: database
- objectName: username
key: username
- objectName: password
key: password
```

### Service Configuration

For services that need to mount the Key Vault secrets, add the following configuration to each service (pgstacBootstrap, raster, stac, vector, multidim):

```yaml
# Define a common volume configuration for all services
commonVolumeConfig: &commonVolumeConfig
labels:
azure.workload.identity/use: "true"
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-pg-secret-provider

# Apply the common volume configuration to each service
pgstacBootstrap:
enabled: true
settings:
<<: *commonVolumeConfig

raster:
enabled: true
settings:
<<: *commonVolumeConfig

stac:
enabled: true
settings:
<<: *commonVolumeConfig

vector:
enabled: true
settings:
<<: *commonVolumeConfig

multidim:
enabled: false # set to true if needed
settings:
<<: *commonVolumeConfig
```

## 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
```

## Complete Example

Here's a complete example configuration for connecting EOAPI to an Azure managed PostgreSQL database:

```yaml
# Service Account Configuration with Azure Workload Identity
serviceAccount:
create: true
annotations:
azure.workload.identity/client-id: "12345678-1234-1234-1234-123456789012"
azure.workload.identity/tenant-id: "87654321-4321-4321-4321-210987654321"

# Unified PostgreSQL Configuration - using external-secret type
postgresql:
type: "external-secret"
external:
host: "mypostgresserver.postgres.database.azure.com"
port: "5432"
database: "eoapi"
existingSecret:
name: "azure-pg-credentials"
keys:
username: "username"
password: "password"
host: "host"
port: "port"
database: "database"

# Disable internal PostgreSQL cluster
postgrescluster:
enabled: false

# Define common volume configuration with Azure Key Vault integration
commonVolumeConfig: &commonVolumeConfig
labels:
azure.workload.identity/use: "true"
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-pg-secret-provider

# Apply the common volume configuration to each service
pgstacBootstrap:
enabled: true
settings:
<<: *commonVolumeConfig

stac:
enabled: true
settings:
<<: *commonVolumeConfig

raster:
enabled: true
settings:
<<: *commonVolumeConfig

vector:
enabled: true
settings:
<<: *commonVolumeConfig

multidim:
enabled: false
settings:
<<: *commonVolumeConfig
```

Make sure to create the SecretProviderClass as shown in the "Azure Key Vault Integration" section above before deploying EOAPI with this configuration.
2 changes: 1 addition & 1 deletion helm-chart/eoapi/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ annotations:
# 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
Loading