diff --git a/charts/opentelemetry-collector/Chart.yaml b/charts/opentelemetry-collector/Chart.yaml index 51390a9f2..1b3fb69aa 100644 --- a/charts/opentelemetry-collector/Chart.yaml +++ b/charts/opentelemetry-collector/Chart.yaml @@ -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/ diff --git a/charts/opentelemetry-collector/templates/_helpers.tpl b/charts/opentelemetry-collector/templates/_helpers.tpl index e3466e540..a6e836f22 100644 --- a/charts/opentelemetry-collector/templates/_helpers.tpl +++ b/charts/opentelemetry-collector/templates/_helpers.tpl @@ -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 -}} diff --git a/charts/opentelemetry-collector/templates/ingress.yaml b/charts/opentelemetry-collector/templates/ingress.yaml new file mode 100644 index 000000000..593ecd0ed --- /dev/null +++ b/charts/opentelemetry-collector/templates/ingress.yaml @@ -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 }} diff --git a/charts/opentelemetry-collector/values.yaml b/charts/opentelemetry-collector/values.yaml index 2b4049eaa..424685de5 100644 --- a/charts/opentelemetry-collector/values.yaml +++ b/charts/opentelemetry-collector/values.yaml @@ -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: {}