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

This add make target to deploy a dev version using helm #586

Merged
merged 6 commits into from
May 24, 2019
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
17 changes: 17 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ push-latest:
done

helm:
-rm -f production/helm/*/requirements.lock
@set -e; \
helm init -c; \
for chart in $(CHARTS); do \
Expand Down Expand Up @@ -258,3 +259,19 @@ check_assets: assets
echo "Run 'make assets' and commit the changes to fix the error."; \
exit 1; \
fi

helm-install:
kubectl apply -f tools/helm.yaml
helm init --wait --service-account helm --upgrade
$(MAKE) upgrade-helm

helm-debug: ARGS=--dry-run --debug
helm-debug: helm-upgrade

helm-upgrade: helm
helm upgrade --wait --install $(ARGS) loki-stack ./production/helm/loki-stack \
--set promtail.image.tag=$(IMAGE_TAG) --set loki.image.tag=$(IMAGE_TAG) -f tools/dev.values.yaml


helm-clean:
-helm delete --purge loki-stack
3 changes: 3 additions & 0 deletions production/helm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,6 @@ For example, if you update the loki chart, you need to bump the version as follo
```bash
$ # update version loki/Chart.yaml
$ # update version loki-stack/Chart.yaml
```

You can use the `make helm-debug` to test and print out all chart templates. If you want to install helm (tiller) in your cluster use `make helm-install`, to install the current build in your Kubernetes cluster run `make helm-upgrade`.
2 changes: 1 addition & 1 deletion production/helm/loki-stack/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: loki-stack
version: 0.9.3
version: 0.9.4
appVersion: 0.0.1
kubeVersion: "^1.10.0-0"
description: "Loki: like Prometheus, but for logs."
Expand Down
9 changes: 8 additions & 1 deletion production/helm/loki-stack/requirements.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,11 @@ dependencies:
condition: promtail.enabled
repository: "file://../promtail"
version: "^0.6.0"

- name: "grafana"
condition: grafana.enabled
version: "~3.3.7"
repository: "https://kubernetes-charts.storage.googleapis.com/"
- name: "prometheus"
condition: prometheus.enabled
version: "~8.11.2"
repository: "https://kubernetes-charts.storage.googleapis.com/"
32 changes: 32 additions & 0 deletions production/helm/loki-stack/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "loki-stack.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-stack.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-stack.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}
30 changes: 30 additions & 0 deletions production/helm/loki-stack/templates/datasources.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{{- if and .Values.grafana.enabled .Values.grafana.sidecar.datasources.enabled }}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ template "loki-stack.fullname" . }}
labels:
app: {{ template "loki-stack.name" . }}
chart: {{ template "loki-stack.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
grafana_datasource: "1"
data:
loki-stack-datasource.yaml: |-
apiVersion: 1
datasources:
{{- if .Values.loki.enabled }}
- name: Loki
type: loki
access: proxy
url: http://{{(include "loki.serviceName" .)}}:{{ .Values.loki.service.port }}
version: 1
{{- end }}
{{- if .Values.prometheus.enabled }}
- name: Prometheus
type: prometheus
access: proxy
url: http://{{ .Values.prometheus.server.fullnameOverride }}:{{ .Values.prometheus.server.service.servicePort }}
version: 1
{{- end }}
{{- end }}
10 changes: 10 additions & 0 deletions production/helm/loki-stack/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,13 @@ loki:
promtail:
enabled: true

grafana:
enabled: false
sidecar:
datasources:
enabled: true

prometheus:
enabled: false
server:
fullnameOverride: prometheus-server
6 changes: 3 additions & 3 deletions production/helm/loki/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,9 @@ persistence:
podLabels: {}

## Pod Annotations
podAnnotations: {}
# prometheus.io/scrape: "true"
# prometheus.io/port: "http-metrics"
podAnnotations:
prometheus.io/scrape: "true"
prometheus.io/port: "http-metrics"

## Assign a PriorityClassName to pods if set
# priorityClassName:
Expand Down
6 changes: 3 additions & 3 deletions production/helm/promtail/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ pipelineStages:
## Pod Labels
podLabels: {}

podAnnotations: {}
# prometheus.io/scrape: "true"
# prometheus.io/port: "http-metrics"
podAnnotations:
prometheus.io/scrape: "true"
prometheus.io/port: "http-metrics"
cyriltovena marked this conversation as resolved.
Show resolved Hide resolved

# This should match config.server.http_listen_port
port: 3101
Expand Down
25 changes: 25 additions & 0 deletions tools/dev.values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
grafana:
enabled: true
service:
type: LoadBalancer
port: 3000
adminPassword: admin

prometheus:
enabled: true
pushgateway:
enabled: false
server:
service:
type: LoadBalancer
servicePort: 9090

promtail:
image:
pullPolicy: Never

loki:
image:
pullPolicy: Never
service:
type: LoadBalancer
37 changes: 37 additions & 0 deletions tools/helm.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: helm
namespace: kube-system
---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRoleBinding
metadata:
name: helm
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: cluster-admin
subjects:
- kind: ServiceAccount
name: helm
namespace: kube-system
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
creationTimestamp: null
name: cluster-admin
annotations:
rbac.authorization.kubernetes.io/autoupdate: "true"
rules:
- apiGroups:
- '*'
resources:
- '*'
verbs:
- '*'
- nonResourceURLs:
- '*'
verbs:
- '*'