Skip to content

Commit

Permalink
feat(collector): allow deployment of ingress for standaloneCollector (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
secustor authored Feb 7, 2022
1 parent b3ce25d commit ffd0d36
Show file tree
Hide file tree
Showing 4 changed files with 96 additions and 1 deletion.
2 changes: 1 addition & 1 deletion charts/opentelemetry-collector/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apiVersion: v2
name: opentelemetry-collector
version: 0.8.3
version: 0.9.0
description: OpenTelemetry Collector Helm chart for Kubernetes
type: application
home: https://opentelemetry.io/
Expand Down
27 changes: 27 additions & 0 deletions charts/opentelemetry-collector/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,30 @@ Create the name of the clusterRoleBinding to use
{{- default "default" .Values.clusterRole.clusterRoleBinding.name }}
{{- end }}
{{- end }}

{{/*
Return the appropriate apiVersion for ingress.
*/}}
{{- define "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 supports pathType.
*/}}
{{- define "ingress.supportsPathType" -}}
{{- or (eq (include "ingress.isStable" .) "true") (and (eq (include "ingress.apiVersion" .) "networking.k8s.io/v1beta1") (semverCompare ">= 1.18-0" .Capabilities.KubeVersion.Version)) -}}
{{- end -}}

{{/*
Return if ingress is stable.
*/}}
{{- define "ingress.isStable" -}}
{{- eq (include "ingress.apiVersion" .) "networking.k8s.io/v1" -}}
{{- end -}}
53 changes: 53 additions & 0 deletions charts/opentelemetry-collector/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{{- if and .Values.standaloneCollector.enabled .Values.ingress.enabled -}}
{{- $ingressApiIsStable := eq (include "ingress.isStable" .) "true" -}}
{{- $ingressSupportsPathType := eq (include "ingress.supportsPathType" .) "true" -}}
apiVersion: {{ include "ingress.apiVersion" . }}
kind: Ingress
metadata:
name: {{ include "opentelemetry-collector.fullname" . }}
labels:
{{- include "opentelemetry-collector.labels" . | nindent 4 }}
component: standalone-collector
{{- if .Values.ingress.annotations }}
annotations:
{{ toYaml .Values.ingress.annotations | nindent 4 }}
{{- end }}
spec:
{{- if .Values.ingress.ingressClassName }}
ingressClassName: {{ .Values.ingress.ingressClassName }}
{{- end -}}
{{- if .Values.ingress.tls }}
tls:
{{- range .Values.ingress.tls }}
- hosts:
{{- range .hosts }}
- {{ . | quote }}
{{- end }}
{{- with .secretName }}
secretName: {{ . }}
{{- end }}
{{- end }}
{{- end }}
rules:
{{- range .Values.ingress.hosts }}
- host: {{ .host | quote }}
http:
paths:
{{- range .paths }}
- path: {{ .path }}
{{- if $ingressSupportsPathType }}
pathType: {{ .pathType }}
{{- end }}
backend:
{{- if $ingressApiIsStable }}
service:
name: {{ include "opentelemetry-collector.fullname" $ }}
port:
number: {{ .port }}
{{- else }}
serviceName: {{ include "opentelemetry-collector.fullname" $ }}
servicePort: {{ .port }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
15 changes: 15 additions & 0 deletions charts/opentelemetry-collector/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,21 @@ service:
type: ClusterIP
annotations: {}

ingress:
enabled: false
annotations: {}
# ingressClassName: nginx
# hosts:
# - host: collector.example.com
# paths:
# - path: /
# pathType: Prefix
# port: 4318
# tls:
# - secretName: collector-tls
# hosts:
# - collector.example.com

podMonitor:
enabled: false
metricsEndpoints: {}
Expand Down

0 comments on commit ffd0d36

Please sign in to comment.