diff --git a/charts/egressd/templates/exporter/deployment.yaml b/charts/egressd/templates/exporter/deployment.yaml index dafdbc0..0a66adb 100644 --- a/charts/egressd/templates/exporter/deployment.yaml +++ b/charts/egressd/templates/exporter/deployment.yaml @@ -61,6 +61,22 @@ spec: valueFrom: fieldRef: fieldPath: metadata.namespace + {{- if .Values.castai.clusterID }} + {{- if ne .Values.castai.clusterIdSecretKeyRef.name "" }} + {{- fail "clusterID and clusterIdSecretKeyRef are mutually exclusive" }} + {{- end }} + - name: CLUSTER_ID + value: {{ .Values.castai.clusterID | quote }} + {{- else }} + {{- if not .Values.castai.clusterIdSecretKeyRef.name }} + {{- fail "either clusterID or clusterIdSecretKeyRef should be passed" }} + {{- end }} + - name: CLUSTER_ID + valueFrom: + secretKeyRef: + name: {{ .Values.castai.clusterIdSecretKeyRef.name }} + key: {{ .Values.castai.clusterIdSecretKeyRef.key }} + {{- end }} {{- if or .Values.castai.apiKey .Values.castai.apiKeySecretRef }} - name: API_KEY valueFrom: diff --git a/charts/egressd/values.yaml b/charts/egressd/values.yaml index bc6b6ea..8b42d99 100644 --- a/charts/egressd/values.yaml +++ b/charts/egressd/values.yaml @@ -17,6 +17,12 @@ castai: # CASTAI Cluster unique identifier. clusterID: "" + # clusterIdSecretKeyRef -- Name of secret with ClusterID + # The referenced secret must provide the ClusterID in .data[<<.Values.castai.clusterIdSecretKeyRef.key>>] + clusterIdSecretKeyRef: + name: "" + key: "CLUSTER_ID" + imagePullSecrets: [] nameOverride: "" fullnameOverride: "" @@ -126,7 +132,7 @@ exporter: {{- if or .Values.castai.apiKey .Values.castai.apiKeySecretRef }} castai: http: - url: "{{.Values.castai.apiURL}}/v1/kubernetes/clusters/{{.Values.castai.clusterID}}/egressd-metrics" + url: "{{.Values.castai.apiURL}}/v1/kubernetes/clusters/${CLUSTER_ID}/egressd-metrics" compression: gzip encoding: protobuf method: POST diff --git a/exporter/sinks/http.go b/exporter/sinks/http.go index 513f13a..3c86a8e 100644 --- a/exporter/sinks/http.go +++ b/exporter/sinks/http.go @@ -45,7 +45,7 @@ type HTTPSink struct { } func (s *HTTPSink) Push(ctx context.Context, batch *pb.PodNetworkMetricBatch) error { - uri, err := url.Parse(s.cfg.URL) + uri, err := url.Parse(os.ExpandEnv(s.cfg.URL)) if err != nil { return fmt.Errorf("invalid url: %w", err) }