@@ -2,6 +2,7 @@ package e2edb
2
2
3
3
import (
4
4
"fmt"
5
+ "path/filepath"
5
6
"strings"
6
7
7
8
"github.com/cortexproject/cortex/integration/e2e"
@@ -15,11 +16,23 @@ const (
15
16
16
17
// NewMinio returns minio server, used as a local replacement for S3.
17
18
func NewMinio (port int , bktNames ... string ) * e2e.HTTPService {
18
- minioKESGithubContent := "https://raw.githubusercontent.com/minio/kes/master"
19
- commands := []string {
20
- fmt .Sprintf ("curl -sSL --tlsv1.2 -O '%s/root.key' -O '%s/root.cert'" , minioKESGithubContent , minioKESGithubContent ),
19
+ return newMinio (port , map [string ]string {}, bktNames ... )
20
+ }
21
+
22
+ // NewMinioWithKES returns minio server, configured to talk to a KES service.
23
+ func NewMinioWithKES (port int , kesEndpoint , rootKeyFile , rootCertFile , caCertFile string , bktNames ... string ) * e2e.HTTPService {
24
+ kesEnvVars := map [string ]string {
25
+ "MINIO_KMS_KES_ENDPOINT" : kesEndpoint ,
26
+ "MINIO_KMS_KES_KEY_FILE" : filepath .Join (e2e .ContainerSharedDir , rootKeyFile ),
27
+ "MINIO_KMS_KES_CERT_FILE" : filepath .Join (e2e .ContainerSharedDir , rootCertFile ),
28
+ "MINIO_KMS_KES_CAPATH" : filepath .Join (e2e .ContainerSharedDir , caCertFile ),
29
+ "MINIO_KMS_KES_KEY_NAME" : "my-minio-key" ,
21
30
}
31
+ return newMinio (port , kesEnvVars , bktNames ... )
32
+ }
22
33
34
+ func newMinio (port int , envVars map [string ]string , bktNames ... string ) * e2e.HTTPService {
35
+ commands := []string {}
23
36
for _ , bkt := range bktNames {
24
37
commands = append (commands , fmt .Sprintf ("mkdir -p /data/%s" , bkt ))
25
38
}
@@ -33,17 +46,27 @@ func NewMinio(port int, bktNames ...string) *e2e.HTTPService {
33
46
e2e .NewHTTPReadinessProbe (port , "/minio/health/ready" , 200 , 200 ),
34
47
port ,
35
48
)
36
- m .SetEnvVars (map [string ]string {
37
- "MINIO_ACCESS_KEY" : MinioAccessKey ,
38
- "MINIO_SECRET_KEY" : MinioSecretKey ,
39
- "MINIO_BROWSER" : "off" ,
40
- "ENABLE_HTTPS" : "0" ,
41
- // https://docs.min.io/docs/minio-kms-quickstart-guide.html
42
- "MINIO_KMS_KES_ENDPOINT" : "https://play.min.io:7373" ,
43
- "MINIO_KMS_KES_KEY_FILE" : "root.key" ,
44
- "MINIO_KMS_KES_CERT_FILE" : "root.cert" ,
45
- "MINIO_KMS_KES_KEY_NAME" : "my-minio-key" ,
46
- })
49
+ envVars ["MINIO_ACCESS_KEY" ] = MinioAccessKey
50
+ envVars ["MINIO_SECRET_KEY" ] = MinioSecretKey
51
+ envVars ["MINIO_BROWSER" ] = "off"
52
+ envVars ["ENABLE_HTTPS" ] = "0"
53
+ m .SetEnvVars (envVars )
54
+ return m
55
+ }
56
+
57
+ // NewKES returns KES server, used as a local key management store
58
+ func NewKES (port int , serverKeyFile , serverCertFile , rootCertFile string ) * e2e.HTTPService {
59
+ // Run this as a shell command, so sub-shell can evaluate 'identity' of root user.
60
+ command := fmt .Sprintf ("/kes server --addr 0.0.0.0:%d --key=%s --cert=%s --root=$(/kes tool identity of %s) --auth=off --quiet" ,
61
+ port , filepath .Join (e2e .ContainerSharedDir , serverKeyFile ), filepath .Join (e2e .ContainerSharedDir , serverCertFile ), filepath .Join (e2e .ContainerSharedDir , rootCertFile ))
62
+
63
+ m := e2e .NewHTTPService (
64
+ "kes" ,
65
+ images .KES ,
66
+ e2e .NewCommandWithoutEntrypoint ("sh" , "-c" , command ),
67
+ nil , // KES only supports https calls - TODO make Scenario able to call https or poll plain TCP socket.
68
+ port ,
69
+ )
47
70
return m
48
71
}
49
72
0 commit comments