-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add the ability to set an additional service for the recevier (#1213)
Signed-off-by: Pete Wall <[email protected]>
- Loading branch information
Showing
5 changed files
with
180 additions
and
0 deletions.
There are no files selected for viewing
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
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 @@ | ||
{{- if and (index .Values "alloy-receiver").enabled (index .Values "alloy-receiver").extraService.enabled -}} | ||
{{- $name := printf "%s-%s" .Release.Name (index .Values "alloy-receiver").extraService.name | trunc 63 | trimSuffix "-" }} | ||
{{- if (index .Values "alloy-receiver").extraService.fullname }} | ||
{{- $name = (index .Values "alloy-receiver").extraService.fullname }} | ||
{{- end }} | ||
|
||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: {{ $name }} | ||
labels: | ||
{{- include "alloy.labels" (index .Subcharts "alloy-receiver") | nindent 4 }} | ||
app.kubernetes.io/component: networking | ||
{{- with (index .Values "alloy-receiver").service.annotations }} | ||
annotations: | ||
{{- toYaml . | nindent 4 }} | ||
{{- end }} | ||
spec: | ||
type: {{ (index .Values "alloy-receiver").service.type }} | ||
{{- if (index .Values "alloy-receiver").service.clusterIP }} | ||
clusterIP: {{ (index .Values "alloy-receiver").service.clusterIP }} | ||
{{- end }} | ||
selector: | ||
{{- include "alloy.selectorLabels" . | nindent 4 }} | ||
{{- if semverCompare ">=1.26-0" .Capabilities.KubeVersion.Version }} | ||
internalTrafficPolicy: {{ (index .Values "alloy-receiver").service.internalTrafficPolicy}} | ||
{{- end }} | ||
ports: | ||
- name: http-metrics | ||
{{- if eq (index .Values "alloy-receiver").service.type "NodePort" }} | ||
nodePort: {{ (index .Values "alloy-receiver").service.nodePort }} | ||
{{- end }} | ||
port: {{ (index .Values "alloy-receiver").alloy.listenPort }} | ||
targetPort: {{ (index .Values "alloy-receiver").alloy.listenPort }} | ||
protocol: "TCP" | ||
{{- range $portMap := (index .Values "alloy-receiver").alloy.extraPorts }} | ||
- name: {{ $portMap.name }} | ||
port: {{ $portMap.port }} | ||
targetPort: {{ $portMap.targetPort }} | ||
protocol: {{ coalesce $portMap.protocol "TCP" }} | ||
{{- end }} | ||
{{- end }} |
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,109 @@ | ||
# yamllint disable rule:document-start rule:line-length rule:trailing-spaces | ||
suite: Test Extra Receiver Service | ||
templates: | ||
- receiver-service.yaml | ||
tests: | ||
- it: does not create a Service by default | ||
set: | ||
cluster: {name: test-cluster} | ||
alloy-receiver: | ||
enabled: true | ||
extraConfig: " " | ||
asserts: | ||
- hasDocuments: | ||
count: 0 | ||
|
||
- it: creates a Service when enabled | ||
set: | ||
cluster: {name: test-cluster} | ||
alloy-receiver: | ||
enabled: true | ||
extraConfig: " " | ||
extraService: | ||
enabled: true | ||
asserts: | ||
- hasDocuments: | ||
count: 1 | ||
- isKind: | ||
of: Service | ||
- equal: | ||
path: metadata.name | ||
value: RELEASE-NAME-alloy | ||
|
||
- it: creates a Service with a specified name | ||
set: | ||
cluster: {name: test-cluster} | ||
alloy-receiver: | ||
enabled: true | ||
extraConfig: " " | ||
extraService: | ||
enabled: true | ||
name: alloy-ingester | ||
asserts: | ||
- hasDocuments: | ||
count: 1 | ||
- isKind: | ||
of: Service | ||
- equal: | ||
path: metadata.name | ||
value: RELEASE-NAME-alloy-ingester | ||
|
||
- it: creates a Service with a specified full name | ||
set: | ||
cluster: {name: test-cluster} | ||
alloy-receiver: | ||
enabled: true | ||
extraConfig: " " | ||
extraService: | ||
enabled: true | ||
fullname: alloy-ingester | ||
asserts: | ||
- hasDocuments: | ||
count: 1 | ||
- isKind: | ||
of: Service | ||
- equal: | ||
path: metadata.name | ||
value: alloy-ingester | ||
|
||
- it: has the same extraPorts as the main receiver | ||
set: | ||
cluster: {name: test-cluster} | ||
alloy-receiver: | ||
enabled: true | ||
extraConfig: " " | ||
alloy: | ||
extraPorts: | ||
- name: otlp-http | ||
port: 4318 | ||
targetPort: 4318 | ||
protocol: TCP | ||
- name: otlp-grpc | ||
port: 4317 | ||
targetPort: 4317 | ||
protocol: TCP | ||
extraService: | ||
enabled: true | ||
asserts: | ||
- hasDocuments: | ||
count: 1 | ||
- isKind: | ||
of: Service | ||
- equal: | ||
path: spec.ports | ||
value: | ||
- name: http-metrics | ||
port: 12345 | ||
targetPort: 12345 | ||
protocol: TCP | ||
- name: otlp-http | ||
port: 4318 | ||
targetPort: 4318 | ||
protocol: TCP | ||
- name: otlp-grpc | ||
port: 4317 | ||
targetPort: 4317 | ||
protocol: TCP | ||
|
||
|
||
|
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
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