Skip to content

Commit 90f2f49

Browse files
authored
Gangams/make infra geneva config optional in multi tenancy (#1050)
* make geneva config optional * include namespace for geneva telemetry service pod * remove unused prom scrape annotations * remove unused prom scrape annotations * fix bug * fix pr feedback * fix pr feedback
1 parent e349505 commit 90f2f49

File tree

5 files changed

+52
-10
lines changed

5 files changed

+52
-10
lines changed

build/common/installer/scripts/tomlparser-geneva-config.rb

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,14 @@ def get_command_windows(env_variable_name, env_variable_value)
225225
return "[System.Environment]::SetEnvironmentVariable(\"#{env_variable_name}\", \"#{env_variable_value}\", \"Process\")" + "\n" + "[System.Environment]::SetEnvironmentVariable(\"#{env_variable_name}\", \"#{env_variable_value}\", \"Machine\")" + "\n"
226226
end
227227

228+
def is_configure_geneva_env_vars()
229+
is_configure = false
230+
if (@geneva_logs_integration && (!@multi_tenancy || !@infra_namespaces.empty?))
231+
is_configure = true
232+
end
233+
return is_configure
234+
end
235+
228236
@configSchemaVersion = ENV["AZMON_AGENT_CFG_SCHEMA_VERSION"]
229237
puts "****************Start Agent Integrations Config Processing********************"
230238
if !@configSchemaVersion.nil? && !@configSchemaVersion.empty? && @configSchemaVersion.strip.casecmp("v1") == 0 #note v1 is the only supported schema version , so hardcoding it
@@ -254,7 +262,7 @@ def get_command_windows(env_variable_name, env_variable_value)
254262
file.write("export ENABLE_FBIT_THREADING=#{@enable_fbit_threading}\n")
255263
end
256264

257-
if @geneva_logs_integration
265+
if is_configure_geneva_env_vars()
258266
file.write("export MONITORING_GCS_ENVIRONMENT=#{@geneva_account_environment}\n")
259267
file.write("export MONITORING_GCS_NAMESPACE=#{@geneva_account_namespace}\n")
260268
file.write("export MONITORING_GCS_ACCOUNT=#{@geneva_account_name}\n")
@@ -290,7 +298,7 @@ def get_command_windows(env_variable_name, env_variable_value)
290298
file.write(commands)
291299
end
292300

293-
if @geneva_logs_integration
301+
if is_configure_geneva_env_vars()
294302
commands = get_command_windows("MONITORING_GCS_ENVIRONMENT", @geneva_account_environment)
295303
file.write(commands)
296304
commands = get_command_windows("MONITORING_GCS_NAMESPACE", @geneva_account_namespace_windows)

build/linux/installer/conf/fluent-bit-geneva-telemetry-svc.conf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@
1818

1919
[INPUT]
2020
Name forward
21-
Alias input_forward
21+
Alias input_${GENEVA_TELEMETRY_SERVICE_POD_NAMESPACE}_forward
2222
Listen 0.0.0.0
2323
Port 24224
2424
Buffer_Chunk_Size ${FBIT_INPUT_FORWARD_BUFFER_CHUNK_SIZE}
2525
Buffer_Max_Size ${FBIT_INPUT_FORWARD_BUFFER_CHUNK_MAX_SIZE}
2626

2727
[OUTPUT]
2828
Name oms
29-
Alias output_geneva
29+
Alias output_${GENEVA_TELEMETRY_SERVICE_POD_NAMESPACE}_geneva
3030
EnableTelemetry true
3131
Retry_Limit 10
3232
TelemetryPushIntervalSeconds 300

charts/azuremonitor-containers-geneva/templates/deployment.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ spec:
1818
metadata:
1919
annotations:
2020
agentVersion: {{ .Values.image.agentVersion }}
21-
prometheus.io/scrape: "true"
22-
prometheus.io/port: "9102"
2321
labels:
2422
rsName: "ama-logs-geneva"
2523
aadpodidbinding: {{ .Values.genevaLogsConfig.aadpodidbinding }}
@@ -35,6 +33,10 @@ spec:
3533
resources:
3634
{{- toYaml .Values.resources | nindent 12 }}
3735
env:
36+
- name: GENEVA_TELEMETRY_SERVICE_POD_NAMESPACE
37+
valueFrom:
38+
fieldRef:
39+
fieldPath: metadata.namespace
3840
- name: ENABLE_FBIT_INTERNAL_METRICS
3941
value: {{ .Values.enableInternalMetrics | quote }}
4042
- name: FBIT_SERVICE_GRACE_INTERVAL_SECONDS

kubernetes/linux/main.sh

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,15 @@ waitforlisteneronTCPport() {
6161
fi
6262
}
6363

64+
isGenevaMode() {
65+
if [ "${GENEVA_LOGS_INTEGRATION}" == "true" ] && { [ "${GENEVA_LOGS_MULTI_TENANCY}" == "false" ] || [ -n "${GENEVA_LOGS_INFRA_NAMESPACES}" ]; }; then
66+
true
67+
elif [ "${GENEVA_LOGS_INTEGRATION_SERVICE_MODE}" == "true" ]; then
68+
true
69+
else
70+
false
71+
fi
72+
}
6473
checkAgentOnboardingStatus() {
6574
local sleepdurationsecs=1
6675
local totalsleptsecs=0
@@ -80,7 +89,8 @@ checkAgentOnboardingStatus() {
8089
successMessage="Loaded data sources"
8190
failureMessage="Failed to load data sources into config"
8291
fi
83-
if [ "${GENEVA_LOGS_INTEGRATION}" == "true" ] || [ "${GENEVA_LOGS_INTEGRATION_SERVICE_MODE}" == "true" ]; then
92+
93+
if isGenevaMode; then
8494
successMessage="Config downloaded and parsed"
8595
failureMessage="failed to download start up config"
8696
fi
@@ -800,7 +810,7 @@ source /etc/mdsd.d/envmdsd
800810
MDSD_AAD_MSI_AUTH_ARGS=""
801811
# check if its AAD Auth MSI mode via USING_AAD_MSI_AUTH
802812
export AAD_MSI_AUTH_MODE=false
803-
if [ "${CONTAINER_TYPE}" != "PrometheusSidecar" ] && [ "${GENEVA_LOGS_INTEGRATION}" == "true" -o "${GENEVA_LOGS_INTEGRATION_SERVICE_MODE}" == "true" ]; then
813+
if [ "${CONTAINER_TYPE}" != "PrometheusSidecar" ] && isGenevaMode; then
804814
echo "Runnning AMA in Geneva Logs Integration Mode"
805815
export MONITORING_USE_GENEVA_CONFIG_SERVICE=true
806816
echo "export MONITORING_USE_GENEVA_CONFIG_SERVICE=true" >> ~/.bashrc

kubernetes/windows/main.ps1

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -716,6 +716,29 @@ function Bootstrap-CACertificates {
716716
}
717717
}
718718

719+
function IsGenevaMode() {
720+
$isGenevaLogsIntegration=$false
721+
$isGenevaLogsMultitenancy=$false
722+
$genevaLogsIntegration = [System.Environment]::GetEnvironmentVariable("GENEVA_LOGS_INTEGRATION")
723+
$genevaLogsMultitenancy = [System.Environment]::GetEnvironmentVariable("GENEVA_LOGS_MULTI_TENANCY")
724+
$genevaLogsInfraNameSpaces = [System.Environment]::GetEnvironmentVariable("GENEVA_LOGS_INFRA_NAMESPACES")
725+
$isGenevaLogsInfraNameSpacesEmpty=$true
726+
727+
if (![string]::IsNullOrEmpty($genevaLogsIntegration) -and $genevaLogsIntegration.ToLower() -eq 'true') {
728+
$isGenevaLogsIntegration=$true
729+
}
730+
if (![string]::IsNullOrEmpty($genevaLogsMultitenancy) -and $genevaLogsMultitenancy.ToLower() -eq 'true') {
731+
$isGenevaLogsMultitenancy=$true
732+
}
733+
if (![string]::IsNullOrEmpty($genevaLogsInfraNameSpaces)) {
734+
$isGenevaLogsInfraNameSpacesEmpty=$false
735+
}
736+
if ($isGenevaLogsIntegration -and (!$isGenevaLogsMultitenancy -or !$isGenevaLogsInfraNameSpacesEmpty)){
737+
return $true
738+
}
739+
return $false
740+
}
741+
719742
Set-ProcessAndMachineEnvVariables "COMPlus_ThreadPool_UnfairSemaphoreSpinLimit" "0"
720743

721744
Start-Transcript -Path main.txt
@@ -736,9 +759,8 @@ if (![string]::IsNullOrEmpty($requiresCertBootstrap) -and `
736759
Bootstrap-CACertificates
737760
}
738761

739-
$isGenevaLogsIntegration = [System.Environment]::GetEnvironmentVariable("GENEVA_LOGS_INTEGRATION")
740762
$isAADMSIAuth = [System.Environment]::GetEnvironmentVariable("USING_AAD_MSI_AUTH")
741-
if (![string]::IsNullOrEmpty($isGenevaLogsIntegration) -and $isGenevaLogsIntegration.ToLower() -eq 'true') {
763+
if (IsGenevaMode) {
742764
Write-Host "Starting Windows AMA in 1P Mode"
743765
#start Windows AMA
744766
Start-Job -ScriptBlock { Start-Process -NoNewWindow -FilePath "C:\opt\windowsazuremonitoragent\windowsazuremonitoragent\Monitoring\Agent\MonAgentLauncher.exe" -ArgumentList @("-useenv")}

0 commit comments

Comments
 (0)