Skip to content

Commit 14dc395

Browse files
author
Steve Salas
committed
Merge branch 'develop'
2 parents 292c6ac + 4d60782 commit 14dc395

File tree

9 files changed

+169
-88
lines changed

9 files changed

+169
-88
lines changed

codedx/sample-values/values-external-db.yaml

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
# Here are the steps required to use Code Dx with an external database:
55
#
66
# 1) Create a database user for Code Dx. You can customize the following statement to create
7-
# a Code Dx database user named codedx.
7+
# a Code Dx database user named codedx (remove REQUIRE SSL if SSL/TLS is not required).
88
#
9-
# CREATE USER 'codedx'@'%' IDENTIFIED BY 'enter-a-password-here';
9+
# CREATE USER 'codedx'@'%' IDENTIFIED BY 'enter-a-password-here' REQUIRE SSL;
1010
#
1111
# 2) Apply any database configuration changes necessary to allow remote database connections.
1212
#
@@ -20,16 +20,25 @@
2020
# GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, ALTER, REFERENCES, INDEX, DROP ON codedxdb.* to 'codedx'@'%';
2121
# FLUSH PRIVILEGES;
2222
#
23-
# 5) Set the optimizer_search_depth database variable to 0 with the below configuration. Failure to
24-
# complete this step will negatively affect Code Dx performance.
23+
# 5) Set the optimizer_search_depth database variable to 0, the character set to utf8mb4, and the collation to
24+
# utf8mb4_general_ci with the below configuration. Failure to complete this step will negatively affect Code Dx
25+
# performance or functionality.
2526
#
2627
# [mysqld]
2728
# optimizer_search_depth=0
29+
# character-set-server=utf8mb4
30+
# collation-server=utf8mb4_general_ci
31+
#
32+
# Also, make sure that sql_mode contains neither ONLY_FULL_GROUP_BY nor PAD_CHAR_TO_FULL_LENGTH.
2833
#
2934
# 6) When you install Code Dx, specify existingSecret (values.yaml) with fields
3035
# codedx-mariadb-username and codedx.mariadb.password for the username and
3136
# password that Code Dx will use to access the Code Dx database.
3237
#
38+
# If you're using One-Way TLS for MariaDB clients, do not set externalDatabaseSkipTls and specify
39+
# a path to the MariaDB server CA as the externalDatabaseServerCert parameter when running the
40+
# setup script.
41+
#
3342
# 7) Edit the externalDbUrl connection string by replacing host.docker.internal with your database
3443
# hostname and codedxdb with the name of the Code Dx database you created.
3544
#

codedx/values.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -573,15 +573,15 @@ mariadb:
573573
bind-address=0.0.0.0
574574
pid-file=/opt/bitnami/mariadb/tmp/mysqld.pid
575575
log-error=/opt/bitnami/mariadb/logs/mysqld.log
576-
character-set-server=UTF8
576+
character-set-server=utf8mb4
577577
collation-server=utf8_general_ci
578578
optimizer_search_depth=0
579579
innodb_flush_log_at_trx_commit=0
580580
581581
[client]
582582
port=3306
583583
socket=/opt/bitnami/mariadb/tmp/mysql.sock
584-
default-character-set=UTF8
584+
default-character-set=utf8mb4
585585
586586
[manager]
587587
port=3306
@@ -607,15 +607,15 @@ mariadb:
607607
bind-address=0.0.0.0
608608
pid-file=/opt/bitnami/mariadb/tmp/mysqld.pid
609609
log-error=/opt/bitnami/mariadb/logs/mysqld.log
610-
character-set-server=UTF8
610+
character-set-server=utf8mb4
611611
collation-server=utf8_general_ci
612612
optimizer_search_depth=0
613613
innodb_flush_log_at_trx_commit=0
614614
615615
[client]
616616
port=3306
617617
socket=/opt/bitnami/mariadb/tmp/mysql.sock
618-
default-character-set=UTF8
618+
default-character-set=utf8mb4
619619
620620
[manager]
621621
port=3306

setup/aws/setup.ps1

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<#PSScriptInfo
2-
.VERSION 1.0.0
2+
.VERSION 1.0.1
33
.GUID 7324446b-ac6b-4870-846d-bef7547de642
44
.AUTHOR Code Dx
55
#>
@@ -36,5 +36,3 @@ $provisionNetworkPolicy = {
3636
& (join-path $PSScriptRoot '../setup.ps1') `
3737
-storageClassName $storageClassName `
3838
-provisionNetworkPolicy $provisionNetworkPolicy @args
39-
40-
Write-Verbose 'Deployment complete!'

setup/azure/setup.ps1

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<#PSScriptInfo
2-
.VERSION 1.0.1
2+
.VERSION 1.0.2
33
.GUID 01d0c54b-ce7a-4462-b4cd-fb27a4f847bc
44
.AUTHOR Code Dx
55
#>
@@ -36,5 +36,3 @@ if ($nginxIngressControllerLoadBalancerIP -eq '') {
3636
-storageClassName $storageClassName `
3737
-nginxIngressControllerLoadBalancerIP $nginxIngressControllerLoadBalancerIP `
3838
@args
39-
40-
Write-Verbose 'Deployment complete!'

setup/common/codedx.ps1

Lines changed: 50 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<#PSScriptInfo
2-
.VERSION 1.0.2
2+
.VERSION 1.0.3
33
.GUID 6b1307f7-7098-4c65-9a86-8478840ad4cd
44
.AUTHOR Code Dx
55
#>
@@ -64,6 +64,7 @@ function New-CodeDxDeployment([string] $codeDxDnsName,
6464
[string[]] $serviceAnnotationsCodeDx,
6565
[string] $ingressControllerNamespace,
6666
[string[]] $ingressAnnotations,
67+
[string] $caCertsFilename,
6768
[string] $caCertsFilePwd,
6869
[string] $externalDbUrl,
6970
[string] $externalDbUser,
@@ -73,7 +74,8 @@ function New-CodeDxDeployment([string] $codeDxDnsName,
7374
[switch] $enablePSPs,
7475
[switch] $enableNetworkPolicies,
7576
[switch] $configureTls,
76-
[switch] $skipDatabase) {
77+
[switch] $skipDatabase,
78+
[switch] $offlineMode) {
7779

7880
if (-not (Test-Namespace $namespace)) {
7981
New-Namespace $namespace
@@ -197,14 +199,14 @@ mariadb:
197199
backup:
198200
size: {14}Gi
199201
{22}
200-
cacertsFile: ''
202+
cacertsFile: '{30}'
201203
cacertsFilePwd: '{21}'
202204
codedxProps:
203205
internalExtra:
204206
- type: values
205207
key: codedx-offline-props
206208
values:
207-
- "codedx.offline-mode = true"
209+
- "codedx.offline-mode = {31}"
208210
{29}
209211
'@ -f (Get-CodeDxPdSecretName $releaseName), $tomcatImage, $imagePullSecretYaml, `
210212
$psp, $networkPolicy, `
@@ -220,7 +222,7 @@ $defaultKeyStorePwd, `
220222
$codeDxTomcatPortNumber, $codeDxTlsTomcatPortNumber, `
221223
$serviceTypeCodeDx, (ConvertTo-YamlMap $serviceAnnotationsCodeDx), `
222224
$enableDb, $ingressNginxAssumption, `
223-
$externalDb
225+
$externalDb, $caCertsFilename, $offlineMode.ToString().ToLower()
224226

225227
$valuesFile = 'codedx-values.yaml'
226228
$values | out-file $valuesFile -Encoding ascii -Force
@@ -428,54 +430,32 @@ function Get-RunningCodeDxPodName([string] $codedxNamespace) {
428430
$name
429431
}
430432

431-
function Set-TrustedCerts([string] $workDir,
433+
function Get-RunningCodeDxKeystore([string] $codedxNamespace, [string] $outPath) {
434+
435+
$podName = Get-RunningCodeDxPodName $codedxNamespace
436+
$podFile = "$podName`:/usr/local/openjdk-8/jre/lib/security/cacerts"
437+
438+
kubectl -n $codedxNamespace cp $podFile $outPath
439+
if ($LASTEXITCODE -ne 0) {
440+
throw "Unable to copy out cacerts file from '$podFile', kubectl exited with code $LASTEXITCODE."
441+
}
442+
}
443+
444+
function Set-TrustedCerts([string] $workDir,
432445
[string] $waitSeconds,
433446
[string] $codedxNamespace,
434447
[string] $codedxReleaseName,
435448
[string[]] $extraValuesPaths,
436449
[string] $adminPwd,
437-
[string] $caCertsFilePwd,
438-
[string] $caCertsFileNewPwd,
450+
[string] $keystorePwd,
439451
[string] $externalDbUser,
440452
[string] $externalDbPwd,
441-
[string[]] $trustedCertPaths,
442453
[switch] $offlineMode) {
443454

444-
$caCertsFilePath = './cacerts'
445-
if (test-path $caCertsFilePath) {
446-
remove-item $caCertsFilePath -force
447-
}
448-
449-
$chartFolder = (join-path $workDir codedx-kubernetes/codedx)
450-
$chartFolderCaCertsFilePath = join-path $chartFolder $caCertsFilePath
451-
452-
# if cacerts already exists in the chart folder via -extraCodeDxChartFilesPaths, use
453-
# that copy; otherwise, pull a copy from the running Code Dx pod
454-
if (test-path $chartFolderCaCertsFilePath) {
455-
copy-item $chartFolderCaCertsFilePath $caCertsFilePath
456-
} else {
457-
$podName = Get-RunningCodeDxPodName $codedxNamespace
458-
$podFile = "$podName`:/usr/local/openjdk-8/jre/lib/security/cacerts"
459-
460-
kubectl -n $codedxNamespace cp $podFile $caCertsFilePath
461-
if ($LASTEXITCODE -ne 0) {
462-
throw "Unable to copy out cacerts file, kubectl exited with code $LASTEXITCODE."
463-
}
464-
}
465-
466-
# set cacerts password
467-
$keystorePwd = $caCertsFilePwd
468-
if ('' -ne $caCertsFileNewPwd -and $caCertsFilePwd -ne $caCertsFileNewPwd) {
469-
$keystorePwd = $caCertsFileNewPwd
470-
}
471-
Set-KeystorePassword $caCertsFilePath $caCertsFilePwd $keystorePwd
472455
New-CodeDxPdSecret $codedxNamespace $codedxReleaseName $adminPwd $keystorePwd $externalDbUser $externalDbPwd
473-
474-
Import-TrustedCaCerts $caCertsFilePath $keystorePwd $trustedCertPaths
475-
476-
# move edited cacerts file to chart directory where it can be found during chart install
477-
copy-item $caCertsFilePath $chartFolder -Force
478-
456+
457+
$chartFolder = (join-path $workDir codedx-kubernetes/codedx)
458+
479459
$values = @'
480460
cacertsFile: cacerts
481461
codedxProps:
@@ -752,3 +732,30 @@ function Get-CommonName([string] $name) {
752732
}
753733
$name.TrimEnd('-')
754734
}
735+
736+
function Get-TrustedCaCertsFilePwd([string] $currentPwd, [string] $newPwd) {
737+
738+
$pwd = $currentPwd
739+
if ('' -ne $newPwd -and $pwd -ne $newPwd) {
740+
$pwd = $newPwd
741+
}
742+
$pwd
743+
}
744+
745+
function New-TrustedCaCertsFile([string] $basePath,
746+
[string] $currentPwd, [string] $newPwd,
747+
[string[]] $certPathsToImport,
748+
[string] $destinationDirectory) {
749+
750+
$filePath = "./cacerts"
751+
if (Test-Path $filePath) {
752+
Remove-Item $filePath -force
753+
}
754+
Copy-Item $basePath $filePath
755+
756+
$pwd = (Get-TrustedCaCertsFilePwd $currentPwd $newPwd)
757+
Set-KeystorePassword $filePath $currentPwd $pwd
758+
759+
Import-TrustedCaCerts $filePath $pwd $certPathsToImport
760+
Copy-Item $filePath $destinationDirectory -Force
761+
}

setup/common/k8s.ps1

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<#PSScriptInfo
2-
.VERSION 1.0.1
2+
.VERSION 1.0.2
33
.GUID 5614d5a5-d33b-4a86-a7bb-ccc91c3f9bb3
44
.AUTHOR Code Dx
55
#>
@@ -376,7 +376,8 @@ function Wait-ReplicasReady([string] $message, [int] $waitSeconds, [string] $nam
376376
}
377377

378378
$sleepSeconds = [math]::min(60, ($waitSeconds * .05))
379-
$timeoutTime = [datetime]::Now.AddSeconds($waitSeconds)
379+
$startTime = [datetime]::Now
380+
$timeoutTime = $startTime.AddSeconds($waitSeconds)
380381
while ($true) {
381382

382383
$resourceExists = ($resourceType -eq 'deployment' -and (Test-Deployment $namespace $resourceName)) -or
@@ -408,7 +409,14 @@ function Wait-ReplicasReady([string] $message, [int] $waitSeconds, [string] $nam
408409
throw "Unable to continue because the $resourceType $resourceName is not ready ($message)"
409410
}
410411

411-
Write-Verbose "Current replica count does not yet match desired count. Another check will occur in $sleepSeconds seconds ($message)."
412+
kubectl -n $namespace get pod
413+
414+
$now = [datetime]::Now
415+
Write-Verbose $message
416+
Write-Verbose " Current replica count does not yet match desired count."
417+
Write-Verbose " Elapsed time is $($now.Subtract($startTime).TotalSeconds) seconds."
418+
Write-Verbose " Wait will timeout in $($timeoutTime.Subtract($now).TotalSeconds) seconds."
419+
Write-Verbose " Another replica count check will occur in $sleepSeconds seconds."
412420
start-sleep -seconds $sleepSeconds
413421
}
414422
}

setup/common/keytool.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<#PSScriptInfo
2-
.VERSION 1.0.0
2+
.VERSION 1.0.1
33
.GUID a0b1e49c-0f56-43fa-bd1d-ae211ac63c2a
44
.AUTHOR Code Dx
55
#>

setup/common/mariadb.ps1

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<#PSScriptInfo
2-
.VERSION 1.0.1
2+
.VERSION 1.0.2
33
.GUID d7edc525-a26e-4f80-b65b-262a0e56422e
44
.AUTHOR Code Dx
55
#>
@@ -137,3 +137,25 @@ function Start-SlaveDB([string] $namespace,
137137
Write-Error "Unable to start DB slave, kubectl exited with exit code $LASTEXITCODE."
138138
}
139139
}
140+
141+
function Get-DatabaseUrl([string] $databaseHost, [int] $databasePort,
142+
[string] $databaseName,
143+
[string] $databaseCertPath,
144+
[switch] $databaseSkipTls) {
145+
146+
$url = "jdbc:mysql://$databaseHost"
147+
if ($databasePort -ne 3306) {
148+
$url = "$url`:$databasePort"
149+
}
150+
151+
$url = "$url/$databaseName"
152+
153+
if (-not $databaseSkipTls) {
154+
155+
if ($databaseCertPath -eq '' -or -not (Test-Path $databaseCertPath -PathType Leaf)) {
156+
throw "Using a One-Way SSL/TLS configuration requires a server certificate"
157+
}
158+
$url = "$url`?useSSL=true&requireSSL=true"
159+
}
160+
$url
161+
}

0 commit comments

Comments
 (0)