Skip to content

Commit 9c5de61

Browse files
author
Andrew Farries
committed
Mount stripe secret into usage component
The component will need to interact with the stripe api so will need API keys.
1 parent e9e33d8 commit 9c5de61

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

install/installer/pkg/components/usage/constants.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@
55
package usage
66

77
const (
8-
Component = "usage"
8+
Component = "usage"
9+
stripeSecretMountPath = "stripe-secret"
910
)

install/installer/pkg/components/usage/deployment.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"github.com/gitpod-io/gitpod/common-go/baseserver"
88
"github.com/gitpod-io/gitpod/installer/pkg/cluster"
99
"github.com/gitpod-io/gitpod/installer/pkg/common"
10+
"github.com/gitpod-io/gitpod/installer/pkg/config/v1/experimental"
1011
appsv1 "k8s.io/api/apps/v1"
1112
corev1 "k8s.io/api/core/v1"
1213
"k8s.io/apimachinery/pkg/api/resource"
@@ -19,6 +20,31 @@ import (
1920
func deployment(ctx *common.RenderContext) ([]runtime.Object, error) {
2021
labels := common.DefaultLabels(Component)
2122

23+
var volumes []corev1.Volume
24+
var volumeMounts []corev1.VolumeMount
25+
_ = ctx.WithExperimental(func(cfg *experimental.Config) error {
26+
if cfg.WebApp != nil && cfg.WebApp.Server != nil && cfg.WebApp.Server.StripeSecret != "" {
27+
stripeSecret := cfg.WebApp.Server.StripeSecret
28+
29+
volumes = append(volumes,
30+
corev1.Volume{
31+
Name: "stripe-secret",
32+
VolumeSource: corev1.VolumeSource{
33+
Secret: &corev1.SecretVolumeSource{
34+
SecretName: stripeSecret,
35+
},
36+
},
37+
})
38+
39+
volumeMounts = append(volumeMounts, corev1.VolumeMount{
40+
Name: "stripe-secret",
41+
MountPath: stripeSecretMountPath,
42+
ReadOnly: true,
43+
})
44+
}
45+
return nil
46+
})
47+
2248
return []runtime.Object{
2349
&appsv1.Deployment{
2450
TypeMeta: common.TypeMetaDeployment,
@@ -45,6 +71,7 @@ func deployment(ctx *common.RenderContext) ([]runtime.Object, error) {
4571
RestartPolicy: "Always",
4672
TerminationGracePeriodSeconds: pointer.Int64(30),
4773
InitContainers: []corev1.Container{*common.DatabaseWaiterContainer(ctx)},
74+
Volumes: volumes,
4875
Containers: []corev1.Container{{
4976
Name: Component,
5077
Image: ctx.ImageName(ctx.Config.Repository, Component, ctx.VersionManifest.Components.Usage.Version),
@@ -66,6 +93,7 @@ func deployment(ctx *common.RenderContext) ([]runtime.Object, error) {
6693
common.DefaultEnv(&ctx.Config),
6794
common.DatabaseEnv(&ctx.Config),
6895
),
96+
VolumeMounts: volumeMounts,
6997
LivenessProbe: &corev1.Probe{
7098
ProbeHandler: corev1.ProbeHandler{
7199
HTTPGet: &corev1.HTTPGetAction{

0 commit comments

Comments
 (0)