-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build memcached into the chart, enabled by default, this commit inclu…
…des a results cache and chunks cache Signed-off-by: Edward Welch <[email protected]>
- Loading branch information
Showing
9 changed files
with
459 additions
and
22 deletions.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
production/helm/loki/templates/chunks-cache/poddisruptionbudget-chunks-cache.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{{- if .Values.chunksCache.enabled }} | ||
apiVersion: {{ include "loki.pdb.apiVersion" . }} | ||
kind: PodDisruptionBudget | ||
metadata: | ||
name: {{ include "loki.fullname" . }}-memcached-chunks-cache | ||
namespace: {{ .Release.Namespace }} | ||
labels: | ||
{{- include "loki.selectorLabels" . | nindent 4 }} | ||
app.kubernetes.io/component: memcached-chunks-cache | ||
spec: | ||
selector: | ||
matchLabels: | ||
{{- include "loki.selectorLabels" . | nindent 6 }} | ||
app.kubernetes.io/component: memcached-chunks-cache | ||
maxUnavailable: 1 | ||
{{- end -}} |
1 change: 1 addition & 0 deletions
1
production/helm/loki/templates/chunks-cache/service-chunks-cache-headless.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{{- include "loki.memcached.service" (dict "ctx" $ "valuesSection" "chunksCache" "component" "chunks-cache" ) }} |
1 change: 1 addition & 0 deletions
1
production/helm/loki/templates/chunks-cache/statefulset-chunks-cache.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{{- include "loki.memcached.statefulSet" (dict "ctx" $ "valuesSection" "chunksCache" "component" "chunks-cache" ) }} |
159 changes: 159 additions & 0 deletions
159
production/helm/loki/templates/memcached/_memcached-statefulset.tpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,159 @@ | ||
{{/* | ||
memcached StatefulSet | ||
Params: | ||
ctx = . context | ||
valuesSection = name of the section in values.yaml | ||
component = name of the component | ||
valuesSection and component are specified separately because helm prefers camelcase for naming convetion and k8s components are named with snake case. | ||
*/}} | ||
{{- define "loki.memcached.statefulSet" -}} | ||
{{ with (index $.ctx.Values $.valuesSection) }} | ||
{{- if .enabled -}} | ||
apiVersion: apps/v1 | ||
kind: StatefulSet | ||
metadata: | ||
name: {{ include "loki.resourceName" (dict "ctx" $.ctx "component" $.component) }} | ||
labels: | ||
{{- include "loki.labels" $.ctx | nindent 4 }} | ||
app.kubernetes.io/component: "memcached-{{ $.component }}" | ||
name: "memcached-{{ $.component }}" | ||
annotations: | ||
{{- toYaml .annotations | nindent 4 }} | ||
namespace: {{ $.ctx.Release.Namespace | quote }} | ||
spec: | ||
podManagementPolicy: {{ .podManagementPolicy }} | ||
replicas: {{ .replicas }} | ||
selector: | ||
matchLabels: | ||
{{- include "loki.selectorLabels" $.ctx | nindent 6 }} | ||
app.kubernetes.io/component: "memcached-{{ $.component }}" | ||
name: "memcached-{{ $.component }}" | ||
updateStrategy: | ||
{{- toYaml .statefulStrategy | nindent 4 }} | ||
serviceName: {{ template "loki.fullname" $.ctx }}-{{ $.component }} | ||
|
||
template: | ||
metadata: | ||
labels: | ||
{{- include "loki.selectorLabels" $.ctx | nindent 8 }} | ||
app.kubernetes.io/component: "memcached-{{ $.component }}" | ||
name: "memcached-{{ $.component }}" | ||
{{- with $.ctx.Values.loki.podLabels }} | ||
{{- toYaml . | nindent 8 }} | ||
{{- end }} | ||
{{- with .podLabels }} | ||
{{- toYaml . | nindent 8 }} | ||
{{- end }} | ||
annotations: | ||
{{- with $.ctx.Values.global.podAnnotations }} | ||
{{- toYaml . | nindent 8 }} | ||
{{- end }} | ||
{{- with .podAnnotations }} | ||
{{- toYaml . | nindent 8 }} | ||
{{- end }} | ||
|
||
spec: | ||
serviceAccountName: {{ template "loki.serviceAccountName" $.ctx }} | ||
{{- if .priorityClassName }} | ||
priorityClassName: {{ .priorityClassName }} | ||
{{- end }} | ||
securityContext: | ||
{{- toYaml $.ctx.Values.memcached.podSecurityContext | nindent 8 }} | ||
initContainers: | ||
{{- toYaml .initContainers | nindent 8 }} | ||
nodeSelector: | ||
{{- toYaml .nodeSelector | nindent 8 }} | ||
affinity: | ||
{{- toYaml .affinity | nindent 8 }} | ||
toplogySpreadConstraints: | ||
{{- toYaml .topologySpreadConstraints | nindent 8 }} | ||
tolerations: | ||
{{- toYaml .tolerations | nindent 8 }} | ||
terminationGracePeriodSeconds: {{ .terminationGracePeriodSeconds }} | ||
{{- if $.ctx.Values.imagePullSecrets }} | ||
imagePullSecrets: | ||
{{- range $.ctx.Values.image.pullSecrets }} | ||
- name: {{ . }} | ||
{{- end }} | ||
{{- end }} | ||
{{- if .extraVolumes }} | ||
volumes: | ||
{{- toYaml .extraVolumes | nindent 8 }} | ||
{{- end }} | ||
containers: | ||
{{- if .extraContainers }} | ||
{{ toYaml .extraContainers | nindent 8 }} | ||
{{- end }} | ||
- name: memcached | ||
{{- with $.ctx.Values.memcached.image }} | ||
image: {{ .repository }}:{{ .tag }} | ||
imagePullPolicy: {{ .pullPolicy }} | ||
{{- end }} | ||
resources: | ||
{{- if .resources }} | ||
{{- toYaml .resources | nindent 12 }} | ||
{{- else }} | ||
{{- /* Calculate requested memory as round(allocatedMemory * 1.2). But with integer built-in operators. */}} | ||
{{- $requestMemory := div (add (mul .allocatedMemory 12) 5) 10 }} | ||
limits: | ||
memory: {{ $requestMemory }}Mi | ||
requests: | ||
cpu: 500m | ||
memory: {{ $requestMemory }}Mi | ||
{{- end }} | ||
ports: | ||
- containerPort: {{ .port }} | ||
name: client | ||
args: | ||
- -m {{ .allocatedMemory }} | ||
- --extended=modern,track_sizes{{ with .extraExtendedOptions }},{{ . }}{{ end }} | ||
- -I {{ .maxItemMemory }}m | ||
- -c {{ .connectionLimit }} | ||
- -v | ||
- -u {{ .port }} | ||
{{- range $key, $value := .extraArgs }} | ||
- "-{{ $key }}{{ if $value }} {{ $value }}{{ end }}" | ||
{{- end }} | ||
env: | ||
{{- with $.ctx.Values.global.extraEnv }} | ||
{{ toYaml . | nindent 12 }} | ||
{{- end }} | ||
envFrom: | ||
{{- with $.ctx.Values.global.extraEnvFrom }} | ||
{{- toYaml . | nindent 12 }} | ||
{{- end }} | ||
securityContext: | ||
{{- toYaml $.ctx.Values.memcached.containerSecurityContext | nindent 12 }} | ||
{{- if .extraVolumeMounts }} | ||
volumeMounts: | ||
{{- toYaml .extraVolumeMounts | nindent 12 }} | ||
{{- end }} | ||
|
||
{{- if $.ctx.Values.memcachedExporter.enabled }} | ||
- name: exporter | ||
{{- with $.ctx.Values.memcachedExporter.image }} | ||
image: {{ .repository}}:{{ .tag }} | ||
imagePullPolicy: {{ .pullPolicy }} | ||
{{- end }} | ||
ports: | ||
- containerPort: 9150 | ||
name: http-metrics | ||
args: | ||
- "--memcached.address=localhost:{{ .port }}" | ||
- "--web.listen-address=0.0.0.0:9150" | ||
{{- range $key, $value := $.ctx.Values.memcachedExporter.extraArgs }} | ||
- "--{{ $key }}{{ if $value }}={{ $value }}{{ end }}" | ||
{{- end }} | ||
resources: | ||
{{- toYaml $.ctx.Values.memcachedExporter.resources | nindent 12 }} | ||
securityContext: | ||
{{- toYaml $.ctx.Values.memcachedExporter.containerSecurityContext | nindent 12 }} | ||
{{- if .extraVolumeMounts }} | ||
volumeMounts: | ||
{{- toYaml .extraVolumeMounts | nindent 12 }} | ||
{{- end }} | ||
{{- end }} | ||
{{- end -}} | ||
{{- end -}} | ||
{{- end -}} | ||
|
42 changes: 42 additions & 0 deletions
42
production/helm/loki/templates/memcached/_memcached-svc.tpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
{{/* | ||
memcached Service | ||
Params: | ||
ctx = . context | ||
valuesSection = name of the section in values.yaml | ||
component = name of the component | ||
valuesSection and component are specified separately because helm prefers camelcase for naming convetion and k8s components are named with snake case. | ||
*/}} | ||
{{- define "loki.memcached.service" -}} | ||
{{ with (index $.ctx.Values $.valuesSection) }} | ||
{{- if .enabled -}} | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: {{ include "loki.resourceName" (dict "ctx" $.ctx "component" $.component) }} | ||
labels: | ||
{{- include "loki.labels" $.ctx | nindent 4 }} | ||
app.kubernetes.io/component: "memcached-{{ $.component }}" | ||
{{- with .service.labels }} | ||
{{- toYaml . | nindent 4 }} | ||
{{- end }} | ||
annotations: | ||
{{- toYaml .service.annotations | nindent 4 }} | ||
namespace: {{ $.ctx.Release.Namespace | quote }} | ||
spec: | ||
type: ClusterIP | ||
clusterIP: None | ||
ports: | ||
- name: memcached-client | ||
port: {{ .port }} | ||
targetPort: {{ .port }} | ||
{{ if $.ctx.Values.memcachedExporter.enabled -}} | ||
- name: http-metrics | ||
port: 9150 | ||
targetPort: 9150 | ||
{{ end }} | ||
selector: | ||
{{- include "loki.selectorLabels" $.ctx | nindent 4 }} | ||
app.kubernetes.io/component: "memcached-{{ $.component }}" | ||
{{- end -}} | ||
{{- end -}} | ||
{{- end -}} |
16 changes: 16 additions & 0 deletions
16
production/helm/loki/templates/results-cache/poddisruptionbudget-results-cache.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{{- if .Values.resultsCache.enabled }} | ||
apiVersion: {{ include "loki.pdb.apiVersion" . }} | ||
kind: PodDisruptionBudget | ||
metadata: | ||
name: {{ include "loki.fullname" . }}-memcached-results-cache | ||
namespace: {{ .Release.Namespace }} | ||
labels: | ||
{{- include "loki.selectorLabels" . | nindent 4 }} | ||
app.kubernetes.io/component: memcached-results-cache | ||
spec: | ||
selector: | ||
matchLabels: | ||
{{- include "loki.selectorLabels" . | nindent 6 }} | ||
app.kubernetes.io/component: memcached-results-cache | ||
maxUnavailable: 1 | ||
{{- end -}} |
1 change: 1 addition & 0 deletions
1
production/helm/loki/templates/results-cache/service-results-cache-headless.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{{- include "loki.memcached.service" (dict "ctx" $ "valuesSection" "resultsCache" "component" "results-cache" ) }} |
1 change: 1 addition & 0 deletions
1
production/helm/loki/templates/results-cache/statefulset-results-cache.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{{- include "loki.memcached.statefulSet" (dict "ctx" $ "valuesSection" "resultsCache" "component" "results-cache" ) }} |
Oops, something went wrong.