Skip to content

Commit

Permalink
min-tls settings for postgres (#865)
Browse files Browse the repository at this point in the history
* introduce override variables for postgres min-tls version
* set min-tls version for CS and maestro to 1.2

https://issues.redhat.com/browse/ARO-12468

Signed-off-by: Gerd Oberlechner <[email protected]>
  • Loading branch information
geoberle authored Nov 21, 2024
1 parent 2a053ee commit 5fdc3d9
Show file tree
Hide file tree
Showing 10 changed files with 47 additions and 2 deletions.
10 changes: 9 additions & 1 deletion config/config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@
},
"private": {
"type": "boolean"
},
"minTLSVersion": {
"type": "string",
"enum": ["TLSV1.2", "TLSV1.3"]
}
},
"required": [
Expand Down Expand Up @@ -245,6 +249,10 @@
},
"serverVersion": {
"type": "string"
},
"minTLSVersion": {
"type": "string",
"enum": ["TLSV1.2", "TLSV1.3"]
}
},
"additionalProperties": false,
Expand Down Expand Up @@ -569,4 +577,4 @@
"svcAcrName",
"vnetAddressPrefix"
]
}
}
2 changes: 2 additions & 0 deletions config/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ defaults:
serverStorageSizeGB: '32'
deploy: true
private: false
minTLSVersion: 'TLSV1.2'
restrictIstioIngress: true
consumerName: hcp-underlay-{{ .ctx.regionShort }}-mgmt-{{ .ctx.stamp }}

Expand All @@ -67,6 +68,7 @@ defaults:
name: arohcp-cs-{{ .ctx.regionShort }}
deploy: true
private: false
minTLSVersion: 'TLSV1.2'

# Image Sync
imageSync:
Expand Down
2 changes: 2 additions & 0 deletions config/public-cloud-cs-pr.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"imageTag": "aac7623",
"postgres": {
"deploy": true,
"minTLSVersion": "TLSV1.2",
"name": "arohcp-cs-cspr",
"private": false
}
Expand Down Expand Up @@ -61,6 +62,7 @@
"keyVaultName": "arohcp-maestro-cspr",
"postgres": {
"deploy": false,
"minTLSVersion": "TLSV1.2",
"name": "arohcp-maestro-cspr",
"private": false,
"serverStorageSizeGB": "32",
Expand Down
2 changes: 2 additions & 0 deletions config/public-cloud-dev.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"imageTag": "aac7623",
"postgres": {
"deploy": true,
"minTLSVersion": "TLSV1.2",
"name": "arohcp-cs-dev",
"private": false
}
Expand Down Expand Up @@ -61,6 +62,7 @@
"keyVaultName": "arohcp-maestro-dev",
"postgres": {
"deploy": false,
"minTLSVersion": "TLSV1.2",
"name": "arohcp-maestro-dev",
"private": false,
"serverStorageSizeGB": "32",
Expand Down
2 changes: 2 additions & 0 deletions config/public-cloud-personal-dev.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"imageTag": "aac7623",
"postgres": {
"deploy": false,
"minTLSVersion": "TLSV1.2",
"name": "arohcp-cs-usw3tst",
"private": false
}
Expand Down Expand Up @@ -61,6 +62,7 @@
"keyVaultName": "arohcp-maestro-usw3tst",
"postgres": {
"deploy": false,
"minTLSVersion": "TLSV1.2",
"name": "arohcp-maestro-usw3tst",
"private": false,
"serverStorageSizeGB": "32",
Expand Down
2 changes: 2 additions & 0 deletions dev-infrastructure/configurations/svc-cluster.tmpl.bicepparam
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@ param maestroKeyVaultName = '{{ .maestro.keyVaultName }}'
param maestroEventGridNamespacesName = '{{ .maestro.eventgridName }}'
param maestroCertDomain = '{{ .maestro.certDomain}}'
param maestroPostgresServerName = '{{ .maestro.postgres.name }}'
param maestroPostgresServerMinTLSVersion = '{{ .maestro.postgres.minTLSVersion }}'
param maestroPostgresServerVersion = '{{ .maestro.postgres.serverVersion }}'
param maestroPostgresServerStorageSizeGB = {{ .maestro.postgres.serverStorageSizeGB }}
param deployMaestroPostgres = {{ .maestro.postgres.deploy }}
param maestroPostgresPrivate = {{ .maestro.postgres.private }}

param deployCsInfra = {{ .clusterService.postgres.deploy }}
param csPostgresServerName = '{{ .clusterService.postgres.name }}'
param csPostgresServerMinTLSVersion = '{{ .clusterService.postgres.minTLSVersion }}'
param clusterServicePostgresPrivate = {{ .clusterService.postgres.private }}

param serviceKeyVaultName = '{{ .serviceKeyVault.name }}'
Expand Down
4 changes: 4 additions & 0 deletions dev-infrastructure/modules/cluster-service.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ param csDatabaseName string = 'clusters-service'
@description('The name of the Postgres server for CS')
param postgresServerName string

@description('The minimum TLS version for the Postgres server')
param postgresServerMinTLSVersion string

param postgresServerPrivate bool

param privateEndpointSubnetId string = ''
Expand All @@ -38,6 +41,7 @@ module postgres 'postgres/postgres.bicep' = {
}
]
version: '12'
minTLSVersion: postgresServerMinTLSVersion
configurations: [
// some configs taked over from the CS RDS instance
// https://gitlab.cee.redhat.com/service/app-interface/-/blob/fc95453b1e0eaf162089525f5b94b6dc1e6a091f/resources/terraform/resources/ocm/clusters-service-production-rds-parameter-group-pg12.yml
Expand Down
4 changes: 4 additions & 0 deletions dev-infrastructure/modules/maestro/maestro-server.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ param deployPostgres bool
@description('The name of the Postgres server for Maestro')
param postgresServerName string

@description('The version of the Postgres server for Maestro')
param postgresServerMinTLSVersion string

@description('The version of the Postgres server for Maestro')
param postgresServerVersion string

Expand Down Expand Up @@ -71,6 +74,7 @@ module postgres '../postgres/postgres.bicep' = if (deployPostgres) {
name: '${deployment().name}-postgres'
params: {
name: postgresServerName
minTLSVersion: postgresServerMinTLSVersion
databaseAdministrators: [
// add the dedicated admin managed identity as administrator
// this one is going to be used to manage DB access
Expand Down
13 changes: 12 additions & 1 deletion dev-infrastructure/modules/postgres/postgres.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ param location string = resourceGroup().location

param sku string = 'Standard_D2s_v3'
param tier string = 'GeneralPurpose'
param minTLSVersion string

type DatabaseAdministrators = {
principalId: string
Expand Down Expand Up @@ -145,6 +146,16 @@ resource postgres_config 'Microsoft.DBforPostgreSQL/flexibleServers/configuratio
}
]

resource postgres_min_tls 'Microsoft.DBforPostgreSQL/flexibleServers/configurations@2023-12-01-preview' = {
name: 'ssl_min_protocol_version'
parent: postgres
properties: {
source: 'user-override'
value: minTLSVersion
}
dependsOn: [postgres_config]
}

@batchSize(1)
resource postgres_database 'Microsoft.DBforPostgreSQL/flexibleServers/databases@2023-12-01-preview' = [
for database in databases: {
Expand All @@ -154,7 +165,7 @@ resource postgres_database 'Microsoft.DBforPostgreSQL/flexibleServers/databases@
charset: database.charset
collation: database.collation
}
dependsOn: [postgres_config]
dependsOn: [postgres_min_tls]
}
]

Expand Down
8 changes: 8 additions & 0 deletions dev-infrastructure/templates/svc-cluster.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ param deployCsInfra bool
@maxLength(60)
param csPostgresServerName string

@description('The minimum TLS version for the Postgres server for CS')
param csPostgresServerMinTLSVersion string

@description('If true, make the CS Postgres instance private')
param clusterServicePostgresPrivate bool = true

Expand All @@ -89,6 +92,9 @@ param maestroPostgresServerName string
@description('The version of the Postgres server for Maestro')
param maestroPostgresServerVersion string

@description('The minimum TLS version for the Postgres server for Maestro')
param maestroPostgresServerMinTLSVersion string

@description('The size of the Postgres server for Maestro')
param maestroPostgresServerStorageSizeGB int

Expand Down Expand Up @@ -223,6 +229,7 @@ module maestroServer '../modules/maestro/maestro-server.bicep' = {
deployPostgres: deployMaestroPostgres
postgresServerName: maestroPostgresServerName
postgresServerVersion: maestroPostgresServerVersion
postgresServerMinTLSVersion: maestroPostgresServerMinTLSVersion
postgresServerStorageSizeGB: maestroPostgresServerStorageSizeGB
privateEndpointSubnetId: svcCluster.outputs.aksNodeSubnetId
privateEndpointVnetId: svcCluster.outputs.aksVnetId
Expand Down Expand Up @@ -283,6 +290,7 @@ module cs '../modules/cluster-service.bicep' = if (deployCsInfra) {
params: {
location: location
postgresServerName: csPostgresServerName
postgresServerMinTLSVersion: csPostgresServerMinTLSVersion
privateEndpointSubnetId: svcCluster.outputs.aksNodeSubnetId
privateEndpointVnetId: svcCluster.outputs.aksVnetId
postgresServerPrivate: clusterServicePostgresPrivate
Expand Down

0 comments on commit 5fdc3d9

Please sign in to comment.