Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use yq in build script to generate overrides yamls #421

Merged
merged 2 commits into from
Feb 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 8 additions & 28 deletions ci/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -109,35 +109,20 @@ if [ -n "$GITHUB_TOKEN" ] && [ "$TRAVIS_EVENT_TYPE" == "pull_request" ]; then
# Generate override yaml files for chart dependencies to determine if changes are made to overrides yaml files
echo "Generating overrides files..."

metrics_server_start=`grep -n "metrics-server:" deploy/helm/sumologic/values.yaml | head -n 1 | cut -d: -f1`
metrics_server_start=$(($metrics_server_start + 2))
metrics_server_end=`grep -n "## Configure fluent-bit" deploy/helm/sumologic/values.yaml | head -n 1 | cut -d: -f1`
metrics_server_end=$(($metrics_server_end - 1))

echo "Copy 'values.yaml' from line $metrics_server_start to line $metrics_server_end to 'metrics-server-overrides.yaml'"
echo "Copy metrics-server section from 'values.yaml' to 'metrics-server-overrides.yaml'"
echo "# This file is auto-generated." > deploy/helm/metrics-server-overrides.yaml
# Copy lines of metrics_server section and remove indention from values.yaml
sed -n "$metrics_server_start,${metrics_server_end}p" deploy/helm/sumologic/values.yaml | sed 's/ //' >> deploy/helm/metrics-server-overrides.yaml

fluent_bit_start=`grep -n "fluent-bit:" deploy/helm/sumologic/values.yaml | head -n 1 | cut -d: -f1`
fluent_bit_start=$(($fluent_bit_start + 2))
fluent_bit_end=`grep -n "## Configure prometheus-operator" deploy/helm/sumologic/values.yaml | head -n 1 | cut -d: -f1`
fluent_bit_end=$(($fluent_bit_end - 1))
yq r deploy/helm/sumologic/values.yaml metrics-server | yq d - enabled >> deploy/helm/metrics-server-overrides.yaml

echo "Copy 'values.yaml' from line $fluent_bit_start to line $fluent_bit_end to 'fluent-bit-overrides.yaml'"
echo "Copy fluent-bit section from 'values.yaml' to 'fluent-bit-overrides.yaml'"
echo "# This file is auto-generated." > deploy/helm/fluent-bit-overrides.yaml
# Copy lines of fluent-bit section and remove indention from values.yaml
sed -n "$fluent_bit_start,${fluent_bit_end}p" deploy/helm/sumologic/values.yaml | sed 's/ //' >> deploy/helm/fluent-bit-overrides.yaml

prometheus_start=`grep -n "prometheus-operator:" deploy/helm/sumologic/values.yaml | head -n 1 | cut -d: -f1`
prometheus_start=$(($prometheus_start + 2))
prometheus_end=`grep -n "## Configure falco" deploy/helm/sumologic/values.yaml | head -n 1 | cut -d: -f1`
prometheus_end=$(($prometheus_end - 1))
yq r deploy/helm/sumologic/values.yaml fluent-bit | yq d - enabled >> deploy/helm/fluent-bit-overrides.yaml

echo "Copy 'values.yaml' from line $prometheus_start to line $prometheus_end to 'prometheus-overrides.yaml'"
echo "Copy prometheus-operator section from 'values.yaml' to 'prometheus-overrides.yaml'"
echo "# This file is auto-generated." > deploy/helm/prometheus-overrides.yaml
# Copy lines of prometheus-operator section and remove indention from values.yaml
sed -n "$prometheus_start,${prometheus_end}p" deploy/helm/sumologic/values.yaml | sed 's/ //' >> deploy/helm/prometheus-overrides.yaml
yq r deploy/helm/sumologic/values.yaml prometheus-operator >> deploy/helm/prometheus-overrides.yaml

echo "Copy prometheus.prometheusSpec.remoteWrite from 'prometheus-overrides.yaml' and inject into 'deploy/kubernetes/kube-prometheus-sumo-logic-mixin.libsonnet'"
prometheus_remote_write=`yq r deploy/helm/prometheus-overrides.yaml prometheus.prometheusSpec.remoteWrite -j | jq '.' | sed 's/^/ /'`
Expand All @@ -148,16 +133,11 @@ if [ -n "$GITHUB_TOKEN" ] && [ "$TRAVIS_EVENT_TYPE" == "pull_request" ]; then
prometheus_remote_write="${prometheus_remote_write//$'\n'/\\n}"
echo "// This file is autogenerated" > deploy/kubernetes/kube-prometheus-sumo-logic-mixin.libsonnet
sed "s#\[\/\*REMOTE_WRITE\*\/\]#$prometheus_remote_write#" ci/jsonnet-mixin.tmpl | sed 's#"http://collection-sumologic.sumologic.svc.cluster.local:9888\/#$._config.sumologicCollectorSvc + "#g' | sed 's/+: /+: /' | sed -r 's/"(\w*)":/\1:/g' > deploy/kubernetes/kube-prometheus-sumo-logic-mixin.libsonnet

falco_start=`grep -n "falco:" deploy/helm/sumologic/values.yaml | head -n 1 | cut -d: -f1`
falco_start=$(($falco_start + 2))
falco_end=`grep -n "## Configure falco" deploy/helm/sumologic/values.yaml | head -n 1 | cut -d: -f1`
falco_end=$(($falco_end - 1))

echo "Copy 'values.yaml' from line $falco_start to end to 'falco-overrides.yaml'"
echo "Copy falco section from 'values.yaml' to 'falco-overrides.yaml'"
echo "# This file is auto-generated." > deploy/helm/falco-overrides.yaml
# Copy lines of falco section and remove indention from values.yaml
sed -n "$falco_start,$ p" deploy/helm/sumologic/values.yaml | sed 's/ //' >> deploy/helm/falco-overrides.yaml
yq r deploy/helm/sumologic/values.yaml falco | yq d - enabled >> deploy/helm/falco-overrides.yaml

if [ "$(git diff deploy/helm/metrics-server-overrides.yaml)" ] || [ "$(git diff deploy/helm/fluent-bit-overrides.yaml)" ] || [ "$(git diff deploy/helm/prometheus-overrides.yaml)" ] || [ "$(git diff deploy/helm/falco-overrides.yaml)" ] || [ "$(git diff deploy/kubernetes/kube-prometheus-sumo-logic-mixin.libsonnet)" ]; then
echo "Detected changes in 'fluent-bit-overrides.yaml', 'prometheus-overrides.yaml', 'falco-overrides.yaml', or 'kube-prometheus-sumo-logic-mixin.libsonnet', committing the updated version to $TRAVIS_PULL_REQUEST_BRANCH..."
Expand Down
14 changes: 4 additions & 10 deletions deploy/helm/fluent-bit-overrides.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,19 @@ backend:
tls_verify: "on"
tls_debug: 1
shared_key:

trackOffsets: true

tolerations:
- effect: NoSchedule
operator: Exists

- effect: NoSchedule
operator: Exists
input:
systemd:
enabled: true

parsers:
enabled: true
# This regex matches the first line of a multiline log starting with a date of the format : "2019-11-17 07:14:12" or "2019-11-17T07:14:12"
regex:
- name: multi_line
regex: (?<log>^{"log":"\d{4}-\d{1,2}-\d{1,2}.\d{2}:\d{2}:\d{2}.*)

- name: multi_line
regex: (?<log>^{"log":"\d{4}-\d{1,2}-\d{1,2}.\d{2}:\d{2}:\d{2}.*)
rawConfig: |-
@INCLUDE fluent-bit-service.conf

Expand Down Expand Up @@ -101,4 +96,3 @@ rawConfig: |-
Read_From_Tail true

@INCLUDE fluent-bit-output.conf

5 changes: 2 additions & 3 deletions deploy/helm/metrics-server-overrides.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# This file is auto-generated.
args:
- --kubelet-insecure-tls
- --kubelet-preferred-address-types=InternalIP,ExternalIP,Hostname

- --kubelet-insecure-tls
- --kubelet-preferred-address-types=InternalIP,ExternalIP,Hostname
Loading