Skip to content

Commit d88ab7a

Browse files
Simon Emmsroboquat
Simon Emms
authored andcommitted
[installer]: configure minio to act as gateway to azure blob storage
1 parent ae96f3d commit d88ab7a

File tree

5 files changed

+70
-23
lines changed

5 files changed

+70
-23
lines changed

installer/pkg/common/storage.go

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,24 @@ package common
77
import (
88
"fmt"
99
storageconfig "github.com/gitpod-io/gitpod/content-service/api/config"
10+
"k8s.io/utils/pointer"
1011

1112
corev1 "k8s.io/api/core/v1"
12-
"k8s.io/utils/pointer"
1313
)
1414

1515
// StorageConfig produces config service configuration from the installer config
1616

17+
func useMinio(context *RenderContext) bool {
18+
// Minio is used for in-cluster storage and as a facade to non-GCP providers
19+
if pointer.BoolDeref(context.Config.ObjectStorage.InCluster, false) {
20+
return true
21+
}
22+
if context.Config.ObjectStorage.Azure != nil {
23+
return true
24+
}
25+
return false
26+
}
27+
1728
func StorageConfig(context *RenderContext) storageconfig.StorageConfig {
1829
var res *storageconfig.StorageConfig
1930
if context.Config.ObjectStorage.CloudStorage != nil {
@@ -28,21 +39,8 @@ func StorageConfig(context *RenderContext) storageconfig.StorageConfig {
2839
},
2940
}
3041
}
31-
if context.Config.ObjectStorage.S3 != nil {
32-
// TODO(cw): where do we get the AWS secretKey and accessKey from?
33-
res = &storageconfig.StorageConfig{
34-
Kind: storageconfig.MinIOStorage,
35-
MinIOConfig: storageconfig.MinIOConfig{
36-
Endpoint: "some-magic-amazon-value?",
37-
AccessKeyID: "TODO",
38-
SecretAccessKey: "TODO",
39-
Secure: true,
40-
Region: context.Config.Metadata.Region,
41-
ParallelUpload: 6,
42-
},
43-
}
44-
}
45-
if b := context.Config.ObjectStorage.InCluster; b != nil && *b {
42+
43+
if useMinio(context) {
4644
res = &storageconfig.StorageConfig{
4745
Kind: storageconfig.MinIOStorage,
4846
MinIOConfig: storageconfig.MinIOConfig{
@@ -120,14 +118,10 @@ func AddStorageMounts(ctx *RenderContext, pod *corev1.PodSpec, container ...stri
120118
return nil
121119
}
122120

123-
if ctx.Config.ObjectStorage.S3 != nil {
124-
return nil
125-
}
126-
127-
if pointer.BoolDeref(ctx.Config.ObjectStorage.InCluster, false) {
121+
if useMinio(ctx) {
128122
// builtin storage needs no extra mounts
129123
return nil
130124
}
131125

132-
return fmt.Errorf("no valid storage confniguration set")
126+
return fmt.Errorf("no valid storage configuration set")
133127
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// Copyright (c) 2021 Gitpod GmbH. All rights reserved.
2+
// Licensed under the GNU Affero General Public License (AGPL).
3+
// See License-AGPL.txt in the project root for license information.
4+
5+
package azure
6+
7+
import (
8+
"fmt"
9+
"github.com/gitpod-io/gitpod/installer/pkg/common"
10+
"github.com/gitpod-io/gitpod/installer/pkg/helm"
11+
"github.com/gitpod-io/gitpod/installer/third_party/charts"
12+
"helm.sh/helm/v3/pkg/cli/values"
13+
)
14+
15+
var Helm = func(apiPort int32, consolePort int32) common.HelmFunc {
16+
return common.CompositeHelmFunc(
17+
helm.ImportTemplate(charts.Minio(), helm.TemplateConfig{}, func(cfg *common.RenderContext) (*common.HelmConfig, error) {
18+
return &common.HelmConfig{
19+
Enabled: true,
20+
Values: &values.Options{
21+
Values: []string{
22+
helm.KeyValue("minio.gateway.enabled", "true"),
23+
helm.KeyValue("minio.gateway.auth.azure.accessKey", cfg.Values.StorageAccessKey), // Azure value actually taken from secret - used for console/API access
24+
helm.KeyValue("minio.gateway.auth.azure.secretKey", cfg.Values.StorageSecretKey), // Ditto
25+
helm.KeyValue("minio.gateway.auth.azure.storageAccountNameExistingSecret", cfg.Config.ObjectStorage.Azure.Credentials.Name),
26+
helm.KeyValue("minio.gateway.auth.azure.storageAccountNameExistingSecretKey", "accountName"),
27+
helm.KeyValue("minio.gateway.auth.azure.storageAccountKeyExistingSecret", cfg.Config.ObjectStorage.Azure.Credentials.Name),
28+
helm.KeyValue("minio.gateway.auth.azure.storageAccountKeyExistingSecretKey", "accountKey"),
29+
helm.KeyValue("minio.gateway.replicaCount", "2"),
30+
helm.KeyValue("minio.gateway.type", "azure"),
31+
helm.KeyValue("minio.persistence.enabled", "false"),
32+
helm.KeyValue("minio.service.ports.api", fmt.Sprintf("%d", apiPort)),
33+
helm.KeyValue("minio.service.ports.console", fmt.Sprintf("%d", consolePort)),
34+
},
35+
},
36+
}, nil
37+
}),
38+
)
39+
}

installer/pkg/components/minio/helm.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@
22
// Licensed under the GNU Affero General Public License (AGPL).
33
// See License-AGPL.txt in the project root for license information.
44

5-
// Minio is used for both incluster deployments and as a facade for non-GCP storage providers
5+
// Minio is used for both in-cluster deployments and as a facade for non-GCP storage providers
66

77
package minio
88

99
import (
1010
"github.com/gitpod-io/gitpod/installer/pkg/common"
11+
"github.com/gitpod-io/gitpod/installer/pkg/components/minio/azure"
1112
"github.com/gitpod-io/gitpod/installer/pkg/components/minio/incluster"
1213
"k8s.io/utils/pointer"
1314
)
@@ -17,6 +18,9 @@ var Helm = common.CompositeHelmFunc(
1718
if pointer.BoolDeref(cfg.Config.ObjectStorage.InCluster, false) {
1819
return incluster.Helm(ServiceAPIPort, ServiceConsolePort)(cfg)
1920
}
21+
if cfg.Config.ObjectStorage.Azure != nil {
22+
return azure.Helm(ServiceAPIPort, ServiceConsolePort)(cfg)
23+
}
2024

2125
return nil, nil
2226
},

installer/pkg/config/v1/config.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ type ObjectStorage struct {
123123
InCluster *bool `json:"inCluster,omitempty"`
124124
S3 *ObjectStorageS3 `json:"s3,omitempty"`
125125
CloudStorage *ObjectStorageCloudStorage `json:"cloudStorage,omitempty"`
126+
Azure *ObjectStorageAzure `json:"azure,omitempty"`
126127
}
127128

128129
type ObjectStorageS3 struct {
@@ -134,6 +135,10 @@ type ObjectStorageCloudStorage struct {
134135
Project string `json:"project" validate:"required"`
135136
}
136137

138+
type ObjectStorageAzure struct {
139+
Credentials ObjectRef `json:"credentials"`
140+
}
141+
137142
type InstallationKind string
138143

139144
const (

installer/pkg/config/v1/validation.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,11 @@ func (v version) ClusterValidation(rcfg interface{}) cluster.ValidationChecks {
7777
res = append(res, cluster.CheckSecret(secretName, cluster.CheckSecretRequiredData("service-account.json")))
7878
}
7979

80+
if cfg.ObjectStorage.Azure != nil {
81+
secretName := cfg.ObjectStorage.Azure.Credentials.Name
82+
res = append(res, cluster.CheckSecret(secretName, cluster.CheckSecretRequiredData("accountName", "accountKey")))
83+
}
84+
8085
if cfg.ContainerRegistry.External != nil {
8186
secretName := cfg.ContainerRegistry.External.Certificate.Name
8287
res = append(res, cluster.CheckSecret(secretName, cluster.CheckSecretRequiredData(".dockerconfigjson")))

0 commit comments

Comments
 (0)