|
| 1 | +{{/* |
| 2 | +Service helper |
| 3 | +*/}} |
| 4 | + |
| 5 | +{{- define "loki.service" }} |
| 6 | +{{- $target := .target }} |
| 7 | +{{- $ctx := .ctx }} |
| 8 | +{{- $component := .component }} |
| 9 | +{{- $name := .name }} |
| 10 | +{{- $headlessName := .headlessName }} |
| 11 | +{{- with $ctx }} |
| 12 | +apiVersion: v1 |
| 13 | +kind: Service |
| 14 | +metadata: |
| 15 | + {{- if $name }} |
| 16 | + name: {{ $name }} |
| 17 | + {{- else }} |
| 18 | + name: "{{ include "loki.fullname" . }}-{{ $target }}" |
| 19 | + {{- end }} |
| 20 | + namespace: "{{ include "loki.namespace" . }}" |
| 21 | + labels: |
| 22 | + {{- include "loki.labels" . | nindent 4 }} |
| 23 | + app.kubernetes.io/component: {{ $target | quote }} |
| 24 | + {{- with (mergeOverwrite (dict) .Values.defaults.service.labels ($component.serviceLabels | default dict) $component.service.labels) }} |
| 25 | + {{- toYaml . | nindent 4 }} |
| 26 | + {{- end }} |
| 27 | + annotations: |
| 28 | + {{- with (mergeOverwrite (dict) .Values.loki.serviceAnnotations .Values.defaults.service.annotations ($component.serviceAnnotations | default dict) $component.service.annotations) }} |
| 29 | + {{- toYaml . | nindent 4 }} |
| 30 | + {{- end }} |
| 31 | +spec: |
| 32 | + type: {{ $component.serviceType | default $component.service.type | default "ClusterIP" }} |
| 33 | + publishNotReadyAddresses: true |
| 34 | + ports: |
| 35 | + - name: http-metrics |
| 36 | + port: 3100 |
| 37 | + targetPort: http-metrics |
| 38 | + protocol: TCP |
| 39 | + - name: grpc |
| 40 | + port: 9095 |
| 41 | + targetPort: grpc |
| 42 | + protocol: TCP |
| 43 | + {{- with (dig "appProtocol" "grpc" $component.service.appProtocol.grpc $component) }} |
| 44 | + appProtocol: {{ . }} |
| 45 | + {{- end }} |
| 46 | + - name: grpclb |
| 47 | + port: 9096 |
| 48 | + targetPort: grpc |
| 49 | + protocol: TCP |
| 50 | + {{- with (dig "appProtocol" "grpc" $component.service.appProtocol.grpc $component) }} |
| 51 | + appProtocol: {{ . }} |
| 52 | + {{- end }} |
| 53 | + selector: |
| 54 | + {{ include "loki.selectorLabels" . | nindent 4 }} |
| 55 | + app.kubernetes.io/component: {{ $target | quote }} |
| 56 | +{{- with (coalesce $component.trafficDistribution $component.service.trafficDistribution .Values.defaults.service.trafficDistribution .Values.loki.service.trafficDistribution) }} |
| 57 | + trafficDistribution: {{ . }} |
| 58 | +{{- end }} |
| 59 | +{{- with $component.service.sessionAffinity }} |
| 60 | + sessionAffinity: {{ . }} |
| 61 | +{{- end }} |
| 62 | +{{- with $component.service.sessionAffinityConfig }} |
| 63 | + sessionAffinityConfig: |
| 64 | + {{- toYaml . | nindent 4 }} |
| 65 | +{{- end }} |
| 66 | +--- |
| 67 | +apiVersion: v1 |
| 68 | +kind: Service |
| 69 | +metadata: |
| 70 | + {{ if $headlessName }} |
| 71 | + name: {{ $headlessName }} |
| 72 | + {{ else }} |
| 73 | + name: "{{ include "loki.fullname" . }}-{{ $target }}-headless" |
| 74 | + {{- end }} |
| 75 | + namespace: {{ include "loki.namespace" . }} |
| 76 | + labels: |
| 77 | + {{- include "loki.labels" . | nindent 4 }} |
| 78 | + app.kubernetes.io/component: {{ $target | quote }} |
| 79 | + prometheus.io/service-monitor: "false" |
| 80 | + variant: headless |
| 81 | + {{- with (mergeOverwrite (dict) .Values.defaults.service.labels ($component.serviceLabels | default dict) $component.service.labels) }} |
| 82 | + {{- toYaml . | nindent 4 }} |
| 83 | + {{- end }} |
| 84 | + annotations: |
| 85 | + {{- with (mergeOverwrite (dict) .Values.loki.serviceAnnotations .Values.defaults.service.annotations ($component.serviceAnnotations | default dict) $component.service.annotations) }} |
| 86 | + {{- toYaml . | nindent 4 }} |
| 87 | + {{- end }} |
| 88 | +spec: |
| 89 | + clusterIP: None |
| 90 | + type: ClusterIP |
| 91 | + publishNotReadyAddresses: true |
| 92 | + ports: |
| 93 | + - name: http-metrics |
| 94 | + port: 3100 |
| 95 | + targetPort: http-metrics |
| 96 | + protocol: TCP |
| 97 | + - name: grpc |
| 98 | + port: 9095 |
| 99 | + targetPort: grpc |
| 100 | + protocol: TCP |
| 101 | + {{- with (dig "appProtocol" "grpc" $component.service.appProtocol.grpc $component) }} |
| 102 | + appProtocol: {{ . }} |
| 103 | + {{- end }} |
| 104 | + - name: grpclb |
| 105 | + port: 9096 |
| 106 | + targetPort: grpc |
| 107 | + protocol: TCP |
| 108 | + {{- with (dig "appProtocol" "grpc" $component.service.appProtocol.grpc $component) }} |
| 109 | + appProtocol: {{ . }} |
| 110 | + {{- end }} |
| 111 | + selector: |
| 112 | + {{ include "loki.selectorLabels" . | nindent 4 }} |
| 113 | + app.kubernetes.io/component: {{ $target | quote }} |
| 114 | +{{- end }} |
| 115 | +{{- end }} |
0 commit comments