mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-29 06:27:05 +00:00
Merge pull request #81300 from liyanhui1228/sd_logging
Install and start logging agent based on kube env
This commit is contained in:
commit
9614a85a2b
@ -84,6 +84,25 @@ function FetchAndImport-ModuleFromMetadata {
|
|||||||
Import-Module -Force C:\$Filename
|
Import-Module -Force C:\$Filename
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Returns true if the ENABLE_STACKDRIVER_WINDOWS or ENABLE_NODE_LOGGING field in kube_env is true.
|
||||||
|
# $KubeEnv is a hash table containing the kube-env metadata keys+values.
|
||||||
|
# ENABLE_NODE_LOGGING is used for legacy Stackdriver Logging, and will be deprecated (always set to False)
|
||||||
|
# soon. ENABLE_STACKDRIVER_WINDOWS is added to indicate whether logging is enabled for windows nodes.
|
||||||
|
function IsLoggingEnabled {
|
||||||
|
param (
|
||||||
|
[parameter(Mandatory=$true)] [hashtable]$KubeEnv
|
||||||
|
)
|
||||||
|
|
||||||
|
if ($KubeEnv.Contains('ENABLE_STACKDRIVER_WINDOWS') -and `
|
||||||
|
($KubeEnv['ENABLE_STACKDRIVER_WINDOWS'] -eq 'true')) {
|
||||||
|
return $true
|
||||||
|
} elseif ($KubeEnv.Contains('ENABLE_NODE_LOGGING') -and `
|
||||||
|
($KubeEnv['ENABLE_NODE_LOGGING'] -eq 'true')) {
|
||||||
|
return $true
|
||||||
|
}
|
||||||
|
return $false
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
# Don't use FetchAndImport-ModuleFromMetadata for common.psm1 - the common
|
# Don't use FetchAndImport-ModuleFromMetadata for common.psm1 - the common
|
||||||
# module includes variables and functions that any other function may depend
|
# module includes variables and functions that any other function may depend
|
||||||
@ -112,9 +131,12 @@ try {
|
|||||||
Create-Directories
|
Create-Directories
|
||||||
Download-HelperScripts
|
Download-HelperScripts
|
||||||
|
|
||||||
Install-LoggingAgent
|
# Even if Stackdriver is already installed, the function will still [re]start the service.
|
||||||
Configure-LoggingAgent
|
if (IsLoggingEnabled $kube_env) {
|
||||||
Restart-LoggingAgent
|
Install-LoggingAgent
|
||||||
|
Configure-LoggingAgent
|
||||||
|
Restart-LoggingAgent
|
||||||
|
}
|
||||||
|
|
||||||
Create-DockerRegistryKey
|
Create-DockerRegistryKey
|
||||||
Configure-Dockerd
|
Configure-Dockerd
|
||||||
|
Loading…
Reference in New Issue
Block a user