Skip to content

Commit

Permalink
feat: add support to key files in secrets
Browse files Browse the repository at this point in the history
Add possibility to store the online key as file in the secrets

It allows uses that uses clients that doesn't support KMS key for
example

Signed-off-by: Kairo Araujo <kairo.araujo@testifysec.com>
  • Loading branch information
kairoaraujo committed Sep 18, 2024
1 parent 176fa84 commit deff2a7
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 8 deletions.
2 changes: 1 addition & 1 deletion charts/rstuf-worker/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.1.3
version: 0.1.4

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
Expand Down
26 changes: 20 additions & 6 deletions charts/rstuf-worker/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,17 @@ spec:
{{- toYaml .Values.readinessProbe | nindent 12 }}
resources:
{{- toYaml .Values.resources | nindent 12 }}
{{- with .Values.volumeMounts }}
volumeMounts:
{{- with .Values.volumeMounts }}
{{- toYaml . | nindent 12 }}
{{- end }}
{{- end }}
{{- if .Values.onlineKeyFile }}
{{- range .Values.onlineKeyFile }}
- name: {{ .keyid | printf "%.7s" }}-keyfile-volume
mountPath: /run/secrets/{{ .keyid }}
subPath: {{ .keyid }}
{{- end }}
{{- end }}
env:
- name: RSTUF_BROKER_SERVER
value: {{ .Values.backend.brokerServer | quote }}
Expand All @@ -59,9 +66,9 @@ spec:
- name: RSTUF_LOCAL_STORAGE_BACKEND_PATH
value: {{ required "storage.backendPath is required when storage.type is 'LocalStorage'." .Values.storage.storagePath | quote }}
{{- end }}
{{- if and (eq .Values.storage.type "LocalStorage") .Values.storage.onlineKeyDir }}
{{- if .Values.onlineKeyDir }}
- name: RSTUF_ONLINE_KEY_DIR
value: {{ .Values.storage.onlineKeyDir | quote }}
value: {{ .Values.onlineKeyDir | quote }}
{{- end }}
{{- if eq .Values.storage.type "AWSS3" }}
- name: RSTUF_AWS_STORAGE_BUCKET
Expand Down Expand Up @@ -103,10 +110,17 @@ spec:
- name: RSTUF_LOCK_TIMEOUT
value: {{ .Values.backend.lockTimeOut | quote }}
{{- end }}
{{- with .Values.volumes }}
volumes:
{{- with .Values.volumes }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end }}
{{- if .Values.onlineKeyFile }}
{{- range .Values.onlineKeyFile }}
- name: {{ .keyid | printf "%.7s" }}-keyfile-volume
secret:
secretName: {{ .keyid }}-keyfile-secret
{{- end }}
{{- end }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
Expand Down
13 changes: 13 additions & 0 deletions charts/rstuf-worker/templates/secrets.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# templates/secrets.yaml
{{- if and (.Values.onlineKeyDir) (.Values.onlineKeyFile) }}
{{- range .Values.onlineKeyFile }}
apiVersion: v1
kind: Secret
metadata:
name: {{ .keyid }}-keyfile-secret
type: Opaque
data:
{{ .keyid }}: {{ .pem | quote }}
---
{{- end }}
{{- end }}
9 changes: 8 additions & 1 deletion charts/rstuf-worker/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ storage:
s3Region: ""
s3Endpoint: ""


backend:
brokerServer: "redis://redis"
redisServer: "redis://redis"
Expand All @@ -53,6 +52,14 @@ backend:
redisDbResult: "" # default is 0
redisDbSettings: "" # default is 1

# using online key as file
# onlineKeyDir: "/run/secrets"
# onlineKeyFile:
# - keyid: 0d9d3d4bad91c455bc03921daa95774576b86625ac45570d0cac025b08e65043
# # pem must be base64 encoded
# pem: |
# LS0tLS1CRUdJTiBSU0EgUFJJVkFURSBLRVktLS0tLQpNSUlFcEFJQkFBS0NBUUVBd0pOdG1KeTBia3kwVlpIaEpvVndWUjBvSXRvOG5kTExpY25hSFBEVWZGc3YyZFRQCjUwdUxpWXVZaFUvUkxUaCtQS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ether a service account should be created
create: true
Expand Down

0 comments on commit deff2a7

Please sign in to comment.