Skip to content

Commit

Permalink
Add telemetry collector deployment to consul-k8s (hashicorp#2134)
Browse files Browse the repository at this point in the history
* Create values.yaml section for telemetry-collector

* Initial telemetry-collector validation and bats test

* Add nodeSelector

* Add connect-init initContainer

* Add consul-dataplane container

* Conditionally add ca-cert volume

* Include vault annotations

* Prune tests to pertinent test cases

* Move consul server env vars

* Check ca mount for dataplane container

* Check correct env var

* Set default resources

* Set initContainer and tolerations

* Support priorityClassName

* Support setting initContainer resources

* Fix replicas unit test

* Turn off tproxy and remove unneeded security context

* Set -tls-disabled if global.tls.enabled=false

* Set -ca-certs correct if tls is enabled

* Set external server args

* Set partition flag tests

* Label bats tests, remove duplicate flags

* Bats tests for service, add metricsserver port

* Support annotations and imagePullSecret on serviceAccount

* Create configmap for custom configuration

* Add configmap to deployment

* Fix test names

* Remove unneeded cloud validation. fixup comment

* Comment values.yaml changes

* Switch from sidecar auth method to component auth method

* changelog

* Add PodSecurityPolicy for consul-telemetry-collector

* Rename init container + add comment

* Remove logLevel bats tests as it is unsupported right now

* Remove auth-method special cases

* Replace LOGIN_DATACENTER login with LOGIN_NAMESPACE

* Remove unneeded LOGIN_DATACENTER test
  • Loading branch information
clly authored May 16, 2023
1 parent eeab076 commit 02cab6c
Show file tree
Hide file tree
Showing 17 changed files with 1,865 additions and 12 deletions.
3 changes: 3 additions & 0 deletions .changelog/2134.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:feature
Add support for consul-telemetry-collector to forward envoy metrics to an otelhttp compatible receiver or HCP
```
36 changes: 36 additions & 0 deletions charts/consul/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -387,3 +387,39 @@ Usage: {{ template "consul.validateCloudSecretKeys" . }}
{{- end }}
{{- end }}
{{- end -}}


{{/*
Fails if temeletryCollector.clientId or telemetryCollector.clientSecret exist and one of other secrets is nil or empty.
- telemetryCollector.cloud.clientId.secretName
- telemetryCollector.cloud.clientSecret.secretName
- global.cloud.resourceId.secretName
Usage: {{ template "consul.validateTelemetryCollectorCloud" . }}

*/}}
{{- define "consul.validateTelemetryCollectorCloud" -}}
{{- if (and .Values.telemetryCollector.cloud.clientId.secretName (or (not .Values.global.cloud.resourceId.secretName) (not .Values.telemetryCollector.cloud.clientSecret.secretName))) }}
{{fail "When telemetryCollector.cloud.clientId.secretName is set, global.cloud.resourceId.secretName, telemetryCollector.cloud.clientSecret.secretName must also be set."}}
{{- end }}
{{- if (and .Values.telemetryCollector.cloud.clientSecret.secretName (or (not .Values.global.cloud.resourceId.secretName) (not .Values.telemetryCollector.cloud.clientSecret.secretName))) }}
{{fail "When telemetryCollector.cloud.clientSecret.secretName is set, global.cloud.resourceId.secretName,telemetryCollector.cloud.clientId.secretName must also be set."}}
{{- end }}
{{- end }}

{{/**/}}

{{- define "consul.validateTelemetryCollectorCloudSecretKeys" -}}
{{- if or (and .Values.telemetryCollector.cloud.clientId.secretName (not .Values.telemetryCollector.cloud.clientId.secretKey)) (and .Values.telemetryCollector.cloud.clientId.secretKey (not .Values.telemetryCollector.cloud.clientId.secretName)) }}
{{fail "When either telemetryCollector.cloud.clientId.secretName or telemetryCollector.cloud.clientId.secretKey is defined, both must be set."}}
{{- end }}
{{- if or (and .Values.telemetryCollector.cloud.clientSecret.secretName (not .Values.telemetryCollector.cloud.clientSecret.secretKey)) (and .Values.telemetryCollector.cloud.clientSecret.secretKey (not .Values.telemetryCollector.cloud.clientSecret.secretName)) }}
{{fail "When either telemetryCollector.cloud.clientSecret.secretName or telemetryCollector.cloud.clientSecret.secretKey is defined, both must be set."}}
{{- end }}
{{- if or (and .Values.telemetryCollector.cloud.clientSecret.secretName .Values.telemetryCollector.cloud.clientSecret.secretKey .Values.telemetryCollector.cloud.clientId.secretName .Values.telemetryCollector.cloud.clientId.secretKey (not .Values.global.cloud.resourceId.secretName)) }}
{{fail "When telemetryCollector has clientId and clientSecret global.cloud.resourceId.secretName must be set"}}
{{- end }}
{{- if or (and .Values.telemetryCollector.cloud.clientSecret.secretName .Values.telemetryCollector.cloud.clientSecret.secretKey .Values.telemetryCollector.cloud.clientId.secretName .Values.telemetryCollector.cloud.clientId.secretKey (not .Values.global.cloud.resourceId.secretKey)) }}
{{fail "When telemetryCollector has clientId and clientSecret .global.cloud.resourceId.secretKey must be set"}}
{{- end }}
{{- end -}}
18 changes: 18 additions & 0 deletions charts/consul/templates/telemetry-collector-configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{{- if (and .Values.telemetryCollector.enabled .Values.telemetryCollector.customExporterConfig) }}
# Immutable ConfigMap which saves the partition name. Attempting to update this configmap
# with a new Admin Partition name will cause the helm upgrade to fail
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ template "consul.fullname" . }}-telemetry-collector
namespace: {{ .Release.Namespace }}
labels:
app: {{ template "consul.name" . }}
chart: {{ template "consul.chart" . }}
heritage: {{ .Release.Service }}
release: {{ .Release.Name }}
component: consul-telemetry-collector
data:
config.json: |-
{{ tpl .Values.telemetryCollector.customExporterConfig . | trimAll "\"" | indent 4 }}
{{- end }}
Loading

0 comments on commit 02cab6c

Please sign in to comment.