Skip to content

Commit

Permalink
Merge pull request #174 from SumoLogic/rmiller-helm-yaml-test
Browse files Browse the repository at this point in the history
Fix Helm template naming in yaml files
  • Loading branch information
Ryan Miller committed Sep 3, 2019
2 parents cfa7ab7 + 650c91e commit 2b24687
Show file tree
Hide file tree
Showing 7 changed files with 91 additions and 109 deletions.
6 changes: 1 addition & 5 deletions ci/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ if [ "$TRAVIS_BRANCH" != "master" ] && [ "$TRAVIS_EVENT_TYPE" == "push" ] && [ -
cd ../../../

with_files=`ls deploy/helm/sumologic/templates/*.yaml | sed 's#deploy/helm/sumologic/templates#-x templates#g' | sed 's/yaml/yaml \\\/g'`
eval 'sudo helm template deploy/helm/sumologic $with_files --namespace "\$NAMESPACE" --set dryRun=true >> deploy/kubernetes/fluentd-sumologic.yaml.tmpl'
eval 'sudo helm template deploy/helm/sumologic $with_files --namespace "\$NAMESPACE" --name collection --set dryRun=true >> deploy/kubernetes/fluentd-sumologic.yaml.tmpl'

if [[ $(git diff deploy/kubernetes/fluentd-sumologic.yaml.tmpl) ]]; then
echo "Detected changes in 'fluentd-sumologic.yaml.tmpl', committing the updated version to $TRAVIS_BRANCH..."
Expand All @@ -100,8 +100,6 @@ if [ "$TRAVIS_BRANCH" != "master" ] && [ "$TRAVIS_EVENT_TYPE" == "push" ] && [ -
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
# Remove release name from service name
sed -i 's/collection-sumologic/fluentd/' 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))
Expand All @@ -112,8 +110,6 @@ if [ "$TRAVIS_BRANCH" != "master" ] && [ "$TRAVIS_EVENT_TYPE" == "push" ] && [ -
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
# Remove release name from service name
sed -i 's/collection-sumologic/fluentd/' deploy/helm/prometheus-overrides.yaml

falco_start=`grep -n "falco:" deploy/helm/sumologic/values.yaml | head -n 1 | cut -d: -f1`
falco_start=$(($falco_start + 2))
Expand Down
2 changes: 1 addition & 1 deletion deploy/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ Before installing `prometheus-operator`, edit `prometheus-overrides.yaml` to def

__NOTE__ It’s fine to change the value of the `cluster` field, but don’t change the field name (key).

__NOTE__ If you plan to install Prometheus in a different namespace than you deployed FluentD to in Step 1, or you have an existing Prometheus you plan to apply our configuration to running in a different namespace, please update the remote write API configuration to use the full service url. e.g. `http://fluentd.sumologic.svc.cluster.local:9888`.
__NOTE__ If you plan to install Prometheus in a different namespace than you deployed FluentD to in Step 1, or you have an existing Prometheus you plan to apply our configuration to running in a different namespace, please update the remote write API configuration to use the full service url. e.g. `http://collection-sumologic.sumologic.svc.cluster.local:9888`.

You can also [Filter metrics](#filter-metrics) and [Trim and relabel metrics](#trim-and-relabel-metrics) in `prometheus-overrides.yaml`.

Expand Down
2 changes: 1 addition & 1 deletion deploy/helm/fluent-bit-overrides.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ metrics:
backend:
type: forward
forward:
host: fluentd.sumologic.svc.cluster.local
host: collection-sumologic.sumologic.svc.cluster.local
port: 24321
tls: "off"
tls_verify: "on"
Expand Down
106 changes: 51 additions & 55 deletions deploy/helm/prometheus-overrides.yaml

Large diffs are not rendered by default.

14 changes: 4 additions & 10 deletions deploy/helm/sumologic/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -9,30 +9,24 @@ Expand the name of the chart.
{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If dryRun=true, we use fixed value "fluentd".
*/}}
{{- define "sumologic.fullname" -}}
{{- if .Values.dryRun }}
{{- printf "fluentd" }}
{{- else -}}
{{- $name := default .Chart.Name .Values.nameOverride -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end -}}
{{- end -}}

{{/*
Create default fully qualified labels.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If dryRun=true, we use the Chart name "sumologic" and do not include labels specific to Helm.
*/}}
{{- define "sumologic.labels.app" -}}
{{- if .Values.dryRun }}
{{- template "sumologic.name" . }}
{{- else -}}
{{- template "sumologic.fullname" . }}
{{- end -}}
{{- end -}}

{{/*
Create common labels used throughout the chart.
If dryRun=true, we do not create any chart labels.
*/}}
{{- define "sumologic.labels.common" -}}
{{- if .Values.dryRun -}}
{{- else -}}
Expand Down
10 changes: 3 additions & 7 deletions deploy/helm/sumologic/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,7 @@ prometheus-operator:
additionalServiceMonitors:
- name: collection-sumologic
additionalLabels:
app: sumologic
release: collection
app: collection-sumologic
endpoints:
- port: metrics
namespaceSelector:
Expand All @@ -230,8 +229,7 @@ prometheus-operator:
app: collection-sumologic
- name: collection-sumologic-events
additionalLabels:
app: sumologic-events
release: collection
app: collection-sumologic-events
endpoints:
- port: metrics
namespaceSelector:
Expand All @@ -242,8 +240,7 @@ prometheus-operator:
app: collection-sumologic-events
- name: collection-fluent-bit
additionalLabels:
app: fluent-bit
release: collection
app: collection-fluent-bit
endpoints:
- port: metrics
path: /api/v1/metrics/prometheus
Expand All @@ -253,7 +250,6 @@ prometheus-operator:
selector:
matchLabels:
app: fluent-bit
release: collection
prometheusSpec:
externalLabels:
# Set this to a value to distinguish between different k8s clusters
Expand Down
60 changes: 30 additions & 30 deletions deploy/kubernetes/fluentd-sumologic.yaml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: fluentd
name: collection-sumologic
labels:
app: sumologic
app: collection-sumologic

data:
fluent.conf: |-
Expand Down Expand Up @@ -241,9 +241,9 @@ data:
apiVersion: v1
kind: ConfigMap
metadata:
name: fluentd-events
name: collection-sumologic-events
labels:
app: sumologic-events
app: collection-sumologic-events

data:
fluent.conf: |-
Expand Down Expand Up @@ -284,18 +284,18 @@ data:
apiVersion: v1
kind: ServiceAccount
metadata:
name: fluentd
name: collection-sumologic
labels:
app: sumologic
app: collection-sumologic

---
# Source: sumologic/templates/clusterrole.yaml
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: fluentd
name: collection-sumologic
labels:
app: sumologic
app: collection-sumologic

rules:
- apiGroups: ["", "apps", "extensions", "events.k8s.io"]
Expand All @@ -321,30 +321,30 @@ rules:
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: fluentd
name: collection-sumologic
labels:
app: sumologic
app: collection-sumologic

subjects:
- kind: ServiceAccount
namespace: $NAMESPACE
name: fluentd
name: collection-sumologic
roleRef:
kind: ClusterRole
name: fluentd
name: collection-sumologic
apiGroup: rbac.authorization.k8s.io
---
# Source: sumologic/templates/events-service.yaml
apiVersion: v1
kind: Service
metadata:
name: fluentd-events
name: collection-sumologic-events
labels:
app: sumologic-events
app: collection-sumologic-events

spec:
selector:
app: sumologic-events
app: collection-sumologic-events
ports:
- name: metrics
port: 24231
Expand All @@ -356,13 +356,13 @@ spec:
apiVersion: v1
kind: Service
metadata:
name: fluentd
name: collection-sumologic
labels:
app: sumologic
app: collection-sumologic

spec:
selector:
app: sumologic
app: collection-sumologic
ports:
- name: prom-write
port: 9888
Expand All @@ -382,30 +382,30 @@ spec:
apiVersion: apps/v1
kind: Deployment
metadata:
name: fluentd
name: collection-sumologic
labels:
app: sumologic
app: collection-sumologic

spec:
selector:
matchLabels:
app: sumologic
app: collection-sumologic
replicas: 3
template:
metadata:
labels:
app: sumologic
app: collection-sumologic

spec:
serviceAccountName: fluentd
serviceAccountName: collection-sumologic
volumes:
- name: pos-files
hostPath:
path: /var/run/fluentd-pos
type: ""
- name: config-volume
configMap:
name: fluentd
name: collection-sumologic
containers:
- name: fluentd
image: sumologic/kubernetes-fluentd:0.3.0
Expand Down Expand Up @@ -536,29 +536,29 @@ spec:
apiVersion: apps/v1
kind: Deployment
metadata:
name: fluentd-events
name: collection-sumologic-events
labels:
app: sumologic-events
app: collection-sumologic-events

spec:
selector:
matchLabels:
app: sumologic-events
app: collection-sumologic-events
template:
metadata:
labels:
app: sumologic-events
app: collection-sumologic-events

spec:
serviceAccountName: fluentd
serviceAccountName: collection-sumologic
volumes:
- name: pos-files
hostPath:
path: /var/run/fluentd-pos
type: ""
- name: config-volume
configMap:
name: fluentd-events
name: collection-sumologic-events
containers:
- name: fluentd-events
image: sumologic/kubernetes-fluentd:0.3.0
Expand Down

0 comments on commit 2b24687

Please sign in to comment.