Skip to content
Merged
Changes from all commits
Commits
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
29 changes: 29 additions & 0 deletions kubernetes/windows/main.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,27 @@ function Generate-Certificates {
C:\\opt\\omsagentwindows\\certgenerator\\certificategenerator.exe
}

function Bootstrap-CACertificates {
try {
# This is required when the root CA certs are different for some clouds.
$caCerts=Invoke-WebRequest 'http://168.63.129.16/machine?comp=acmspackage&type=cacertificates&ext=json' -UseBasicParsing | ConvertFrom-Json
if (![string]::IsNullOrEmpty($caCerts)) {
$certificates = $caCerts.Certificates
for ($index = 0; $index -lt $certificates.Length ; $index++) {
$name=$certificates[$index].Name
$certificates[$index].CertBody > $name
Write-Host "name: $($name)"
Import-Certificate -FilePath .\$name -CertStoreLocation 'Cert:\LocalMachine\Root' -Verbose
}
}
}
catch {
$e = $_.Exception
Write-Host $e
Write-Host "exception occured in Bootstrap-CACertificates..."
}
}

function Test-CertificatePath {
$certLocation = $env:CI_CERT_LOCATION
$keyLocation = $env:CI_KEY_LOCATION
Expand All @@ -288,6 +309,14 @@ Start-Transcript -Path main.txt
Remove-WindowsServiceIfItExists "fluentdwinaks"
Set-EnvironmentVariables
Start-FileSystemWatcher

#Bootstrapping CA certs for non public clouds and AKS clusters
$aksResourceId = [System.Environment]::GetEnvironmentVariable("AKS_RESOURCE_ID")
if (![string]::IsNullOrEmpty($aksResourceId) -and $aksResourceId.ToLower().Contains("/microsoft.containerservice/managedclusters/"))
{
Bootstrap-CACertificates
}

Generate-Certificates
Test-CertificatePath
Start-Fluent
Expand Down