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

Add Refinery chart #27

Merged
merged 12 commits into from
Mar 30, 2021
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ You can use Helm for installing [Honeycomb](https://honeycomb.io) packages in yo

Packages:
- [Honeycomb Kubernetes Agent](./honeycomb/)
- [Honeycomb Refinery](./refinery)
- [Honeycomb Secure Tenancy Proxy](./secure-tenancy)
- [OpenTelemetry-Collector](./opentelemetry-collector)

Expand Down
23 changes: 23 additions & 0 deletions refinery/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# 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
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
19 changes: 19 additions & 0 deletions refinery/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
apiVersion: v2
name: refinery
description: Chart to deploy Honeycomb Refinery
type: application
version: 1.0.0
appVersion: 1.1.1
keywords:
- refinery
- honeycomb
- observability
- sampling
- tracing
home: https://honeycomb.io
sources:
- https://github.com/honeycombio/refinery
icon: https://www.honeycomb.io/wp-content/themes/honeycomb/assets/img/logo.svg
maintainers:
- name: puckpuck
email: pierre@honeycomb.io
158 changes: 158 additions & 0 deletions refinery/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
# Refinery: Sampling Proxy Service for Honeycomb

[Refinery](https://github.com/honeycombio/refinery) is a trace-aware sampling proxy server for Honeycomb.

[Honeycomb](https://honeycomb.io) is built for modern software teams to see and understand how their production systems are behaving.
Our goal is to give engineers the observability they need to eliminate toil and delight their users.
This Helm Chart will install Refinery with the desired sampling rules passed in via a configuration file.

## TL;DR

Install the chart with a deterministic sample rate of 1 out of every 2 events.
```console
helm repo add honeycomb https://honeycombio.github.io/helm-charts
helm install refinery honeycomb/refinery --set rules.SampleRate=2
```

## Prerequisites

- Helm 3.0+

## Installing the Chart

Install Refinery with your custom chart values file

```console
helm install refinery honeycomb/refinery --values /path/to/refinery-values.yaml
```

If no configuration file is passed in, Refinery will deploy with the default configuration in [`values.yaml`](./values.yaml).

## Configuring sampling rules

The **Sample Rate** in Honeycomb is expressed as the denominator for 1 out of X events.
A sample rate of 20 means to keep 1 event from every 20, which is also equivalent to a 5% sampling you may see with other platforms.

[The Refinery documentation](https://docs.honeycomb.io/manage-data-volume/refinery/sampling-methods/) goes into more detail about how each sampling method works.
These example configurations are provided to demonstrate how to define rules in YAML.

### Deterministic Sampler

The default sampling method uses the `DeterministicSampler` with a `SampleRate` of 1.
This means that all of your data is sent to Honeycomb.
Refinery does not down-sample your data by default.

```yaml
rules:
# DryRun: false
Sampler: DeterministicSampler
SampleRate: 1
```

### Rules Based Sampler

The Rules Based Sampler allows you to specify specific span attribute values that will be used to determine a sample rate applied to the trace.
Rules are evaluated in order as they appear in the configuration.
A default rule should also be specified as the last rule.

```yaml
rules:
# DryRun: false
my_dataset:
Sampler: "RulesBasedSampler"
Rule:
- Name: "keep 5xx errors"
SampleRate: 1
Condition:
- Field: "status_code"
Operator: ">="
Value: 500
- Name: "downsample 200 responses"
SampleRate: 1000
Condition:
- Field: "http.status_code"
Operator: "="
Value: 200
- Name: "send 1 in 10 traces"
SampleRate: 10 # base case
```

### Exponential Moving Average (EMA) Dynamic Sampler

The EMA Dynamic Sampler, will determine sampling rates, based on field values.
Values that are seen often (ie: http status 200) will get sampled less than values that are rare (ie: http status 500).
You configure which fields to use for sampling decisions, the exponential moving average adjustment interval, and weight.
This is the recommended sampling method for most teams.

```yaml
rules:
# DryRun: false
my_dataset:
Sampler: "EMADynamicSampler"
GoalSampleRate: 2
FieldList:
- "request.method"
- "response.status_code"
AdjustmentInterval: 15
Weight: 0.5
```

## Configuration

The repository's [values.yaml](./values.yaml) file contains information about all configuration options for this chart.

### Refinery Metrics

If you decide to send [Refinery's runtime metrics](https://docs.honeycomb.io/manage-data-volume/refinery/scale-and-troubleshoot/#understanding-refinerys-metrics) to Honeycomb, you will need to give Refinery an API for the team you want those metrics sent to.

You can obtain your API Key by going to your Account profile page within your Honeycomb instance.

```yaml
# refinery.yaml
config:
Metrics: honeycomb
HoneycombMetrics:
# MetricsHoneycombAPI: https://api.honeycomb.io # default
MetricsAPIKey: YOUR_API_KEY
# MetricsDataset: "Refinery Metrics" # default
# MetricsReportingInterval: 3 # default
```

## Parameters

The following table lists the configurable parameters of the Refinery chart and their default values, as defined in [`values.yaml`](./values.yaml).

| Parameter | Description | Default |
| --- | --- | --- |
| `replicaCount` | Number of Refinery replicas | `2` |
| `image.repository` | Refinery image name | `honeycombio/refinery` |
| `image.pullPolicy` | Refinery image pull policy | `IfNotPresent` |
| `image.tag` | Refinery image tag (leave blank to use app version) | `nil` |
| `imagePullSecrets` | Specify docker-registry secret names as an array | `[]` |
| `nameOverride` | String to partially override refinery.fullname template with a string (will append the release name) | `nil` |
| `fullnameOverride` | String to fully override refinery.fullname template with a string | `nil` |
| `config` | Refinery core Configuration | see [Refinery Configuration](#configuration) |
| `rules` | Refinery sampling rules | see [Configuring sampling rules](#configuring-sampling-rules) |
| `redis.enabled` | When true, a Redis instance will be installed | `true` |
| `redis.existingHost` | If `redis.enabled` is false, this must be set to the name and port of an existing Redis service | `nil` |
| `redis.image.repository` | Redis image name | `redis` |
| `redis.image.tag` | Redis image tag | `6.0.2` |
| `redis.image.pullPolicy` | Redis image pull policy | `IfNotPresent` |
| `serviceAccount.create` | Specify whether a ServiceAccount should be created | `true` |
| `serviceAccount.name` | The name of the ServiceAccount to create | Generated using the `refinery.fullname` template |
| `serviceAccount.annotations` | Annotations to be applied to ServiceAccount | `{}` |
| `podAnnotations` | Pod annotations | `{}` |
| `podSecurityContext` | Security context for pod | `{}` |
| `securityContext` | Security context for container | `{}` |
| `service.type` | Kubernetes Service type | `ClusterIP` |
| `service.port` | Service port | `80` |
| `service.annotations` | Service annotations | `{}` |
| `ingress.enabled` | Enable ingress controller resource | `false` |
| `ingress.annotations` | Ingress annotations | `{}` |
| `ingress.hosts[0].name` | Hostname to your Refinery installation | `refinery.local` |
| `ingress.hosts[0].paths` | Path within the url structure | `[]` |
| `ingress.tls` | TLS hosts | `[]` |
| `resources` | CPU/Memory resource requests/limits | limit: 1000m/2Gi, request: 500m/500Mi |
| `nodeSelector` | Node labels for pod assignment | `{}` |
| `tolerations` | Tolerations for pod assignment | `[]`|
| `affinity` | Map of node/pod affinities | `{}` |
2 changes: 2 additions & 0 deletions refinery/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Honeycomb refinery is setup and configured to refine events that are sent through it. You should see data flowing
within a few minutes at https://ui.honeycomb.io
Copy link
Contributor

Choose a reason for hiding this comment

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

not worth a lot of effort, but if possible: the API is configurable, so this note can be misleading

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is the UI link, not the API link.

Copy link
Contributor

Choose a reason for hiding this comment

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

right, so in my case I would be looking at https://ui-dogfood.honeycomb.io. But no one outside Honeycomb would go to another UI, so now that I think about it, it seems OK hard-coded.

101 changes: 101 additions & 0 deletions refinery/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "refinery.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 release name contains chart name it will be used as a full name.
*/}}
{{- define "refinery.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "refinery.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "refinery.labels" -}}
helm.sh/chart: {{ include "refinery.chart" . }}
{{ include "refinery.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "refinery.selectorLabels" -}}
app.kubernetes.io/name: {{ include "refinery.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}



{{/*
Create a default fully qualified app name for the redis component.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "refinery.redis.fullname" -}}
{{ include "refinery.fullname" . }}-redis
{{- end }}


{{/*
Common labels for redis
*/}}
{{- define "refinery.redis.labels" -}}
helm.sh/chart: {{ include "refinery.chart" . }}
{{ include "refinery.redis.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels for redis
*/}}
{{- define "refinery.redis.selectorLabels" -}}
app.kubernetes.io/name: {{ include "refinery.name" . }}-redis
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}








{{/*
Create the name of the service account to use
*/}}
{{- define "refinery.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "refinery.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
9 changes: 9 additions & 0 deletions refinery/templates/configmap-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "refinery.fullname" . }}-config
labels:
{{- include "refinery.labels" . | nindent 4 }}
data:
config.yaml: |
{{- toYaml .Values.config | nindent 4 }}
9 changes: 9 additions & 0 deletions refinery/templates/configmap-rules.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "refinery.fullname" . }}-rules
labels:
{{- include "refinery.labels" . | nindent 4 }}
data:
rules.yaml: |
{{- toYaml .Values.rules | nindent 4 }}
49 changes: 49 additions & 0 deletions refinery/templates/deployment-redis.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{{- if .Values.redis.enabled }}
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "refinery.redis.fullname" . }}
labels:
{{- include "refinery.redis.labels" . | nindent 4 }}
spec:
replicas: 1
selector:
matchLabels:
{{- include "refinery.redis.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "refinery.redis.selectorLabels" . | nindent 8 }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "refinery.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: redis
image: "{{ .Values.redis.image.repository }}:{{ .Values.redis.image.tag }}"
imagePullPolicy: {{ .Values.redis.image.pullPolicy }}
ports:
- name: http
containerPort: 6379
protocol: TCP
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end }}
Loading