Skip to content

Commit

Permalink
Fix fluent-bit extraVolumes and extraVolumeMounts migration for v2
Browse files Browse the repository at this point in the history
  • Loading branch information
pmalek committed Jan 15, 2021
1 parent a6aaa71 commit bed9f2a
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 13 deletions.
15 changes: 10 additions & 5 deletions deploy/helm/sumologic/upgrade-2.0.0.sh
Original file line number Diff line number Diff line change
Expand Up @@ -657,12 +657,17 @@ function migrate_fluent_bit() {
yq w -i "${TEMP_FILE}" 'fluent-bit.service.labels."sumologic.com/scrape"' --style double true
fi

yq w -i "${TEMP_FILE}" 'fluent-bit.extraVolumeMounts[+].mountPath' '/tail-db'
yq w -i "${TEMP_FILE}" 'fluent-bit.extraVolumeMounts[0].name' 'tail-db'
local EXTRA_VOLUMES
readonly EXTRA_VOLUMES="$(yq r "${TEMP_FILE}" -- 'fluent-bit.extraVolumes')"
if [[ -n "${EXTRA_VOLUMES}" ]]; then
yq w -i "${TEMP_FILE}" 'fluent-bit.extraVolumes' --from <(echo "${EXTRA_VOLUMES}")
fi

yq w -i "${TEMP_FILE}" 'fluent-bit.extraVolumes[+].hostPath.path' '/var/lib/fluent-bit'
yq w -i "${TEMP_FILE}" 'fluent-bit.extraVolumes[0].hostPath.type' 'DirectoryOrCreate'
yq w -i "${TEMP_FILE}" 'fluent-bit.extraVolumes[0].name' 'tail-db'
local EXTRA_VOLUME_MOUNTS
readonly EXTRA_VOLUME_MOUNTS="$(yq r "${TEMP_FILE}" -- 'fluent-bit.extraVolumeMounts')"
if [[ -n "${EXTRA_VOLUME_MOUNTS}" ]]; then
yq w -i "${TEMP_FILE}" 'fluent-bit.extraVolumeMounts' --from <(echo "${EXTRA_VOLUME_MOUNTS}")
fi

local CONFIG_KEY_WIDTH
readonly CONFIG_KEY_WIDTH="22"
Expand Down
21 changes: 21 additions & 0 deletions tests/upgrade_v2_script/static/fluent_bit.input.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,27 @@ fluent-bit:
valueFrom:
fieldRef:
fieldPath: metadata.namespace
extraVolumes:
- name: ossec-db
emptyDir: {}
- name: suricata-db
emptyDir: {}
- name: ossec-alerts
hostPath:
path: /var/ossec/logs/alerts/alerts.json
type: File
- name: forge-db
emptyDir: {}
extraVolumeMounts:
- name: ossec-db
mountPath: /fluent-bit/ossec
- name: suricata-db
mountPath: /fluent-bit/suricata
- name: ossec-alerts
mountPath: /var/ossec/logs/alerts/alerts.json
readOnly: true
- name: forge-db
mountPath: /fluent-bit/forge
tolerations:
- effect: NoSchedule
operator: Exists
Expand Down
29 changes: 21 additions & 8 deletions tests/upgrade_v2_script/static/fluent_bit.output.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,27 @@ fluent-bit:
valueFrom:
fieldRef:
fieldPath: metadata.namespace
extraVolumes:
- name: ossec-db
emptyDir: {}
- name: suricata-db
emptyDir: {}
- name: ossec-alerts
hostPath:
path: /var/ossec/logs/alerts/alerts.json
type: File
- name: forge-db
emptyDir: {}
extraVolumeMounts:
- name: ossec-db
mountPath: /fluent-bit/ossec
- name: suricata-db
mountPath: /fluent-bit/suricata
- name: ossec-alerts
mountPath: /var/ossec/logs/alerts/alerts.json
readOnly: true
- name: forge-db
mountPath: /fluent-bit/forge
tolerations:
- effect: NoSchedule
operator: Exists
Expand All @@ -19,14 +40,6 @@ fluent-bit:
service:
labels:
sumologic.com/scrape: "true"
extraVolumeMounts:
- mountPath: /tail-db
name: tail-db
extraVolumes:
- hostPath:
path: /var/lib/fluent-bit
type: DirectoryOrCreate
name: tail-db
config:
inputs: |-
[INPUT]
Expand Down

0 comments on commit bed9f2a

Please sign in to comment.