@@ -17,8 +17,8 @@ log_debug "Script [$this_script] has started [$(date)]"
17
17
FLUENT_BIT_ENABLED=${FLUENT_BIT_ENABLED:- true}
18
18
19
19
if [ " $FLUENT_BIT_ENABLED " != " true" ]; then
20
- log_info " Environment variable [FLUENT_BIT_ENABLED] is not set to 'true'; existing WITHOUT deploying Fluent Bit"
21
- exit 0
20
+ log_info " Environment variable [FLUENT_BIT_ENABLED] is not set to 'true'; existing WITHOUT deploying Fluent Bit"
21
+ exit 0
22
22
fi
23
23
24
24
set -e
@@ -39,7 +39,7 @@ helm2ReleaseCheck "fb-$LOG_NS"
39
39
helmRepoAdd fluent https://fluent.github.io/helm-charts
40
40
41
41
# Confirm namespace exists
42
- if [ " $( kubectl get ns " $LOG_NS " -o name 2> /dev/null) " == " " ]; then
42
+ if [ " $( kubectl get ns " $LOG_NS " -o name 2> /dev/null) " == " " ]; then
43
43
log_error " The specified namespace [$LOG_NS ] does not exist."
44
44
exit 1
45
45
fi
@@ -62,55 +62,55 @@ if [ ! -f "$FB_AZMONITOR_USER_YAML" ]; then
62
62
fi
63
63
64
64
if [ -f " $USER_DIR /logging/fluent-bit_config.configmap_azmonitor.yaml" ]; then
65
- # use copy in USER_DIR
66
- FB_CONFIGMAP=" $USER_DIR /logging/fluent-bit_config.configmap_azmonitor.yaml"
65
+ # use copy in USER_DIR
66
+ FB_CONFIGMAP=" $USER_DIR /logging/fluent-bit_config.configmap_azmonitor.yaml"
67
67
else
68
- # use copy in repo
69
- FB_CONFIGMAP=" logging/fb/fluent-bit_config.configmap_azmonitor.yaml"
68
+ # use copy in repo
69
+ FB_CONFIGMAP=" logging/fb/fluent-bit_config.configmap_azmonitor.yaml"
70
70
fi
71
71
log_info " Using FB ConfigMap: $FB_CONFIGMAP "
72
72
73
73
# Check/Create Connection Info Secret
74
- if [ " $( kubectl -n " $LOG_NS " get secret connection-info-azmonitor -o name 2> /dev/null) " == " " ]; then
75
-
76
- export AZMONITOR_CUSTOMER_ID=" ${AZMONITOR_CUSTOMER_ID:- NotProvided} "
77
- export AZMONITOR_SHARED_KEY=" ${AZMONITOR_SHARED_KEY:- NotProvided} "
78
-
79
- if [ " $AZMONITOR_CUSTOMER_ID " != " NotProvided" ] && [ " $AZMONITOR_SHARED_KEY " != " NotProvided" ]; then
80
- log_info " Creating secret [connection-info-azmonitor] in [$LOG_NS ] namespace to hold Azure connection information."
81
- kubectl -n " $LOG_NS " create secret generic connection-info-azmonitor --from-literal=customer_id=" $AZMONITOR_CUSTOMER_ID " --from-literal=shared_key=" $AZMONITOR_SHARED_KEY "
82
- else
83
- 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 ]."
84
- log_error " You must provide this information via environment variables or create the secret [connection-info-azmonitor] before running this script."
85
- exit 1
86
- fi
74
+ if [ " $( kubectl -n " $LOG_NS " get secret connection-info-azmonitor -o name 2> /dev/null) " == " " ]; then
75
+
76
+ export AZMONITOR_CUSTOMER_ID=" ${AZMONITOR_CUSTOMER_ID:- NotProvided} "
77
+ export AZMONITOR_SHARED_KEY=" ${AZMONITOR_SHARED_KEY:- NotProvided} "
78
+
79
+ if [ " $AZMONITOR_CUSTOMER_ID " != " NotProvided" ] && [ " $AZMONITOR_SHARED_KEY " != " NotProvided" ]; then
80
+ log_info " Creating secret [connection-info-azmonitor] in [$LOG_NS ] namespace to hold Azure connection information."
81
+ kubectl -n " $LOG_NS " create secret generic connection-info-azmonitor --from-literal=customer_id=" $AZMONITOR_CUSTOMER_ID " --from-literal=shared_key=" $AZMONITOR_SHARED_KEY "
82
+ else
83
+ 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 ]."
84
+ log_error " You must provide this information via environment variables or create the secret [connection-info-azmonitor] before running this script."
85
+ exit 1
86
+ fi
87
87
else
88
- log_info " Obtaining connection information from existing secret [$LOG_NS /connection-info-azmonitor]"
89
- # Fix SC2155: Declare and assign separately
90
- AZMONITOR_CUSTOMER_ID=$( kubectl -n " $LOG_NS " get secret connection-info-azmonitor -o=jsonpath=" {.data.customer_id}" | base64 --decode)
91
- export AZMONITOR_CUSTOMER_ID
92
- AZMONITOR_SHARED_KEY=$( kubectl -n " $LOG_NS " get secret connection-info-azmonitor -o=jsonpath=" {.data.shared_key}" | base64 --decode)
93
- export AZMONITOR_SHARED_KEY
88
+ log_info " Obtaining connection information from existing secret [$LOG_NS /connection-info-azmonitor]"
89
+ # Fix SC2155: Declare and assign separately
90
+ AZMONITOR_CUSTOMER_ID=$( kubectl -n " $LOG_NS " get secret connection-info-azmonitor -o=jsonpath=" {.data.customer_id}" | base64 --decode)
91
+ export AZMONITOR_CUSTOMER_ID
92
+ AZMONITOR_SHARED_KEY=$( kubectl -n " $LOG_NS " get secret connection-info-azmonitor -o=jsonpath=" {.data.shared_key}" | base64 --decode)
93
+ export AZMONITOR_SHARED_KEY
94
94
fi
95
95
96
96
# Check for an existing Helm release of stable/fluent-bit
97
97
if helm3ReleaseExists fbaz " $LOG_NS " ; then
98
- log_info " Removing an existing release of deprecated stable/fluent-bit Helm chart from from the [$LOG_NS ] namespace [$( date) ]"
99
- helm " $helmDebug " delete -n " $LOG_NS " fbaz
100
-
101
- # Fix SC2155: Declare and assign separately
102
- num_service_monitors_v2=$( kubectl get servicemonitors -A | grep -c fluent-bit-v2 || true)
103
- if [ " $num_service_monitors_v2 " -ge 1 ]; then
104
- log_debug " Updated serviceMonitor [fluent-bit-v2] appears to be deployed."
105
- else
106
- num_service_monitors=$( kubectl get servicemonitors -A | grep -c fluent-bit || true)
107
- if [ " $num_service_monitors " -ge 1 ]; then
108
- log_warn " You appear to have an obsolete service monitor in place for monitoring Fluent Bit."
109
- log_warn " Run monitoring/bin/deploy_monitoring_cluster.sh to deploy the current set of service monitors."
110
- fi
111
- fi
98
+ log_info " Removing an existing release of deprecated stable/fluent-bit Helm chart from from the [$LOG_NS ] namespace [$( date) ]"
99
+ helm " $helmDebug " delete -n " $LOG_NS " fbaz
100
+
101
+ # Fix SC2155: Declare and assign separately
102
+ num_service_monitors_v2=$( kubectl get servicemonitors -A | grep -c fluent-bit-v2 || true)
103
+ if [ " $num_service_monitors_v2 " -ge 1 ]; then
104
+ log_debug " Updated serviceMonitor [fluent-bit-v2] appears to be deployed."
105
+ else
106
+ num_service_monitors=$( kubectl get servicemonitors -A | grep -c fluent-bit || true)
107
+ if [ " $num_service_monitors " -ge 1 ]; then
108
+ log_warn " You appear to have an obsolete service monitor in place for monitoring Fluent Bit."
109
+ log_warn " Run monitoring/bin/deploy_monitoring_cluster.sh to deploy the current set of service monitors."
110
+ fi
111
+ fi
112
112
else
113
- log_debug " No existing release of the deprecated stable/fluent-bit Helm chart was found"
113
+ log_debug " No existing release of the deprecated stable/fluent-bit Helm chart was found"
114
114
fi
115
115
116
116
# Multiline parser setup
147
147
# Check for Kubernetes container runtime log format info
148
148
KUBERNETES_RUNTIME_LOGFMT=" ${KUBERNETES_RUNTIME_LOGFMT:- } "
149
149
if [ -z " $KUBERNETES_RUNTIME_LOGFMT " ]; then
150
- # Fix SC2155: Declare and assign separately
151
- somenode=$( kubectl get nodes | awk ' NR==2 { print $1 }' )
152
- runtime=$( kubectl get node " $somenode " -o " jsonpath={.status.nodeInfo.containerRuntimeVersion}" | awk -F: ' {print $1}' )
153
- log_debug " Kubernetes container runtime [$runtime ] found on node [$somenode ]"
154
- case $runtime in
155
- docker)
156
- KUBERNETES_RUNTIME_LOGFMT=" docker"
157
- ;;
158
- containerd| cri-o)
159
- KUBERNETES_RUNTIME_LOGFMT=" criwithlog"
160
- ;;
161
- * )
162
- log_warn " Unrecognized Kubernetes container runtime [$runtime ]; using default parser"
163
- KUBERNETES_RUNTIME_LOGFMT=" docker"
164
- ;;
165
- esac
150
+ # Fix SC2155: Declare and assign separately
151
+ somenode=$( kubectl get nodes | awk ' NR==2 { print $1 }' )
152
+ runtime=$( kubectl get node " $somenode " -o " jsonpath={.status.nodeInfo.containerRuntimeVersion}" | awk -F: ' {print $1}' )
153
+ log_debug " Kubernetes container runtime [$runtime ] found on node [$somenode ]"
154
+ case $runtime in
155
+ docker)
156
+ KUBERNETES_RUNTIME_LOGFMT=" docker"
157
+ ;;
158
+ containerd | cri-o)
159
+ KUBERNETES_RUNTIME_LOGFMT=" criwithlog"
160
+ ;;
161
+ * )
162
+ log_warn " Unrecognized Kubernetes container runtime [$runtime ]; using default parser"
163
+ KUBERNETES_RUNTIME_LOGFMT=" docker"
164
+ ;;
165
+ esac
166
166
fi
167
167
168
168
MON_NS=" ${MON_NS:- monitoring} "
169
169
170
170
# Create ConfigMap containing Kubernetes container runtime log format
171
171
kubectl -n " $LOG_NS " delete configmap fbaz-env-vars --ignore-not-found
172
172
kubectl -n " $LOG_NS " create configmap fbaz-env-vars \
173
- --from-literal=KUBERNETES_RUNTIME_LOGFMT=" $KUBERNETES_RUNTIME_LOGFMT " \
174
- --from-literal=LOG_MULTILINE_PARSER=" ${LOG_MULTILINE_PARSER} " \
175
- --from-literal=MON_NS=" ${MON_NS} "
173
+ --from-literal=KUBERNETES_RUNTIME_LOGFMT=" $KUBERNETES_RUNTIME_LOGFMT " \
174
+ --from-literal=LOG_MULTILINE_PARSER=" ${LOG_MULTILINE_PARSER} " \
175
+ --from-literal=MON_NS=" ${MON_NS} "
176
176
177
177
kubectl -n " $LOG_NS " label configmap fbaz-env-vars managed-by=v4m-es-script
178
178
179
179
# Check to see if we are upgrading from earlier version requiring root access
180
180
if [ " $( kubectl -n " $LOG_NS " get configmap fbaz-dbmigrate-script -o name --ignore-not-found) " != " configmap/fbaz-dbmigrate-script" ]; then
181
- log_debug " Removing FB pods (if they exist) to allow migration."
182
- kubectl -n " $LOG_NS " delete daemonset v4m-fbaz --ignore-not-found
181
+ log_debug " Removing FB pods (if they exist) to allow migration."
182
+ kubectl -n " $LOG_NS " delete daemonset v4m-fbaz --ignore-not-found
183
183
fi
184
184
185
185
# Create ConfigMap containing Fluent Bit database migration script
0 commit comments