Skip to content

Commit

Permalink
Add helm chart (#107)
Browse files Browse the repository at this point in the history
* Add loki helm chart

Signed-off-by: Julien Garcia Gonzalez <julien@giantswarm.io>

* Add promtail helm chart

Signed-off-by: Julien Garcia Gonzalez <julien@giantswarm.io>

* Update loki conf from comment

Signed-off-by: Julien Garcia Gonzalez <julien@giantswarm.io>

* Update promtail conf from comment

Signed-off-by: Julien Garcia Gonzalez <julien@giantswarm.io>

* Update values from comment

Signed-off-by: Julien Garcia Gonzalez <julien@giantswarm.io>

* adding resources limit and request

Signed-off-by: Julien Garcia Gonzalez <julien@giantswarm.io>

* update README

Signed-off-by: Julien Garcia Gonzalez <julien@giantswarm.io>

* rename to daemonset promtail

Signed-off-by: Julien Garcia Gonzalez <julien@giantswarm.io>

* use masger for loki

Signed-off-by: Julien Garcia Gonzalez <julien@giantswarm.io>

* Move into production repo, re-add readme.

Signed-off-by: Tom Wilkie <tom.wilkie@gmail.com>

* Move to production folder

Signed-off-by: Julien Garcia Gonzalez <julien@giantswarm.io>

* Review feedback; add instructions for installing Grafana with helm.

Signed-off-by: Tom Wilkie <tom.wilkie@gmail.com>
  • Loading branch information
Julien Garcia Gonzalez authored and tomwilkie committed Dec 17, 2018
1 parent db114b6 commit ea712f3
Show file tree
Hide file tree
Showing 22 changed files with 803 additions and 1 deletion.
3 changes: 2 additions & 1 deletion production/README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# Running Loki

Currently there are four ways to try out Loki, in order from easier to hardest:
Currently there are five ways to try out Loki, in order from easier to hardest:

- [Using our free hosted demo](#free-hosted-demo)
- [Running it locally with Docker](#run-locally-using-docker)
- [Using Helm to deploy on Kubernetes](helm/)
- [Building from source](#build-and-run-from-source)
- [Using our Ksonnet config to run a fully-blown production setup](ksonnet/)

Expand Down
13 changes: 13 additions & 0 deletions production/helm/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: loki
version: 0.0.1
appVersion: 0.0.1
kubeVersion: "^1.10.0-0"
description: "Loki: like Prometheus, but for logs."
home: https://grafana.com/loki
icon: https://github.com/grafana/loki/raw/master/docs/logo.png
sources:
- https://github.com/grafana/loki
maintainers:
- name: Loki Maintainers
email: lokiproject@googlegroups.com
engine: gotpl
45 changes: 45 additions & 0 deletions production/helm/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Deploy Loki to Kubernetes with Helm

## Prerequisites

Make sure you have the helm configure on your cluster:

```bash
$ helm init
```

Clone `grafana/loki` repository and navigate to `production helm` directory:

```bash
$ git clone https://github.com/grafana/loki.git
$ cd loki/production/helm
```

## Deploy Loki and Promtail to your cluster

```bash
$ helm install . -n loki --namespace <YOUR-NAMESPACE>
```

## Deploy Grafana to your cluster

To install Grafana on your cluster with helm, use the following command:

```bash
$ helm install stable/grafana -n loki-grafana -f grafana.yaml --namespace <YOUR-NAMESPACE>
```

To get the admin password for the Grafana pod, run the following command:

```bash
$ kubectl get secret --namespace <YOUR-NAMESPACE> loki-grafana -o jsonpath="{.data.admin-password}" | base64 --decode ; echo
```

To access the Grafana UI, run the following command:

```bash
$ kubectl port-forward --namespace <YOUR-NAMESPACE> service/loki-grafana 3000:80
```

Navigate to http://localhost:3000 and login with `admin` and the password output above.
Then follow the [instructions for adding the loki datasource](/docs/usage.md), using the URL `http://loki:3100/`.
5 changes: 5 additions & 0 deletions production/helm/grafana.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
image:
tag: master

env:
GF_EXPLORE_ENABLED: true
43 changes: 43 additions & 0 deletions production/helm/templates/loki/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "loki.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 "loki.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 "loki.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Create the name of the service account
*/}}
{{- define "loki.serviceAccountName" -}}
{{- if .Values.serviceAccount.create -}}
{{ default (include "loki.fullname" .) .Values.serviceAccount.name }}
{{- else -}}
{{ default "default" .Values.serviceAccount.name }}
{{- end -}}
{{- end -}}
43 changes: 43 additions & 0 deletions production/helm/templates/loki/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ template "loki.fullname" . }}
labels:
app: {{ template "loki.name" . }}
chart: {{ template "loki.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
data:
loki.yaml: |
auth_enabled: {{ .Values.loki.config.auth_enabled }}
server:
http_listen_port: {{ .Values.loki.service.port }}
ingester:
lifecycler:
ring:
store: {{ .Values.loki.config.ingester.lifecycler.ring.store }}
replication_factor: {{ .Values.loki.config.ingester.lifecycler.ring.replication_factor }}
{{- if .Values.loki.config.schema_configs }}
schema_config:
configs:
{{- range .Values.loki.config.schema_configs }}
- from: {{ .from }}
store: {{ .store }}
object_store: {{ .object_store }}
schema: {{ .schema }}
index:
prefix: {{ .index.prefix }}
period: {{ .index.period }}
{{- end -}}
{{- end -}}

{{- if .Values.loki.config.storage_configs }}
storage_config:
{{- range .Values.loki.config.storage_configs }}
{{ .name }}:
directory: {{ .directory }}
{{- end -}}
{{- end -}}
79 changes: 79 additions & 0 deletions production/helm/templates/loki/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
apiVersion: apps/v1beta2
kind: Deployment
metadata:
name: {{ template "loki.fullname" . }}
labels:
app: {{ template "loki.name" . }}
chart: {{ template "loki.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
{{- with .Values.loki.annotations }}
annotations:
{{ toYaml . | indent 4 }}
{{- end }}
spec:
replicas: {{ .Values.loki.replicas }}
selector:
matchLabels:
app: {{ template "loki.name" . }}
release: {{ .Release.Name }}
strategy:
type: {{ .Values.loki.deploymentStrategy }}
{{- if ne .Values.loki.deploymentStrategy "RollingUpdate" }}
rollingUpdate: null
{{- end }}
template:
metadata:
labels:
app: {{ template "loki.name" . }}
release: {{ .Release.Name }}
{{- with .Values.loki.podAnnotations }}
annotations:
{{ toYaml . | indent 8 }}
{{- end }}
spec:
serviceAccountName: {{ template "loki.serviceAccountName" . }}
{{- if .Values.loki.priorityClassName }}
priorityClassName: {{ .Values.loki.priorityClassName }}
{{- end }}
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.loki.image.repository }}:{{ .Values.loki.image.tag }}"
imagePullPolicy: {{ .Values.loki.image.pullPolicy }}
args:
- "-config.file=/etc/loki/loki.yaml"
volumeMounts:
- name: config
mountPath: /etc/loki
ports:
- name: {{ template "loki.name" . }}
containerPort: {{ .Values.loki.service.port }}
protocol: TCP
{{- with .Values.loki.livenessProbe }}
livenessProbe:
{{ toYaml . | indent 12 }}
{{- end }}
{{- with .Values.loki.readinessProbe }}
readinessProbe:
{{ toYaml . | indent 12 }}
{{- end }}
{{- with .Values.loki.resources }}
resources:
{{ toYaml . | indent 12 }}
{{- end }}
{{- with .Values.loki.nodeSelector }}
nodeSelector:
{{ toYaml . | indent 8 }}
{{- end }}
{{- with .Values.loki.affinity }}
affinity:
{{ toYaml . | indent 8 }}
{{- end }}
{{- with .Values.loki.tolerations }}
tolerations:
{{ toYaml . | indent 8 }}
{{- end }}
volumes:
- name: config
configMap:
name: {{ template "loki.fullname" . }}
28 changes: 28 additions & 0 deletions production/helm/templates/loki/podsecuritypolicy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{{- if .Values.rbac.pspEnabled }}
apiVersion: extensions/v1beta1
kind: PodSecurityPolicy
metadata:
name: {{ template "loki.fullname" . }}
labels:
app: {{ template "loki.name" . }}
chart: {{ .Chart.Name }}-{{ .Chart.Version }}
heritage: {{ .Release.Service }}
release: {{ .Release.Name }}
spec:
privileged: false
allowPrivilegeEscalation: false
volumes:
- 'configMap'
hostNetwork: false
hostIPC: false
hostPID: false
runAsUser:
rule: 'RunAsAny'
seLinux:
rule: 'RunAsAny'
supplementalGroups:
rule: 'RunAsAny'
fsGroup:
rule: 'RunAsAny'
readOnlyRootFilesystem: false
{{- end }}
18 changes: 18 additions & 0 deletions production/helm/templates/loki/role.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{{- if .Values.rbac.create }}
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: Role
metadata:
name: {{ template "loki.fullname" . }}
labels:
app: {{ template "loki.name" . }}
chart: {{ .Chart.Name }}-{{ .Chart.Version }}
heritage: {{ .Release.Service }}
release: {{ .Release.Name }}
{{- if .Values.rbac.pspEnabled }}
rules:
- apiGroups: ['extensions']
resources: ['podsecuritypolicies']
verbs: ['use']
resourceNames: [{{ template "loki.fullname" . }}]
{{- end }}
{{- end }}
18 changes: 18 additions & 0 deletions production/helm/templates/loki/rolebinding.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{{- if .Values.rbac.create -}}
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: RoleBinding
metadata:
name: {{ template "loki.fullname" . }}
labels:
app: {{ template "loki.name" . }}
chart: {{ .Chart.Name }}-{{ .Chart.Version }}
heritage: {{ .Release.Service }}
release: {{ .Release.Name }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: {{ template "loki.fullname" . }}
subjects:
- kind: ServiceAccount
name: {{ template "loki.serviceAccountName" . }}
{{- end -}}
25 changes: 25 additions & 0 deletions production/helm/templates/loki/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
apiVersion: v1
kind: Service
metadata:
name: {{ template "loki.fullname" . }}
labels:
app: {{ template "loki.name" . }}
chart: {{ template "loki.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
{{- if .Values.loki.service.labels }}
{{ toYaml .Values.loki.service.labels | indent 4 }}
{{- end }}
{{- with .Values.loki.service.annotations }}
annotations:
{{ toYaml . | indent 4 }}
{{- end }}
spec:
ports:
- name: {{ template "loki.name" . }}
port: {{ .Values.loki.service.port }}
protocol: TCP
targetPort: {{ .Values.loki.service.port }}
selector:
app: {{ template "loki.name" . }}
release: {{ .Release.Name }}
11 changes: 11 additions & 0 deletions production/helm/templates/loki/serviceaccount.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{{- if .Values.serviceAccount.create }}
apiVersion: v1
kind: ServiceAccount
metadata:
labels:
app: {{ template "loki.name" . }}
chart: {{ .Chart.Name }}-{{ .Chart.Version }}
heritage: {{ .Release.Service }}
release: {{ .Release.Name }}
name: {{ template "loki.serviceAccountName" . }}
{{- end }}
Loading

0 comments on commit ea712f3

Please sign in to comment.