Adding dependencies, binary autostart

This commit is contained in:
plm
2024-12-16 14:55:43 +01:00
parent 5e1503f0bc
commit 10b01fdc40
318 changed files with 47355 additions and 1 deletions

View File

@@ -0,0 +1,40 @@
{{/*
index-gateway fullname
*/}}
{{- define "loki.indexGatewayFullname" -}}
{{ include "loki.fullname" . }}-index-gateway
{{- end }}
{{/*
index-gateway common labels
*/}}
{{- define "loki.indexGatewayLabels" -}}
{{ include "loki.labels" . }}
app.kubernetes.io/component: index-gateway
{{- end }}
{{/*
index-gateway selector labels
*/}}
{{- define "loki.indexGatewaySelectorLabels" -}}
{{ include "loki.selectorLabels" . }}
app.kubernetes.io/component: index-gateway
{{- end }}
{{/*
index-gateway image
*/}}
{{- define "loki.indexGatewayImage" -}}
{{- $dict := dict "loki" .Values.loki.image "service" .Values.indexGateway.image "global" .Values.global.image "defaultVersion" .Chart.AppVersion -}}
{{- include "loki.lokiImage" $dict -}}
{{- end }}
{{/*
index-gateway priority class name
*/}}
{{- define "loki.indexGatewayPriorityClassName" -}}
{{- $pcn := coalesce .Values.global.priorityClassName .Values.indexGateway.priorityClassName -}}
{{- if $pcn }}
priorityClassName: {{ $pcn }}
{{- end }}
{{- end }}

View File

@@ -0,0 +1,21 @@
{{- $isDistributed := eq (include "loki.deployment.isDistributed" .) "true" -}}
{{- if and $isDistributed (gt (int .Values.indexGateway.replicas) 1) }}
{{- if kindIs "invalid" .Values.indexGateway.maxUnavailable }}
{{- fail "`.Values.indexGateway.maxUnavailable` must be set when `.Values.indexGateway.replicas` is greater than 1." }}
{{- else }}
apiVersion: {{ include "loki.pdb.apiVersion" . }}
kind: PodDisruptionBudget
metadata:
name: {{ include "loki.indexGatewayFullname" . }}
namespace: {{ $.Release.Namespace }}
labels:
{{- include "loki.indexGatewayLabels" . | nindent 4 }}
spec:
selector:
matchLabels:
{{- include "loki.indexGatewaySelectorLabels" . | nindent 6 }}
{{- with .Values.indexGateway.maxUnavailable }}
maxUnavailable: {{ . }}
{{- end }}
{{- end }}
{{- end }}

View File

@@ -0,0 +1,35 @@
{{- $isDistributed := eq (include "loki.deployment.isDistributed" .) "true" -}}
{{- if $isDistributed }}
apiVersion: v1
kind: Service
metadata:
name: {{ include "loki.indexGatewayFullname" . }}-headless
namespace: {{ $.Release.Namespace }}
labels:
{{- include "loki.indexGatewaySelectorLabels" . | nindent 4 }}
prometheus.io/service-monitor: "false"
annotations:
{{- with .Values.loki.serviceAnnotations }}
{{- toYaml . | nindent 4}}
{{- end }}
{{- with .Values.indexGateway.serviceAnnotations }}
{{- toYaml . | nindent 4}}
{{- end }}
spec:
type: ClusterIP
clusterIP: None
ports:
- name: http-metrics
port: 3100
targetPort: http-metrics
protocol: TCP
- name: grpc
port: 9095
targetPort: grpc
protocol: TCP
{{- with .Values.indexGateway.appProtocol.grpc }}
appProtocol: {{ . }}
{{- end }}
selector:
{{- include "loki.indexGatewaySelectorLabels" . | nindent 4 }}
{{- end }}

View File

@@ -0,0 +1,36 @@
{{- $isDistributed := eq (include "loki.deployment.isDistributed" .) "true" -}}
{{- if $isDistributed }}
apiVersion: v1
kind: Service
metadata:
name: {{ include "loki.indexGatewayFullname" . }}
namespace: {{ $.Release.Namespace }}
labels:
{{- include "loki.indexGatewayLabels" . | nindent 4 }}
{{- with .Values.indexGateway.serviceLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
annotations:
{{- with .Values.loki.serviceAnnotations }}
{{- toYaml . | nindent 4}}
{{- end }}
{{- with .Values.indexGateway.serviceAnnotations }}
{{- toYaml . | nindent 4}}
{{- end }}
spec:
type: ClusterIP
ports:
- name: http-metrics
port: 3100
targetPort: http-metrics
protocol: TCP
- name: grpc
port: 9095
targetPort: grpc
protocol: TCP
{{- with .Values.indexGateway.appProtocol.grpc }}
appProtocol: {{ . }}
{{- end }}
selector:
{{- include "loki.indexGatewaySelectorLabels" . | nindent 4 }}
{{- end }}

View File

@@ -0,0 +1,192 @@
{{- $isDistributed := eq (include "loki.deployment.isDistributed" .) "true" -}}
{{- if $isDistributed }}
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: {{ include "loki.indexGatewayFullname" . }}
namespace: {{ $.Release.Namespace }}
labels:
{{- include "loki.indexGatewayLabels" . | nindent 4 }}
{{- with .Values.loki.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
replicas: {{ .Values.indexGateway.replicas }}
{{- with .Values.indexGateway.updateStrategy }}
updateStrategy:
{{- tpl (. | toYaml) $ | nindent 4 }}
{{- end }}
serviceName: {{ include "loki.indexGatewayFullname" . }}-headless
revisionHistoryLimit: {{ .Values.loki.revisionHistoryLimit }}
{{- if and (semverCompare ">= 1.23-0" (include "loki.kubeVersion" .)) (.Values.indexGateway.persistence.enableStatefulSetAutoDeletePVC) }}
{{/*
Data on the read nodes is easy to replace, so we want to always delete PVCs to make
operation easier, and will rely on re-fetching data when needed.
*/}}
persistentVolumeClaimRetentionPolicy:
whenDeleted: {{ .Values.indexGateway.persistence.whenDeleted }}
whenScaled: {{ .Values.indexGateway.persistence.whenScaled }}
{{- end }}
selector:
matchLabels:
{{- include "loki.indexGatewaySelectorLabels" . | nindent 6 }}
template:
metadata:
annotations:
{{- include "loki.config.checksum" . | nindent 8 }}
{{- with .Values.loki.podAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.indexGateway.podAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "loki.indexGatewaySelectorLabels" . | nindent 8 }}
{{- with .Values.loki.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.indexGateway.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- if .Values.indexGateway.joinMemberlist }}
app.kubernetes.io/part-of: memberlist
{{- end }}
spec:
serviceAccountName: {{ include "loki.serviceAccountName" . }}
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.indexGateway.hostAliases }}
hostAliases:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- include "loki.indexGatewayPriorityClassName" . | nindent 6 }}
securityContext:
{{- toYaml .Values.loki.podSecurityContext | nindent 8 }}
terminationGracePeriodSeconds: {{ .Values.indexGateway.terminationGracePeriodSeconds }}
{{- with .Values.indexGateway.initContainers }}
initContainers:
{{- toYaml . | nindent 8 }}
{{- end }}
containers:
- name: index-gateway
image: {{ include "loki.image" . }}
imagePullPolicy: {{ .Values.loki.image.pullPolicy }}
args:
- -config.file=/etc/loki/config/config.yaml
- -target=index-gateway
{{- with .Values.indexGateway.extraArgs }}
{{- toYaml . | nindent 12 }}
{{- end }}
ports:
- name: http-metrics
containerPort: 3100
protocol: TCP
- name: grpc
containerPort: 9095
protocol: TCP
{{- if .Values.indexGateway.joinMemberlist }}
- name: http-memberlist
containerPort: 7946
protocol: TCP
{{- end }}
{{- with .Values.indexGateway.extraEnv }}
env:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.indexGateway.extraEnvFrom }}
envFrom:
{{- toYaml . | nindent 12 }}
{{- end }}
securityContext:
{{- toYaml .Values.loki.containerSecurityContext | nindent 12 }}
readinessProbe:
{{- toYaml .Values.loki.readinessProbe | nindent 12 }}
livenessProbe:
{{- toYaml .Values.loki.livenessProbe | nindent 12 }}
volumeMounts:
- name: config
mountPath: /etc/loki/config
- name: runtime-config
mountPath: /etc/loki/runtime-config
- name: data
mountPath: /var/loki
{{- if .Values.enterprise.enabled }}
- name: license
mountPath: /etc/loki/license
{{- end }}
{{- with .Values.indexGateway.extraVolumeMounts }}
{{- toYaml . | nindent 12 }}
{{- end }}
resources:
{{- toYaml .Values.indexGateway.resources | nindent 12 }}
{{- if .Values.indexGateway.extraContainers }}
{{- toYaml .Values.indexGateway.extraContainers | nindent 8}}
{{- end }}
{{- with .Values.indexGateway.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.indexGateway.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.indexGateway.topologySpreadConstraints }}
topologySpreadConstraints:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.indexGateway.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
volumes:
- name: config
{{- include "loki.configVolume" . | nindent 10 }}
- name: runtime-config
configMap:
name: {{ template "loki.name" . }}-runtime
{{- if .Values.enterprise.enabled }}
- name: license
secret:
{{- if .Values.enterprise.useExternalLicense }}
secretName: {{ .Values.enterprise.externalLicenseName }}
{{- else }}
secretName: enterprise-logs-license
{{- end }}
{{- end }}
{{- with .Values.indexGateway.extraVolumes }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- if not .Values.indexGateway.persistence.enabled }}
- name: data
emptyDir: {}
{{- else if .Values.indexGateway.persistence.inMemory }}
- name: data
{{- if .Values.indexGateway.persistence.inMemory }}
emptyDir:
medium: Memory
{{- end }}
{{- if .Values.indexGateway.persistence.size }}
sizeLimit: {{ .Values.indexGateway.persistence.size }}
{{- end }}
{{- else }}
volumeClaimTemplates:
- metadata:
name: data
{{- with .Values.indexGateway.persistence.annotations }}
annotations:
{{- . | toYaml | nindent 10 }}
{{- end }}
spec:
accessModes:
- ReadWriteOnce
{{- with .Values.indexGateway.persistence.storageClass }}
storageClassName: {{ if (eq "-" .) }}""{{ else }}{{ . }}{{ end }}
{{- end }}
resources:
requests:
storage: {{ .Values.indexGateway.persistence.size | quote }}
{{- end }}
{{- end }}