Skip to content

Commit

Permalink
Add CLUSTER_ID env support in http sink (#122)
Browse files Browse the repository at this point in the history
  • Loading branch information
anjmao authored Jan 13, 2025
1 parent 9ae8d4b commit 37c5764
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
16 changes: 16 additions & 0 deletions charts/egressd/templates/exporter/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
8 changes: 7 additions & 1 deletion charts/egressd/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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: ""
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion exporter/sinks/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit 37c5764

Please sign in to comment.