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

Helm Chart initial commit #118

Merged
merged 7 commits into from
Aug 7, 2019
Merged
Show file tree
Hide file tree
Changes from 2 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
22 changes: 22 additions & 0 deletions deploy/helm/sumologic/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
5 changes: 5 additions & 0 deletions deploy/helm/sumologic/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
apiVersion: v1
appVersion: "1.0"
maimaisie marked this conversation as resolved.
Show resolved Hide resolved
description: A Helm chart for collecting Kubernetes logs, metrics and events into Sumo Logic.
name: sumologic
version: 0.1.0
8 changes: 8 additions & 0 deletions deploy/helm/sumologic/conf/buffer.output.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<buffer>
@type memory
compress gzip
flush_interval "#{ENV['FLUSH_INTERVAL']}"
flush_thread_count "#{ENV['NUM_THREADS']}"
chunk_limit_size "#{ENV['CHUNK_LIMIT_SIZE']}"
total_limit_size "#{ENV['TOTAL_LIMIT_SIZE']}"
</buffer>
8 changes: 8 additions & 0 deletions deploy/helm/sumologic/conf/common.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<source>
@type prometheus
metrics_path /metrics
port 24231
</source>
<source>
@type prometheus_output_monitor
</source>
29 changes: 29 additions & 0 deletions deploy/helm/sumologic/conf/events/events.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<source>
@type prometheus
metrics_path /metrics
port 24231
</source>
<source>
@type prometheus_output_monitor
</source>
<source>
@type events
deploy_namespace $NAMESPACE
maimaisie marked this conversation as resolved.
Show resolved Hide resolved
</source>
<match kubernetes.**>
@type sumologic
@id sumologic.endpoint.events
endpoint "#{ENV['SUMO_ENDPOINT_EVENTS']}"
data_type logs
disable_cookies true
verify_ssl "#{ENV['VERIFY_SSL']}"
proxy_uri "#{ENV['PROXY_URI']}"
<buffer>
@type memory
compress gzip
flush_interval "#{ENV['FLUSH_INTERVAL']}"
flush_thread_count "#{ENV['NUM_THREADS']}"
chunk_limit_size "#{ENV['CHUNK_LIMIT_SIZE']}"
total_limit_size "#{ENV['TOTAL_LIMIT_SIZE']}"
</buffer>
</match>
7 changes: 7 additions & 0 deletions deploy/helm/sumologic/conf/logs/logs.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<source>
@type forward
port 24321
bind 0.0.0.0
</source>
@include logs.source.containers.conf
@include logs.source.systemd.conf
9 changes: 9 additions & 0 deletions deploy/helm/sumologic/conf/logs/logs.output.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
data_type logs
log_key log
endpoint "#{ENV['SUMO_ENDPOINT_LOGS']}"
verify_ssl "#{ENV['VERIFY_SSL']}"
log_format "#{ENV['LOG_FORMAT']}"
add_timestamp "#{ENV['ADD_TIMESTAMP']}"
timestamp_key "#{ENV['TIMESTAMP_KEY']}"
proxy_uri "#{ENV['PROXY_URI']}"
@include buffer.output.conf
57 changes: 57 additions & 0 deletions deploy/helm/sumologic/conf/logs/logs.source.containers.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<filter containers.**>
@type concat
key log
multiline_start_regexp "#{ENV['MULTILINE_START_REGEXP']}"
separator "#{ENV['CONCAT_SEPARATOR']}"
timeout_label @NORMAL
</filter>
<match containers.**>
@type relabel
@label @NORMAL
</match>
<label @NORMAL>
<filter containers.**>
@type kubernetes_metadata
@log_level warn
annotation_match ["sumologic\.com.*"]
de_dot false
watch "#{ENV['K8S_METADATA_FILTER_WATCH']}"
ca_file "#{ENV['K8S_METADATA_FILTER_CA_FILE']}"
verify_ssl "#{ENV['K8S_METADATA_FILTER_VERIFY_SSL']}"
client_cert "#{ENV['K8S_METADATA_FILTER_CLIENT_CERT']}"
client_key "#{ENV['K8S_METADATA_FILTER_CLIENT_KEY']}"
bearer_token_file "#{ENV['K8S_METADATA_FILTER_BEARER_TOKEN_FILE']}"
cache_size "#{ENV['K8S_METADATA_FILTER_BEARER_CACHE_SIZE']}"
cache_ttl "#{ENV['K8S_METADATA_FILTER_BEARER_CACHE_TTL']}"
tag_to_kubernetes_name_regexp '.+?\.containers\.(?<pod_name>[^_]+)_(?<namespace>[^_]+)_(?<container_name>.+)-(?<docker_id>[a-z0-9]{64})\.log$'
merge_json_log false
</filter>
<filter **>
@type enhance_k8s_metadata
in_namespace_path '$.kubernetes.namespace_name'
in_pod_path '$.kubernetes.pod_name'
data_type logs
</filter>
<filter containers.**>
@type kubernetes_sumologic
source_name "#{ENV['SOURCE_NAME']}"
source_host "#{ENV['SOURCE_HOST']}"
log_format "#{ENV['LOG_FORMAT']}"
kubernetes_meta "#{ENV['KUBERNETES_META']}"
kubernetes_meta_reduce "#{ENV['KUBERNETES_META_REDUCE']}"
add_stream "#{ENV['ADD_STREAM']}"
add_time "#{ENV['ADD_TIME']}"
source_category "#{ENV['SOURCE_CATEGORY']}"
source_category_prefix "#{ENV['SOURCE_CATEGORY_PREFIX']}"
source_category_replace_dash "#{ENV['SOURCE_CATEGORY_REPLACE_DASH']}"
exclude_namespace_regex "#{ENV['EXCLUDE_NAMESPACE_REGEX']}"
exclude_pod_regex "#{ENV['EXCLUDE_POD_REGEX']}"
exclude_container_regex "#{ENV['EXCLUDE_CONTAINER_REGEX']}"
exclude_host_regex "#{ENV['EXCLUDE_HOST_REGEX']}"
</filter>
<match **>
@type sumologic
@id sumologic.endpoint.logs
@include logs.output.conf
</match>
</label>
47 changes: 47 additions & 0 deletions deploy/helm/sumologic/conf/logs/logs.source.systemd.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<match host.kubelet.**>
@type relabel
@label @KUBELET
</match>
<label @KUBELET>
<filter host.kubelet.**>
@type kubernetes_sumologic
source_category kubelet
source_name k8s_kubelet
source_category_prefix "#{ENV['SOURCE_CATEGORY_PREFIX']}"
exclude_facility_regex "#{ENV['EXCLUDE_FACILITY_REGEX']}"
exclude_host_regex "#{ENV['EXCLUDE_HOST_REGEX']}"
exclude_priority_regex "#{ENV['EXCLUDE_PRIORITY_REGEX']}"
exclude_unit_regex "#{ENV['EXCLUDE_UNIT_REGEX']}"
</filter>
<match **>
@type sumologic
@id sumologic.endpoint.logs.kubelet
@include logs.output.conf
</match>
</label>
<match host.**>
@type relabel
@label @SYSTEMD
</match>
<label @SYSTEMD>
<filter host.**>
@type kubernetes_sumologic
source_category system
source_category_prefix "#{ENV['SOURCE_CATEGORY_PREFIX']}"
exclude_facility_regex "#{ENV['EXCLUDE_FACILITY_REGEX']}"
exclude_host_regex "#{ENV['EXCLUDE_HOST_REGEX']}"
exclude_priority_regex "#{ENV['EXCLUDE_PRIORITY_REGEX']}"
exclude_unit_regex "#{ENV['EXCLUDE_UNIT_REGEX']}"
</filter>
<filter host.**>
@type record_modifier
<record>
_sumo_metadata ${record["_sumo_metadata"][:source] = tag_parts[1]; record["_sumo_metadata"]}
</record>
</filter>
<match **>
@type sumologic
@id sumologic.endpoint.logs.systemd
@include logs.output.conf
</match>
</label>
72 changes: 72 additions & 0 deletions deploy/helm/sumologic/conf/metrics/metrics.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<source>
@type http
port 9888
<parse>
@type protobuf
</parse>
</source>
<match prometheus.metrics.operator.rule>
@type datapoint
tag prometheus.datapoint.operator.rule
</match>
<match prometheus.metrics**>
@type datapoint
tag prometheus.datapoint
</match>
<match prometheus.datapoint>
@type rewrite_tag_filter
<rule>
key job
pattern ^(.*)$
tag ${tag}.$1
</rule>
</match>
<filter prometheus.datapoint**>
@type enhance_k8s_metadata
</filter>
<filter prometheus.datapoint**>
@type prometheus_format
relabel container_name:container,pod_name:pod
</filter>
<match prometheus.datapoint.apiserver**>
@type sumologic
@id sumologic.endpoint.metrics.apiserver
endpoint "#{ENV['SUMO_ENDPOINT_METRICS_APISERVER']}"
@include metrics.output.conf
</match>
<match prometheus.datapoint.kubelet**>
@type sumologic
@id sumologic.endpoint.metrics.kubelet
endpoint "#{ENV['SUMO_ENDPOINT_METRICS_KUBELET']}"
@include metrics.output.conf
</match>
<match prometheus.datapoint.kube-controller-manager**>
@type sumologic
@id sumologic.endpoint.metrics.kube.controller.manager
endpoint "#{ENV['SUMO_ENDPOINT_METRICS_KUBE_CONTROLLER_MANAGER']}"
@include metrics.output.conf
</match>
<match prometheus.datapoint.kube-scheduler**>
@type sumologic
@id sumologic.endpoint.metrics.kube.scheduler
endpoint "#{ENV['SUMO_ENDPOINT_METRICS_KUBE_SCHEDULER']}"
@include metrics.output.conf
</match>
<match prometheus.datapoint.kube-state**>
@type sumologic
@id sumologic.endpoint.metrics.kube.state
endpoint "#{ENV['SUMO_ENDPOINT_METRICS_KUBE_STATE']}"
@include metrics.output.conf
</match>
<match prometheus.datapoint.node-exporter**>
@type sumologic
@id sumologic.endpoint.metrics.node.exporter
endpoint "#{ENV['SUMO_ENDPOINT_METRICS_NODE_EXPORTER']}"
@include metrics.output.conf
</match>
<match prometheus.datapoint**>
@type sumologic
@id sumologic.endpoint.metrics
endpoint "#{ENV['SUMO_ENDPOINT_METRICS']}"
@include metrics.output.conf
</match>
4 changes: 4 additions & 0 deletions deploy/helm/sumologic/conf/metrics/metrics.output.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
data_type metrics
metric_data_format prometheus
disable_cookies true
@include buffer.output.conf
56 changes: 56 additions & 0 deletions deploy/helm/sumologic/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "sumologic.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end -}}

{{/*
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".
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when we need to generate yaml files, we would set dryRun (for the lack of a better name) to true to use fixed values for release name and the app label
eg.
helm template ./sumologic --set dryRun=true --namespace sumologic

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is such that the generated yaml for non-helm users will be consistent with the yaml we currently provide in the repo. for example our current yaml uses fluentd as the name for a lot of resources but in helm we would prefix with the release name followed by the chart name

*/}}
{{- 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 -}}

{{- define "sumologic.labels.common" -}}
{{- if .Values.dryRun -}}
{{- else -}}
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
release: "{{ .Release.Name }}"
heritage: "{{ .Release.Service }}"
{{- end -}}
{{- end -}}

{{/*
Create a default fully qualified fluentd user conf name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
*/}}
{{- define "sumologic.fluentdUserConfig.fullname" -}}
maimaisie marked this conversation as resolved.
Show resolved Hide resolved
{{- printf "%s-config" (include "sumologic.fullname" .) | trunc 63 | trimSuffix "-" }}
{{- end -}}

{{- define "sumologic.fluentdUserConfigEvents.fullname" -}}
{{- printf "%s-events-config" (include "sumologic.fullname" .) | trunc 63 | trimSuffix "-" }}
{{- end -}}

26 changes: 26 additions & 0 deletions deploy/helm/sumologic/templates/clusterrole.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRole
metadata:
name: {{ template "sumologic.fullname" . }}
labels:
app: {{ template "sumologic.labels.app" . }}
{{ template "sumologic.labels.common" . }}
rules:
- apiGroups: ["", "apps", "extensions", "events.k8s.io"]
resources:
- configmaps
- daemonsets
- deployments
- endpoints
- events
- namespaces
- nodes
- pods
- replicasets
- services
- statefulsets
verbs: ["get", "list", "watch"]
- apiGroups: [""]
resources:
- configmaps
verbs: ["create", "patch"]
15 changes: 15 additions & 0 deletions deploy/helm/sumologic/templates/clusterrolebinding.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRoleBinding
metadata:
name: {{ template "sumologic.fullname" . }}
labels:
app: {{ template "sumologic.labels.app" . }}
{{ template "sumologic.labels.common" . }}
subjects:
- kind: ServiceAccount
namespace: {{ .Release.Namespace }}
name: {{ template "sumologic.fullname" . }}
roleRef:
kind: ClusterRole
name: {{ template "sumologic.fullname" . }}
apiGroup: rbac.authorization.k8s.io
Loading