Skip to content

Commit

Permalink
feat: allow external API keys to be defined for an agent (#643)
Browse files Browse the repository at this point in the history
Signed-off-by: David Poltorak <[email protected]>
  • Loading branch information
davidpoltorak-io authored Aug 22, 2023
1 parent 5a63909 commit 756dea7
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 0 deletions.
3 changes: 3 additions & 0 deletions infrastructure/charts/agent/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
{{- range .Values.ingress.consumers }}
- {{ regexReplaceAll "-" $.Release.Name "_" }}_{{ regexReplaceAll "-" . "_" | lower }}
{{- end }}
{{- range .Values.ingress.externalConsumers }}
- {{ regexReplaceAll "-" $.Release.Name "_" }}_{{ regexReplaceAll "-" . "_" | lower }}
{{- end }}
{{- end -}}
{{- define "labels.common" -}}
app.kubernetes.io/part-of: prism-agent
Expand Down
17 changes: 17 additions & 0 deletions infrastructure/charts/agent/templates/apisixconsumer.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,20 @@ spec:
---
{{- end }}
{{- end }}

{{- $root := . -}}
{{- range $consumer := .Values.ingress.externalConsumers }}
apiVersion: apisix.apache.org/v2
kind: ApisixConsumer
metadata:
name: "{{ $consumer | lower }}"
namespace: "{{ $root.Release.Namespace }}"
labels:
{{ template "labels.common" . }}
spec:
authParameter:
keyAuth:
secretRef:
name: "{{ $root.Values.ingress.externalConsumerKeyPrefix }}-{{ $consumer | lower }}"
---
{{- end }}
21 changes: 21 additions & 0 deletions infrastructure/charts/agent/templates/externalsecret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,24 @@ spec:
dataFrom:
- extract:
key: {{ .Values.secrets.dockerRegistryToken }}

---

{{- $root := . -}}
{{- range $consumer := .Values.ingress.externalConsumers }}
apiVersion: external-secrets.io/v1beta1
kind: ExternalSecret
metadata:
name: "{{ $root.Values.ingress.externalConsumerKeyPrefix }}-{{ $consumer | lower }}"
labels:
{{ template "labels.common" . }}
spec:
refreshInterval: "0"
secretStoreRef:
name: {{ $root.Values.secrets.secretStore | quote }}
kind: ClusterSecretStore
dataFrom:
- extract:
key: "{{ $root.Values.ingress.externalConsumerKeyPrefix }}-{{ $consumer | lower }}"
---
{{- end }}
4 changes: 4 additions & 0 deletions infrastructure/charts/agent/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ ingress:
enabled: true
allow_origins: "*"
consumers: []
# External Consumers are ones where the secret keys/API tokens
# are pulled in using External Secrets [and therefore aren't generated by helm]
externalConsumerKeyPrefix: chart-base-key-prefix
externalConsumers: []

secrets:
secretStore: chart-base-secretstore
Expand Down

0 comments on commit 756dea7

Please sign in to comment.