@@ -15,16 +15,16 @@ log_debug "Script [$this_script] has started [$(date)]"
15
15
FLUENT_BIT_ENABLED=${FLUENT_BIT_ENABLED:- true}
16
16
17
17
if [ " $FLUENT_BIT_ENABLED " != " true" ]; then
18
- log_info " Environment variable [FLUENT_BIT_ENABLED] is not set to 'true'; existing WITHOUT deploying Fluent Bit"
19
- exit 0
18
+ log_info " Environment variable [FLUENT_BIT_ENABLED] is not set to 'true'; existing WITHOUT deploying Fluent Bit"
19
+ exit 0
20
20
fi
21
21
22
22
set -e
23
23
24
24
HELM_DEBUG=" ${HELM_DEBUG:- false} "
25
25
helmDebug=" "
26
26
if [ " $HELM_DEBUG " == " true" ]; then
27
- helmDebug=" --debug"
27
+ helmDebug=" --debug"
28
28
fi
29
29
30
30
# Address SC2154: Ensure variables from common.sh are available or defined
@@ -38,8 +38,8 @@ helmRepoAdd fluent https://fluent.github.io/helm-charts
38
38
39
39
# Confirm namespace exists
40
40
if [ " $( kubectl get ns " $LOG_NS " -o name 2> /dev/null) " == " " ]; then
41
- log_error " The specified namespace [$LOG_NS ] does not exist."
42
- exit 1
41
+ log_error " The specified namespace [$LOG_NS ] does not exist."
42
+ exit 1
43
43
fi
44
44
45
45
log_info " Deploying Fluent Bit (Azure Monitor)"
@@ -55,68 +55,68 @@ generateImageKeysFile "$FB_INITCONTAINER_FULL_IMAGE" "logging/fb/fb_initcontaine
55
55
# Fluent Bit user customizations
56
56
FB_AZMONITOR_USER_YAML=" ${FB_AZMONITOR_USER_YAML:- $USER_DIR / logging/ user-values-fluent-bit-azmonitor.yaml} "
57
57
if [ ! -f " $FB_AZMONITOR_USER_YAML " ]; then
58
- log_debug " [$FB_AZMONITOR_USER_YAML ] not found. Using $TMP_DIR /empty.yaml"
59
- FB_AZMONITOR_USER_YAML=" $TMP_DIR /empty.yaml"
58
+ log_debug " [$FB_AZMONITOR_USER_YAML ] not found. Using $TMP_DIR /empty.yaml"
59
+ FB_AZMONITOR_USER_YAML=" $TMP_DIR /empty.yaml"
60
60
fi
61
61
62
62
if [ -f " $USER_DIR /logging/fluent-bit_config.configmap_azmonitor.yaml" ]; then
63
- # use copy in USER_DIR
64
- FB_CONFIGMAP=" $USER_DIR /logging/fluent-bit_config.configmap_azmonitor.yaml"
63
+ # use copy in USER_DIR
64
+ FB_CONFIGMAP=" $USER_DIR /logging/fluent-bit_config.configmap_azmonitor.yaml"
65
65
else
66
- # use copy in repo
67
- FB_CONFIGMAP=" logging/fb/fluent-bit_config.configmap_azmonitor.yaml"
66
+ # use copy in repo
67
+ FB_CONFIGMAP=" logging/fb/fluent-bit_config.configmap_azmonitor.yaml"
68
68
fi
69
69
log_info " Using FB ConfigMap: $FB_CONFIGMAP "
70
70
71
71
# Check/Create Connection Info Secret
72
72
if [ " $( kubectl -n " $LOG_NS " get secret connection-info-azmonitor -o name 2> /dev/null) " == " " ]; then
73
73
74
- export AZMONITOR_CUSTOMER_ID=" ${AZMONITOR_CUSTOMER_ID:- NotProvided} "
75
- export AZMONITOR_SHARED_KEY=" ${AZMONITOR_SHARED_KEY:- NotProvided} "
74
+ export AZMONITOR_CUSTOMER_ID=" ${AZMONITOR_CUSTOMER_ID:- NotProvided} "
75
+ export AZMONITOR_SHARED_KEY=" ${AZMONITOR_SHARED_KEY:- NotProvided} "
76
76
77
- if [ " $AZMONITOR_CUSTOMER_ID " != " NotProvided" ] && [ " $AZMONITOR_SHARED_KEY " != " NotProvided" ]; then
78
- log_info " Creating secret [connection-info-azmonitor] in [$LOG_NS ] namespace to hold Azure connection information."
79
- kubectl -n " $LOG_NS " create secret generic connection-info-azmonitor --from-literal=customer_id=" $AZMONITOR_CUSTOMER_ID " --from-literal=shared_key=" $AZMONITOR_SHARED_KEY "
80
- else
81
- log_error " Unable to create secret [$LOG_NS /connection-info-azmonitor] because missing required information: [AZMONITOR_CUSTOMER_ID: $AZMONITOR_CUSTOMER_ID ; AZMONITOR_SHARED_KEY: $AZMONITOR_SHARED_KEY ]."
82
- log_error " You must provide this information via environment variables or create the secret [connection-info-azmonitor] before running this script."
83
- exit 1
84
- fi
77
+ if [ " $AZMONITOR_CUSTOMER_ID " != " NotProvided" ] && [ " $AZMONITOR_SHARED_KEY " != " NotProvided" ]; then
78
+ log_info " Creating secret [connection-info-azmonitor] in [$LOG_NS ] namespace to hold Azure connection information."
79
+ kubectl -n " $LOG_NS " create secret generic connection-info-azmonitor --from-literal=customer_id=" $AZMONITOR_CUSTOMER_ID " --from-literal=shared_key=" $AZMONITOR_SHARED_KEY "
80
+ else
81
+ log_error " Unable to create secret [$LOG_NS /connection-info-azmonitor] because missing required information: [AZMONITOR_CUSTOMER_ID: $AZMONITOR_CUSTOMER_ID ; AZMONITOR_SHARED_KEY: $AZMONITOR_SHARED_KEY ]."
82
+ log_error " You must provide this information via environment variables or create the secret [connection-info-azmonitor] before running this script."
83
+ exit 1
84
+ fi
85
85
else
86
- log_info " Obtaining connection information from existing secret [$LOG_NS /connection-info-azmonitor]"
87
- # Fix SC2155: Declare and assign separately
88
- AZMONITOR_CUSTOMER_ID=$( kubectl -n " $LOG_NS " get secret connection-info-azmonitor -o=jsonpath=" {.data.customer_id}" | base64 --decode)
89
- export AZMONITOR_CUSTOMER_ID
90
- AZMONITOR_SHARED_KEY=$( kubectl -n " $LOG_NS " get secret connection-info-azmonitor -o=jsonpath=" {.data.shared_key}" | base64 --decode)
91
- export AZMONITOR_SHARED_KEY
86
+ log_info " Obtaining connection information from existing secret [$LOG_NS /connection-info-azmonitor]"
87
+ # Fix SC2155: Declare and assign separately
88
+ AZMONITOR_CUSTOMER_ID=$( kubectl -n " $LOG_NS " get secret connection-info-azmonitor -o=jsonpath=" {.data.customer_id}" | base64 --decode)
89
+ export AZMONITOR_CUSTOMER_ID
90
+ AZMONITOR_SHARED_KEY=$( kubectl -n " $LOG_NS " get secret connection-info-azmonitor -o=jsonpath=" {.data.shared_key}" | base64 --decode)
91
+ export AZMONITOR_SHARED_KEY
92
92
fi
93
93
94
94
# Check for an existing Helm release of stable/fluent-bit
95
95
if helm3ReleaseExists fbaz " $LOG_NS " ; then
96
- log_info " Removing an existing release of deprecated stable/fluent-bit Helm chart from from the [$LOG_NS ] namespace [$( date) ]"
97
- helm " $helmDebug " delete -n " $LOG_NS " fbaz
98
-
99
- # Fix SC2155: Declare and assign separately
100
- num_service_monitors_v2=$( kubectl get servicemonitors -A | grep -c fluent-bit-v2 || true)
101
- if [ " $num_service_monitors_v2 " -ge 1 ]; then
102
- log_debug " Updated serviceMonitor [fluent-bit-v2] appears to be deployed."
103
- else
104
- num_service_monitors=$( kubectl get servicemonitors -A | grep -c fluent-bit || true)
105
- if [ " $num_service_monitors " -ge 1 ]; then
106
- log_warn " You appear to have an obsolete service monitor in place for monitoring Fluent Bit."
107
- log_warn " Run monitoring/bin/deploy_monitoring_cluster.sh to deploy the current set of service monitors."
96
+ log_info " Removing an existing release of deprecated stable/fluent-bit Helm chart from from the [$LOG_NS ] namespace [$( date) ]"
97
+ helm " $helmDebug " delete -n " $LOG_NS " fbaz
98
+
99
+ # Fix SC2155: Declare and assign separately
100
+ num_service_monitors_v2=$( kubectl get servicemonitors -A | grep -c fluent-bit-v2 || true)
101
+ if [ " $num_service_monitors_v2 " -ge 1 ]; then
102
+ log_debug " Updated serviceMonitor [fluent-bit-v2] appears to be deployed."
103
+ else
104
+ num_service_monitors=$( kubectl get servicemonitors -A | grep -c fluent-bit || true)
105
+ if [ " $num_service_monitors " -ge 1 ]; then
106
+ log_warn " You appear to have an obsolete service monitor in place for monitoring Fluent Bit."
107
+ log_warn " Run monitoring/bin/deploy_monitoring_cluster.sh to deploy the current set of service monitors."
108
+ fi
108
109
fi
109
- fi
110
110
else
111
- log_debug " No existing release of the deprecated stable/fluent-bit Helm chart was found"
111
+ log_debug " No existing release of the deprecated stable/fluent-bit Helm chart was found"
112
112
fi
113
113
114
114
# Multiline parser setup
115
115
LOG_MULTILINE_ENABLED=" ${LOG_MULTILINE_ENABLED:- true} "
116
116
if [ " $LOG_MULTILINE_ENABLED " == " true" ]; then
117
- LOG_MULTILINE_PARSER=" docker, cri"
117
+ LOG_MULTILINE_PARSER=" docker, cri"
118
118
else
119
- LOG_MULTILINE_PARSER=" "
119
+ LOG_MULTILINE_PARSER=" "
120
120
fi
121
121
122
122
# Create ConfigMap containing Fluent Bit configuration
@@ -129,55 +129,55 @@ kubectl -n "$LOG_NS" create configmap fbaz-viya-parsers --from-file=logging/fb/v
129
129
TRACING_ENABLE=" ${TRACING_ENABLE:- false} "
130
130
tracingValuesFile=" "
131
131
if [ " $TRACING_ENABLE " == " true" ]; then
132
- # Create ConfigMap containing tracing config
133
- kubectl -n " $LOG_NS " delete configmap fbaz-viya-tracing --ignore-not-found
134
- kubectl -n " $LOG_NS " create configmap fbaz-viya-tracing --from-file=logging/fb/viya-tracing.conf
132
+ # Create ConfigMap containing tracing config
133
+ kubectl -n " $LOG_NS " delete configmap fbaz-viya-tracing --ignore-not-found
134
+ kubectl -n " $LOG_NS " create configmap fbaz-viya-tracing --from-file=logging/fb/viya-tracing.conf
135
135
136
- tracingValuesFile=" logging/fb/fluent-bit_helm_values_tracing.yaml"
136
+ tracingValuesFile=" logging/fb/fluent-bit_helm_values_tracing.yaml"
137
137
else
138
- # Create empty ConfigMap for tracing since it is expected to exist in main config
139
- kubectl -n " $LOG_NS " delete configmap fbaz-viya-tracing --ignore-not-found
140
- kubectl -n " $LOG_NS " create configmap fbaz-viya-tracing --from-file=" $TMP_DIR " /empty.yaml
138
+ # Create empty ConfigMap for tracing since it is expected to exist in main config
139
+ kubectl -n " $LOG_NS " delete configmap fbaz-viya-tracing --ignore-not-found
140
+ kubectl -n " $LOG_NS " create configmap fbaz-viya-tracing --from-file=" $TMP_DIR " /empty.yaml
141
141
142
- tracingValuesFile=" $TMP_DIR /empty.yaml"
142
+ tracingValuesFile=" $TMP_DIR /empty.yaml"
143
143
fi
144
144
145
145
# Check for Kubernetes container runtime log format info
146
146
KUBERNETES_RUNTIME_LOGFMT=" ${KUBERNETES_RUNTIME_LOGFMT:- } "
147
147
if [ -z " $KUBERNETES_RUNTIME_LOGFMT " ]; then
148
- # Fix SC2155: Declare and assign separately
149
- somenode=$( kubectl get nodes | awk ' NR==2 { print $1 }' )
150
- runtime=$( kubectl get node " $somenode " -o " jsonpath={.status.nodeInfo.containerRuntimeVersion}" | awk -F: ' {print $1}' )
151
- log_debug " Kubernetes container runtime [$runtime ] found on node [$somenode ]"
152
- case $runtime in
153
- docker)
154
- KUBERNETES_RUNTIME_LOGFMT=" docker"
155
- ;;
156
- containerd | cri-o)
157
- KUBERNETES_RUNTIME_LOGFMT=" criwithlog"
158
- ;;
159
- * )
160
- log_warn " Unrecognized Kubernetes container runtime [$runtime ]; using default parser"
161
- KUBERNETES_RUNTIME_LOGFMT=" docker"
162
- ;;
163
- esac
148
+ # Fix SC2155: Declare and assign separately
149
+ somenode=$( kubectl get nodes | awk ' NR==2 { print $1 }' )
150
+ runtime=$( kubectl get node " $somenode " -o " jsonpath={.status.nodeInfo.containerRuntimeVersion}" | awk -F: ' {print $1}' )
151
+ log_debug " Kubernetes container runtime [$runtime ] found on node [$somenode ]"
152
+ case $runtime in
153
+ docker)
154
+ KUBERNETES_RUNTIME_LOGFMT=" docker"
155
+ ;;
156
+ containerd | cri-o)
157
+ KUBERNETES_RUNTIME_LOGFMT=" criwithlog"
158
+ ;;
159
+ * )
160
+ log_warn " Unrecognized Kubernetes container runtime [$runtime ]; using default parser"
161
+ KUBERNETES_RUNTIME_LOGFMT=" docker"
162
+ ;;
163
+ esac
164
164
fi
165
165
166
166
MON_NS=" ${MON_NS:- monitoring} "
167
167
168
168
# Create ConfigMap containing Kubernetes container runtime log format
169
169
kubectl -n " $LOG_NS " delete configmap fbaz-env-vars --ignore-not-found
170
170
kubectl -n " $LOG_NS " create configmap fbaz-env-vars \
171
- --from-literal=KUBERNETES_RUNTIME_LOGFMT=" $KUBERNETES_RUNTIME_LOGFMT " \
172
- --from-literal=LOG_MULTILINE_PARSER=" ${LOG_MULTILINE_PARSER} " \
173
- --from-literal=MON_NS=" ${MON_NS} "
171
+ --from-literal=KUBERNETES_RUNTIME_LOGFMT=" $KUBERNETES_RUNTIME_LOGFMT " \
172
+ --from-literal=LOG_MULTILINE_PARSER=" ${LOG_MULTILINE_PARSER} " \
173
+ --from-literal=MON_NS=" ${MON_NS} "
174
174
175
175
kubectl -n " $LOG_NS " label configmap fbaz-env-vars managed-by=v4m-es-script
176
176
177
177
# Check to see if we are upgrading from earlier version requiring root access
178
178
if [ " $( kubectl -n " $LOG_NS " get configmap fbaz-dbmigrate-script -o name --ignore-not-found) " != " configmap/fbaz-dbmigrate-script" ]; then
179
- log_debug " Removing FB pods (if they exist) to allow migration."
180
- kubectl -n " $LOG_NS " delete daemonset v4m-fbaz --ignore-not-found
179
+ log_debug " Removing FB pods (if they exist) to allow migration."
180
+ kubectl -n " $LOG_NS " delete daemonset v4m-fbaz --ignore-not-found
181
181
fi
182
182
183
183
# Create ConfigMap containing Fluent Bit database migration script
@@ -194,14 +194,14 @@ log_debug "Installing Helm chart from artifact [$chart2install]"
194
194
195
195
# Deploy Fluent Bit via Helm chart
196
196
helm " $helmDebug " upgrade --install v4m-fbaz --namespace " $LOG_NS " \
197
- " $versionstring " \
198
- --values " $TMP_DIR /fb_imagekeysfile.yaml" \
199
- --values " $imageKeysFile " \
200
- --values logging/fb/fluent-bit_helm_values_azmonitor.yaml \
201
- --values " $FB_AZMONITOR_USER_YAML " \
202
- --values " $tracingValuesFile " \
203
- --set fullnameOverride=v4m-fbaz \
204
- " $chart2install "
197
+ " $versionstring " \
198
+ --values " $TMP_DIR /fb_imagekeysfile.yaml" \
199
+ --values " $imageKeysFile " \
200
+ --values logging/fb/fluent-bit_helm_values_azmonitor.yaml \
201
+ --values " $FB_AZMONITOR_USER_YAML " \
202
+ --values " $tracingValuesFile " \
203
+ --set fullnameOverride=v4m-fbaz \
204
+ " $chart2install "
205
205
206
206
# pause to allow migration script to complete (if necessary)
207
207
sleep 20
0 commit comments