Skip to content

Commit

Permalink
Merge pull request #679 from daryamorgan/tempo-distributed-gateway
Browse files Browse the repository at this point in the history
[tempo-distributed] Add gateway component to tempo-distributed
  • Loading branch information
annanay25 committed Sep 28, 2021
2 parents 1b00908 + 21f7aa2 commit 8673445
Show file tree
Hide file tree
Showing 16 changed files with 540 additions and 7 deletions.
2 changes: 1 addition & 1 deletion charts/tempo-distributed/Chart.yaml
Expand Up @@ -2,7 +2,7 @@ apiVersion: v2
name: tempo-distributed
description: Grafana Tempo in MicroService mode
type: application
version: 0.9.14
version: 0.9.15
appVersion: 1.1.0
engine: gotpl
home: https://grafana.com/docs/tempo/latest/
Expand Down
50 changes: 48 additions & 2 deletions charts/tempo-distributed/README.md
@@ -1,6 +1,6 @@
# tempo-distributed

![Version: 0.9.14](https://img.shields.io/badge/Version-0.9.14-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 1.1.0](https://img.shields.io/badge/AppVersion-1.1.0-informational?style=flat-square)
![Version: 0.9.15](https://img.shields.io/badge/Version-0.9.15-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 1.1.0](https://img.shields.io/badge/AppVersion-1.1.0-informational?style=flat-square)

Grafana Tempo in MicroService mode

Expand Down Expand Up @@ -102,6 +102,51 @@ The memcached default args are removed and should be provided manually. The sett
| distributor.service.type | string | `"ClusterIP"` | Type of service for the distributor |
| distributor.terminationGracePeriodSeconds | int | `30` | Grace period to allow the distributor to shutdown before it is killed |
| distributor.tolerations | list | `[]` | Tolerations for distributor pods |
| gateway.affinity | string | Hard node and soft zone anti-affinity | Affinity for gateway pods. Passed through `tpl` and, thus, to be configured as string |
| gateway.basicAuth.enabled | bool | `false` | Enables basic authentication for the gateway |
| gateway.basicAuth.existingSecret | string | `nil` | Existing basic auth secret to use. Must contain '.htpasswd' |
| gateway.basicAuth.htpasswd | string | `"{{ htpasswd (required \"'gateway.basicAuth.username' is required\" .Values.gateway.basicAuth.username) (required \"'gateway.basicAuth.password' is required\" .Values.gateway.basicAuth.password) }}"` | Uses the specified username and password to compute a htpasswd using Sprig's `htpasswd` function. The value is templated using `tpl`. Override this to use a custom htpasswd, e.g. in case the default causes high CPU load. |
| gateway.basicAuth.password | string | `nil` | The basic auth password for the gateway |
| gateway.basicAuth.username | string | `nil` | The basic auth username for the gateway |
| gateway.enabled | bool | `false` | Specifies whether the gateway should be enabled |
| gateway.extraArgs | list | `[]` | Additional CLI args for the gateway |
| gateway.extraEnv | list | `[]` | Environment variables to add to the gateway pods |
| gateway.extraEnvFrom | list | `[]` | Environment variables from secrets or configmaps to add to the gateway pods |
| gateway.extraVolumeMounts | list | `[]` | Volume mounts to add to the gateway pods |
| gateway.extraVolumes | list | `[]` | Volumes to add to the gateway pods |
| gateway.image.pullPolicy | string | `"IfNotPresent"` | The gateway image pull policy |
| gateway.image.registry | string | `"docker.io"` | The Docker registry for the gateway image |
| gateway.image.repository | string | `"nginxinc/nginx-unprivileged"` | The gateway image repository |
| gateway.image.tag | string | `"1.19-alpine"` | The gateway image tag |
| gateway.ingress.annotations | object | `{}` | Ingress Class Name. MAY be required for Kubernetes versions >= 1.18 ingressClassName: nginx -- Annotations for the gateway ingress |
| gateway.ingress.enabled | bool | `false` | Specifies whether an ingress for the gateway should be created |
| gateway.ingress.hosts | list | `[{"host":"gateway.tempo.example.com","paths":[{"path":"/"}]}]` | Hosts configuration for the gateway ingress |
| gateway.ingress.tls | list | `[{"hosts":["gateway.tempo.example.com"],"secretName":"tempo-gateway-tls"}]` | TLS configuration for the gateway ingress |
| gateway.nginxConfig.file | string | See values.yaml | Config file contents for Nginx. Passed through the `tpl` function to allow templating |
| gateway.nginxConfig.httpSnippet | string | `""` | Allows appending custom configuration to the http block |
| gateway.nginxConfig.logFormat | string | `"main '$remote_addr - $remote_user [$time_local] $status '\n '\"$request\" $body_bytes_sent \"$http_referer\" '\n '\"$http_user_agent\" \"$http_x_forwarded_for\"';"` | NGINX log format |
| gateway.nginxConfig.serverSnippet | string | `""` | Allows appending custom configuration to the server block |
| gateway.nodeSelector | object | `{}` | Node selector for gateway pods |
| gateway.podAnnotations | object | `{}` | Annotations for gateway pods |
| gateway.priorityClassName | string | `nil` | The name of the PriorityClass for gateway pods |
| gateway.readinessProbe.httpGet.path | string | `"/"` | |
| gateway.readinessProbe.httpGet.port | string | `"http"` | |
| gateway.readinessProbe.initialDelaySeconds | int | `15` | |
| gateway.readinessProbe.timeoutSeconds | int | `1` | |
| gateway.replicas | int | `1` | Number of replicas for the gateway |
| gateway.resources | object | `{}` | Resource requests and limits for the gateway |
| gateway.service.annotations | object | `{}` | Annotations for the gateway service |
| gateway.service.clusterIP | string | `nil` | ClusterIP of the gateway service |
| gateway.service.labels | object | `{}` | Labels for gateway service |
| gateway.service.loadBalancerIP | string | `nil` | Load balancer IPO address if service type is LoadBalancer |
| gateway.service.nodePort | string | `nil` | Node port if service type is NodePort |
| gateway.service.port | int | `80` | Port of the gateway service |
| gateway.service.type | string | `"ClusterIP"` | Type of the gateway service |
| gateway.terminationGracePeriodSeconds | int | `30` | Grace period to allow the gateway to shutdown before it is killed |
| gateway.tolerations | list | `[]` | Tolerations for gateway pods |
| global.clusterDomain | string | `"cluster.local"` | configures cluster domain ("cluster.local" by default) |
| global.dnsNamespace | string | `"kube-system"` | configures DNS service namespace |
| global.dnsService | string | `"kube-dns"` | configures DNS service name |
| global.image.registry | string | `nil` | Overrides the Docker registry globally for all images |
| global.priorityClassName | string | `nil` | Overrides the priorityClassName for all pods |
| ingester.affinity | string | Hard node and soft zone anti-affinity | Affinity for ingester pods. Passed through `tpl` and, thus, to be configured as string |
Expand Down Expand Up @@ -200,7 +245,7 @@ The memcached default args are removed and should be provided manually. The sett
| serviceMonitor.scrapeTimeout | string | `nil` | ServiceMonitor scrape timeout in Go duration format (e.g. 15s) |
| serviceMonitor.tlsConfig | string | `nil` | ServiceMonitor will use these tlsConfig settings to make the health check requests |
| storage.trace.backend | string | `"local"` | |
| tempo | object | `{"image":{"pullPolicy":"IfNotPresent","registry":"docker.io","repository":"grafana/tempo","tag":null},"readinessProbe":{"httpGet":{"path":"/ready","port":"http"},"initialDelaySeconds":30,"timeoutSeconds":1}}` | Overrides the chart's computed fullname fullnameOverride: tempo -- Overrides the chart's computed fullname |
| tempo | object | `{"image":{"pullPolicy":"IfNotPresent","registry":"docker.io","repository":"grafana/tempo","tag":null},"readinessProbe":{"httpGet":{"path":"/ready","port":"http"},"initialDelaySeconds":30,"timeoutSeconds":1}}` | Overrides the chart's computed fullname fullnameOverride: tempo |
| tempo.image.registry | string | `"docker.io"` | The Docker registry |
| tempo.image.repository | string | `"grafana/tempo"` | Docker image repository |
| tempo.image.tag | string | `nil` | Overrides the image tag whose default is the chart's appVersion |
Expand All @@ -227,6 +272,7 @@ The other components are optional and must be explicitly enabled.
| query-frontend | no |
| compactor | no |
| memcached | yes |
| gateway | yes |

## (Configuration)[https://grafana.com/docs/tempo/latest/configuration/]

Expand Down
1 change: 1 addition & 0 deletions charts/tempo-distributed/README.md.gotmpl
Expand Up @@ -79,6 +79,7 @@ The other components are optional and must be explicitly enabled.
| query-frontend | no |
| compactor | no |
| memcached | yes |
| gateway | yes |


## (Configuration)[https://grafana.com/docs/tempo/latest/configuration/]
Expand Down
3 changes: 3 additions & 0 deletions charts/tempo-distributed/templates/NOTES.txt
Expand Up @@ -15,3 +15,6 @@ Installed components:
{{- if .Values.memcached.enabled }}
* memcached
{{- end }}
{{- if .Values.gateway.enabled }}
* gateway
{{- end }}
34 changes: 34 additions & 0 deletions charts/tempo-distributed/templates/_helpers.tpl
Expand Up @@ -86,3 +86,37 @@ Gossip ring Selector labels
{{- define "tempo.gossipRing.selectorLabels" -}}
tempo-gossip-member: "true"
{{- end -}}

{{/*
Return the appropriate apiVersion for ingress.
*/}}
{{- define "tempo.ingress.apiVersion" -}}
{{- if and (.Capabilities.APIVersions.Has "networking.k8s.io/v1") (semverCompare ">= 1.19-0" .Capabilities.KubeVersion.Version) -}}
{{- print "networking.k8s.io/v1" -}}
{{- else if .Capabilities.APIVersions.Has "networking.k8s.io/v1beta1" -}}
{{- print "networking.k8s.io/v1beta1" -}}
{{- else -}}
{{- print "extensions/v1beta1" -}}
{{- end -}}
{{- end -}}

{{/*
Return if ingress is stable.
*/}}
{{- define "tempo.ingress.isStable" -}}
{{- eq (include "tempo.ingress.apiVersion" .) "networking.k8s.io/v1" -}}
{{- end -}}

{{/*
Return if ingress supports ingressClassName.
*/}}
{{- define "tempo.ingress.supportsIngressClassName" -}}
{{- or (eq (include "tempo.ingress.isStable" .) "true") (and (eq (include "tempo.ingress.apiVersion" .) "networking.k8s.io/v1beta1") (semverCompare ">= 1.18-0" .Capabilities.KubeVersion.Version)) -}}
{{- end -}}

{{/*
Return if ingress supports pathType.
*/}}
{{- define "tempo.ingress.supportsPathType" -}}
{{- or (eq (include "tempo.ingress.isStable" .) "true") (and (eq (include "tempo.ingress.apiVersion" .) "networking.k8s.io/v1beta1") (semverCompare ">= 1.18-0" .Capabilities.KubeVersion.Version)) -}}
{{- end -}}
@@ -1,3 +1,10 @@
{{/*
distributor fullname
*/}}
{{- define "tempo.distributorFullname" -}}
{{ include "tempo.fullname" . }}-distributor
{{- end }}

{{/*
distributor common labels
*/}}
Expand Down
@@ -1,7 +1,7 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ template "tempo.fullname" . }}-distributor
name: {{ include "tempo.distributorFullname" . }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "tempo.distributorLabels" . | nindent 4 }}
Expand Down
@@ -1,7 +1,7 @@
apiVersion: v1
kind: Service
metadata:
name: {{ template "tempo.fullname" . }}-distributor
name: {{ include "tempo.distributorFullname" . }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "tempo.distributorLabels" . | nindent 4 }}
Expand Down
Expand Up @@ -3,7 +3,7 @@
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: {{ template "tempo.fullname" $ }}-distributor
name: {{ include "tempo.distributorFullname" $ }}
{{- with .namespace }}
namespace: {{ . }}
{{- end }}
Expand Down
30 changes: 30 additions & 0 deletions charts/tempo-distributed/templates/gateway/_helpers-gateway.tpl
@@ -0,0 +1,30 @@
{{/*
gateway fullname
*/}}
{{- define "tempo.gatewayFullname" -}}
{{ include "tempo.fullname" . }}-gateway
{{- end }}

{{/*
gateway common labels
*/}}
{{- define "tempo.gatewayLabels" -}}
{{ include "tempo.labels" . }}
app.kubernetes.io/component: gateway
{{- end }}

{{/*
gateway selector labels
*/}}
{{- define "tempo.gatewaySelectorLabels" -}}
{{ include "tempo.selectorLabels" . }}
app.kubernetes.io/component: gateway
{{- end }}

{{/*
gateway image
*/}}
{{- define "tempo.gatewayImage" -}}
{{- $dict := dict "tempo" .Values.tempo.image "service" .Values.gateway.image "global" .Values.global.image "defaultVersion" .Chart.AppVersion -}}
{{- include "tempo.tempoImage" $dict -}}
{{- end }}
11 changes: 11 additions & 0 deletions charts/tempo-distributed/templates/gateway/configmap-gateway.yaml
@@ -0,0 +1,11 @@
{{- if .Values.gateway.enabled }}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "tempo.gatewayFullname" . }}
labels:
{{- include "tempo.gatewayLabels" . | nindent 4 }}
data:
nginx.conf: |
{{- tpl .Values.gateway.nginxConfig.file . | nindent 4 }}
{{- end }}
89 changes: 89 additions & 0 deletions charts/tempo-distributed/templates/gateway/deployment-gateway.yaml
@@ -0,0 +1,89 @@
{{- if .Values.gateway.enabled }}
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "tempo.gatewayFullname" . }}
labels:
{{- include "tempo.gatewayLabels" . | nindent 4 }}
spec:
minReadySeconds: 10
replicas: {{ .Values.gateway.replicas }}
revisionHistoryLimit: 10
selector:
matchLabels:
{{- include "tempo.gatewaySelectorLabels" . | nindent 6 }}
template:
metadata:
annotations:
checksum/config: {{ include (print .Template.BasePath "/gateway/configmap-gateway.yaml") . | sha256sum }}
{{- with .Values.gateway.podAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "tempo.gatewaySelectorLabels" . | nindent 8 }}
spec:
serviceAccountName: {{ include "tempo.serviceAccountName" . }}
terminationGracePeriodSeconds: {{ .Values.gateway.terminationGracePeriodSeconds }}
containers:
- name: nginx
image: {{ include "tempo.gatewayImage" . }}
imagePullPolicy: {{ .Values.gateway.image.pullPolicy }}
ports:
- name: http
containerPort: 8080
protocol: TCP
{{- with .Values.gateway.extraEnv }}
env:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.gateway.extraEnvFrom }}
envFrom:
{{- toYaml . | nindent 12 }}
{{- end }}
readinessProbe:
{{- toYaml .Values.gateway.readinessProbe | nindent 12 }}
volumeMounts:
- name: config
mountPath: /etc/nginx
{{- if .Values.gateway.basicAuth.enabled }}
- name: auth
mountPath: /etc/nginx/secrets
{{- end }}
- name: tmp
mountPath: /tmp
- name: docker-entrypoint-d-override
mountPath: /docker-entrypoint.d
{{- if .Values.gateway.extraVolumeMounts }}
{{- toYaml .Values.gateway.extraVolumeMounts | nindent 12 }}
{{- end }}
resources:
{{- toYaml .Values.gateway.resources | nindent 12 }}
{{- with .Values.gateway.affinity }}
affinity:
{{- tpl . $ | nindent 8 }}
{{- end }}
{{- with .Values.gateway.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.gateway.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
volumes:
- name: config
configMap:
name: {{ include "tempo.gatewayFullname" . }}
{{- if .Values.gateway.basicAuth.enabled }}
- name: auth
secret:
secretName: {{ include "tempo.gatewayAuthSecret" . }}
{{- end }}
- name: tmp
emptyDir: {}
- name: docker-entrypoint-d-override
emptyDir: {}
{{- if .Values.gateway.extraVolumes }}
{{- toYaml .Values.gateway.extraVolumes | nindent 8 }}
{{- end }}
{{- end }}
55 changes: 55 additions & 0 deletions charts/tempo-distributed/templates/gateway/ingress-gateway.yaml
@@ -0,0 +1,55 @@
{{- if .Values.gateway.enabled -}}
{{- if .Values.gateway.ingress.enabled -}}
{{- $ingressApiIsStable := eq (include "tempo.ingress.isStable" .) "true" -}}
{{- $ingressSupportsIngressClassName := eq (include "tempo.ingress.supportsIngressClassName" .) "true" -}}
{{- $ingressSupportsPathType := eq (include "tempo.ingress.supportsPathType" .) "true" -}}
apiVersion: {{ include "tempo.ingress.apiVersion" . }}
kind: Ingress
metadata:
name: {{ include "tempo.gatewayFullname" . }}
labels:
{{- include "tempo.gatewayLabels" . | nindent 4 }}
{{- with .Values.gateway.ingress.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- if and $ingressSupportsIngressClassName .Values.gateway.ingress.ingressClassName }}
ingressClassName: {{ .Values.gateway.ingress.ingressClassName }}
{{- end -}}
{{- if .Values.gateway.ingress.tls }}
tls:
{{- range .Values.gateway.ingress.tls }}
- hosts:
{{- range .hosts }}
- {{ . | quote }}
{{- end }}
{{- with .secretName }}
secretName: {{ . }}
{{- end }}
{{- end }}
{{- end }}
rules:
{{- range .Values.gateway.ingress.hosts }}
- host: {{ .host | quote }}
http:
paths:
{{- range .paths }}
- path: {{ .path }}
{{- if $ingressSupportsPathType }}
pathType: {{ .pathType }}
{{- end }}
backend:
{{- if $ingressApiIsStable }}
service:
name: {{ include "tempo.gatewayFullname" $ }}
port:
number: {{ $.Values.gateway.service.port }}
{{- else }}
serviceName: {{ include "tempo.gatewayFullname" $ }}
servicePort: {{ $.Values.gateway.service.port }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
13 changes: 13 additions & 0 deletions charts/tempo-distributed/templates/gateway/secret-gateway.yaml
@@ -0,0 +1,13 @@
{{- with .Values.gateway }}
{{- if and .enabled .basicAuth.enabled (not .basicAuth.existingSecret) }}
apiVersion: v1
kind: Secret
metadata:
name: {{ include "tempo.gatewayFullname" $ }}
labels:
{{- include "tempo.gatewayLabels" $ | nindent 4 }}
stringData:
.htpasswd: |
{{- tpl .basicAuth.htpasswd $ | nindent 4 }}
{{- end }}
{{- end }}

0 comments on commit 8673445

Please sign in to comment.