Skip to content

Commit 69f7e58

Browse files
authored
Merge pull request #10 from chatwork/passing-token-using-secret
Pass api-token and username using Secret
2 parents fe8afac + a9c62e5 commit 69f7e58

File tree

6 files changed

+42
-12
lines changed

6 files changed

+42
-12
lines changed

charts/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
apiVersion: v2
22
name: sendgrid-stats-exporter
3-
description: A Helm chart for chatwork/sendgrid-stats-exporter (It's till private for now, but will make it public soon)
3+
description: A Helm chart for chatwork/sendgrid-stats-exporter
44
type: application
55
version: 0.0.1
66
appVersion: 0.0.3

charts/README.md

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,7 @@ A Helm chart for [chatwork/sendgrid-stats-exporter](https://github.com/chatwork/
66
## Installing the Chart
77

88
```
9-
$ cat configmap.yaml
10-
apiVersion: v1
11-
kind: ConfigMap
12-
metadata:
13-
name: sendgrid-config
14-
data:
15-
SENDGRID_API_KEY: 'secret'
16-
$ kubectl apply -f configmap.yaml
17-
configmap/sendgrid-config created
18-
19-
$ helm install --set 'envFrom[0].configMapRef.name=sendgrid-config' sendgrid-stats-exporter ./
9+
$ helm install --set 'deployment.secret.apiKey=secret' --set 'deployment.secret.username=username' sendgrid-stats-exporter ./
2010
```
2111

2212
```
@@ -49,6 +39,8 @@ The following table lists the configurable parameters of the Sendgrid-stats-expo
4939
| `podSecurityContext` | Security context for the pod | `{}` |
5040
| `securityContext` | Security context for container | `{}` |
5141
| `envFrom` | Extra custom environment variables from ConfigMaps | `[]` |
42+
| `deployment.secret.apiKey` | SendGrid api token | `{}` |
43+
| `deployment.secret.username` | SendGrid username | `[]` |
5244
| `service.type` | Service Type | `"ClusterIP"` |
5345
| `service.port` | Service port | `9154` |
5446
| `ingress.enabled` | If true, enable Ingress | `false` |

charts/templates/_helpers.tpl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,14 @@ Create the name of the service account to use
6060
{{- default "default" .Values.serviceAccount.name }}
6161
{{- end }}
6262
{{- end }}
63+
64+
{{/*
65+
Return secret name to be used based on provided values.
66+
*/}}
67+
{{- define "sendgrid-stats-exporter.secretName" -}}
68+
{{- if not .Values.deployment.secret.existingSecretName -}}
69+
{{ default (printf "%s-secret" (include "sendgrid-stats-exporter.fullname" . )) }}
70+
{{- else -}}
71+
{{ .Values.deployment.secret.existingSecretName }}
72+
{{- end -}}
73+
{{- end -}}

charts/templates/deployment.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,17 @@ spec:
3535
imagePullPolicy: {{ .Values.image.pullPolicy }}
3636
envFrom:
3737
{{- toYaml .Values.envFrom | nindent 12 }}
38+
env:
39+
- name: SENDGRID_USER_NAME
40+
valueFrom:
41+
secretKeyRef:
42+
name: {{ include "sendgrid-stats-exporter.secretName" . }}
43+
key: username
44+
- name: SENDGRID_API_KEY
45+
valueFrom:
46+
secretKeyRef:
47+
name: {{ include "sendgrid-stats-exporter.secretName" . }}
48+
key: apiKey
3849
ports:
3950
- name: http
4051
containerPort: 9154

charts/templates/secret.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
apiVersion: v1
2+
kind: Secret
3+
metadata:
4+
name: {{ include "sendgrid-stats-exporter.secretName" . }}
5+
labels:
6+
{{- include "sendgrid-stats-exporter.labels" . | nindent 4 }}
7+
type: Opaque
8+
data:
9+
username: {{ .Values.deployment.secret.username | b64enc | quote }}
10+
apiKey: {{ .Values.deployment.secret.apiKey | b64enc | quote }}

charts/values.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ securityContext: {}
2929

3030
envFrom: []
3131

32+
deployment:
33+
secret:
34+
existingSecretName:
35+
username: ""
36+
apiKey: ""
37+
3238
service:
3339
type: ClusterIP
3440
port: 9154

0 commit comments

Comments
 (0)