Plumb through log analytics values (#274)
* plumb through log analytics values * add option to specify a log analytics file as well * use secret for log analytics
This commit is contained in:
committed by
Robbie Zhang
parent
28daffa96f
commit
ef6ae9ecf4
@@ -44,6 +44,7 @@ type ACIProvider struct {
|
||||
pods string
|
||||
internalIP string
|
||||
daemonEndpointPort int32
|
||||
diagnostics *aci.ContainerGroupDiagnostics
|
||||
}
|
||||
|
||||
// AuthConfig is the secret returned from an ImageRegistryCredential
|
||||
@@ -155,6 +156,25 @@ func NewACIProvider(config string, rm *manager.ResourceManager, nodeName, operat
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// If the log analytics file has been specified, load workspace credentials from the file
|
||||
if logAnalyticsAuthFile := os.Getenv("LOG_ANALYTICS_AUTH_LOCATION"); logAnalyticsAuthFile != "" {
|
||||
p.diagnostics, err = aci.NewContainerGroupDiagnosticsFromFile(logAnalyticsAuthFile)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
// If we have both the log analytics workspace id and key, add them to the provider
|
||||
// Environment variables overwrite the values provided in the file
|
||||
if logAnalyticsID := os.Getenv("LOG_ANALYTICS_ID"); logAnalyticsID != "" {
|
||||
if logAnalyticsKey := os.Getenv("LOG_ANALYTICS_KEY"); logAnalyticsKey != "" {
|
||||
p.diagnostics, err = aci.NewContainerGroupDiagnostics(logAnalyticsID, logAnalyticsKey)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if rg := os.Getenv("ACI_RESOURCE_GROUP"); rg != "" {
|
||||
p.resourceGroup = rg
|
||||
}
|
||||
@@ -227,6 +247,7 @@ func (p *ACIProvider) CreatePod(pod *v1.Pod) error {
|
||||
containerGroup.ContainerGroupProperties.Containers = containers
|
||||
containerGroup.ContainerGroupProperties.Volumes = volumes
|
||||
containerGroup.ContainerGroupProperties.ImageRegistryCredentials = creds
|
||||
containerGroup.ContainerGroupProperties.Diagnostics = p.diagnostics
|
||||
|
||||
filterServiceAccountSecretVolume(p.operatingSystem, &containerGroup)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user