Skip to content

Commit be63a75

Browse files
committed
added secret generation for THAND_SECRET
1 parent 622145c commit be63a75

4 files changed

Lines changed: 120 additions & 3 deletions

File tree

.gitignore

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Helm dependencies
2+
charts/*/charts/
3+
charts/*/Chart.lock
4+
5+
# Helm packages
6+
*.tgz
7+
8+
# Chart releaser packages
9+
.cr-release-packages/
10+
.cr-index/
11+
12+
# Temporary files
13+
*.tmp
14+
*.bak
15+
16+
# IDE/Editor files
17+
.vscode/
18+
.idea/
19+
*.swp
20+
*.swo
21+
*~
22+
23+
# OS files
24+
.DS_Store
25+
Thumbs.db
26+
27+
# Logs
28+
*.log

charts/agent/templates/deployment.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,27 @@ spec:
5252
- name: {{ .name }}
5353
value: {{ .value | quote }}
5454
{{- end }}
55+
{{- if .Values.secrets.enabled }}
56+
{{- $secretData := .Values.secrets.data | default dict }}
57+
{{- if .Values.secrets.generate.enabled }}
58+
{{- range $key := .Values.secrets.generate.keys }}
59+
{{- if not (hasKey $secretData $key) }}
60+
- name: {{ $key }}
61+
valueFrom:
62+
secretKeyRef:
63+
name: {{ $.Values.secrets.existingSecret | default (printf "%s-secrets" (include "agent.fullname" $)) }}
64+
key: {{ $key }}
65+
{{- end }}
66+
{{- end }}
67+
{{- end }}
68+
{{- range $key, $value := $secretData }}
69+
- name: {{ $key }}
70+
valueFrom:
71+
secretKeyRef:
72+
name: {{ $.Values.secrets.existingSecret | default (printf "%s-secrets" (include "agent.fullname" $)) }}
73+
key: {{ $key }}
74+
{{- end }}
75+
{{- end }}
5576
{{- with .Values.envFrom }}
5677
envFrom:
5778
{{- toYaml . | nindent 12 }}

charts/agent/templates/secret.yaml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{{- if and .Values.secrets.enabled (not .Values.secrets.existingSecret) }}
2+
{{- $secretData := .Values.secrets.data | default dict }}
3+
{{- if .Values.secrets.generate.enabled }}
4+
{{- range $key := .Values.secrets.generate.keys }}
5+
{{- if not (hasKey $secretData $key) }}
6+
{{- $_ := set $secretData $key (randAlphaNum (.Values.secrets.generate.length | default 32)) }}
7+
{{- end }}
8+
{{- end }}
9+
{{- end }}
10+
apiVersion: v1
11+
kind: Secret
12+
metadata:
13+
name: {{ include "agent.fullname" . }}-secrets
14+
namespace: {{ include "agent.namespace" . }}
15+
labels:
16+
{{- include "agent.labels" . | nindent 4 }}
17+
annotations:
18+
# Force secret regeneration on upgrade if auto-generation is enabled
19+
{{- if .Values.secrets.generate.enabled }}
20+
"helm.sh/hook": "pre-install,pre-upgrade"
21+
"helm.sh/hook-weight": "-5"
22+
"helm.sh/hook-delete-policy": "before-hook-creation"
23+
{{- end }}
24+
type: Opaque
25+
{{- if $secretData }}
26+
data:
27+
{{- range $key, $value := $secretData }}
28+
{{ $key }}: {{ $value | b64enc | quote }}
29+
{{- end }}
30+
{{- else }}
31+
data: {}
32+
{{- end }}
33+
{{- end }}

charts/agent/values.yaml

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
# Namespace where the agent will be deployed
66
namespaceOverride: ""
77

8+
# Hostname for external access
9+
hostname: "thand-agent.local"
10+
811
# Number of replicas for the deployment
912
replicaCount: 1
1013

@@ -87,14 +90,14 @@ ingress:
8790
# kubernetes.io/ingress.class: nginx
8891
# cert-manager.io/cluster-issuer: letsencrypt-prod
8992
hosts:
90-
- host: thand-agent.local
93+
- host: "{{ .Values.hostname }}"
9194
paths:
9295
- path: /
9396
pathType: Prefix
9497
tls: []
9598
# - secretName: thand-agent-tls
9699
# hosts:
97-
# - thand-agent.local
100+
# - "{{ .Values.hostname }}"
98101

99102
# HTTPRoute configuration (Gateway API)
100103
httpRoute:
@@ -104,7 +107,7 @@ httpRoute:
104107
- name: gateway
105108
sectionName: http
106109
hostnames:
107-
- thand-agent.local
110+
- "{{ .Values.hostname }}"
108111
rules:
109112
- matches:
110113
- path:
@@ -162,6 +165,8 @@ affinity: {}
162165
# Environment variables
163166
env:
164167
# Log level: debug, info, warn, error
168+
- name: THAND_LOGIN_ENDPOINT
169+
value: "{{ .Values.hostname }}"
165170
- name: THAND_LOG_LEVEL
166171
value: "info"
167172
# Server port
@@ -182,10 +187,37 @@ envFrom: []
182187
# - configMapRef:
183188
# name: thand-config
184189

190+
# Application secrets configuration
191+
# Used for storing sensitive data like API keys, tokens, etc.
192+
secrets:
193+
# If true, creates a secret with the specified data
194+
enabled: true
195+
# Mount existing secret instead of creating one
196+
existingSecret: ""
197+
# Auto-generate secrets on deployment
198+
generate:
199+
# Enable automatic secret generation
200+
enabled: true
201+
# Length of generated secrets
202+
length: 32
203+
# List of secret keys to auto-generate if not provided in data
204+
keys:
205+
- "THAND_SECRET"
206+
# Secret data - will be base64 encoded automatically
207+
# If a key is listed in generate.keys and not provided here, it will be auto-generated
208+
data: {}
209+
# THAND_SECRET: "your-secret-value-here" # If provided, this overrides auto-generation
210+
# THAND_API_KEY: "your-api-key-here" # For Thand Cloud access
211+
185212
# Thand Agent Configuration
186213
config:
187214
# Main configuration for the agent
188215
# This will be mounted as config.yaml
216+
217+
login:
218+
endpoint: "{{ .Values.hostname }}"
219+
base: "/"
220+
189221
server:
190222
port: 8080
191223
host: "0.0.0.0"
@@ -195,6 +227,9 @@ config:
195227
ready:
196228
enabled: true
197229
path: "/ready"
230+
metrics:
231+
enabled: true
232+
path: "/metrics"
198233

199234
logging:
200235
level: "info"

0 commit comments

Comments
 (0)