Install and start logging based on kube env

This commit is contained in:
Angela Li
2019-08-12 11:07:50 -07:00
parent 84fe3db5cf
commit 53a2559e24

View File

@@ -84,6 +84,20 @@ function FetchAndImport-ModuleFromMetadata {
Import-Module -Force C:\$Filename
}
# Returns true if the ENABLE_NODE_LOGGING field in kube_env is true.
# $KubeEnv is a hash table containing the kube-env metadata keys+values.
function IsLoggingEnabled {
param (
[parameter(Mandatory=$true)] [hashtable]$KubeEnv
)
if ($KubeEnv.Contains('ENABLE_NODE_LOGGING') -and `
($KubeEnv['ENABLE_NODE_LOGGING'] -eq 'true')) {
return $true
}
return $false
}
try {
# Don't use FetchAndImport-ModuleFromMetadata for common.psm1 - the common
# module includes variables and functions that any other function may depend
@@ -108,6 +122,10 @@ try {
StartProcess-WriteSshKeys
}
if (IsLoggingEnabled $kube_env) {
InstallAndStart-LoggingAgent
}
Set-EnvironmentVars
Create-Directories
Download-HelperScripts