@@ -11,17 +11,42 @@ import (
11
11
)
12
12
13
13
const (
14
- secretsTemplateDir = "objstore"
14
+ objStoreSecretsTemplateDir = "objstore"
15
+ cacheTemplatesDir = "redis"
15
16
)
16
17
17
18
// Secrets generates the secrets for the Production environment
18
19
func (p Production ) Secrets () {
19
- secrets (p .generator (secretsTemplateDir ), p .namespace ())
20
+ secrets (p .generator (objStoreSecretsTemplateDir ), p .namespace ())
20
21
}
21
22
22
23
// Secrets generates the secrets for the Stage environment
23
24
func (s Stage ) Secrets () {
24
- secrets (s .generator (secretsTemplateDir ), s .namespace ())
25
+ ns := s .namespace ()
26
+ secrets (s .generator (objStoreSecretsTemplateDir ), ns )
27
+ var cacheObjs []runtime.Object
28
+ for _ , secret := range cacheSecretsStage (ns ) {
29
+ cacheObjs = append (cacheObjs , secret )
30
+ }
31
+ cacheSecrets (s .generator (cacheTemplatesDir ), cacheObjs )
32
+ }
33
+
34
+ func cacheSecrets (gen * mimic.Generator , secrets []runtime.Object ) {
35
+ gen .Add ("cache.yaml" , encoding .GhodssYAML (
36
+ openshift .WrapInTemplate (
37
+ secrets ,
38
+ metav1.ObjectMeta {Name : "redis-cache-secret" },
39
+ []templatev1.Parameter {
40
+ {Name : "INDEX_CACHE_ADDR" },
41
+ {Name : "INDEX_CACHE_PORT" },
42
+ {Name : "INDEX_CACHE_AUTH_TOKEN" },
43
+ {Name : "BUCKET_CACHE_ADDR" },
44
+ {Name : "BUCKET_CACHE_PORT" },
45
+ {Name : "BUCKET_CACHE_AUTH_TOKEN" },
46
+ },
47
+ ),
48
+ ))
49
+ gen .Generate ()
25
50
}
26
51
27
52
func secrets (gen * mimic.Generator , ns string ) {
@@ -73,6 +98,68 @@ func (l Local) Secrets() {
73
98
gen .Generate ()
74
99
}
75
100
101
+ const (
102
+ indexCacheName = "thanos-index-cache"
103
+ bucketCacheName = "thanos-bucket-cache"
104
+ )
105
+
106
+ func cacheSecretsStage (namespace string ) []* corev1.Secret {
107
+ return []* corev1.Secret {
108
+ {
109
+ TypeMeta : metav1.TypeMeta {
110
+ APIVersion : "v1" ,
111
+ Kind : "Secret" ,
112
+ },
113
+ ObjectMeta : metav1.ObjectMeta {
114
+ Name : indexCacheName ,
115
+ Namespace : namespace ,
116
+ Labels : map [string ]string {
117
+ "app.kubernetes.io/name" : indexCacheName ,
118
+ },
119
+ },
120
+ Type : corev1 .SecretTypeOpaque ,
121
+ StringData : map [string ]string {
122
+ "index-cache.yaml" : `type: REDIS
123
+ config:
124
+ addr: ${INDEX_CACHE_ADDR}:${INDEX_CACHE_PORT}
125
+ password: ${INDEX_CACHE_AUTH_TOKEN}
126
+ db: 0
127
+ max_item_size: 12428800 # 10 MiB
128
+ ttl: 24h
129
+ max_ascent_ttl: 24h
130
+ max_size: 0 # Unlimited
131
+ tls_enabled: true` ,
132
+ },
133
+ },
134
+ {
135
+ TypeMeta : metav1.TypeMeta {
136
+ APIVersion : "v1" ,
137
+ Kind : "Secret" ,
138
+ },
139
+ ObjectMeta : metav1.ObjectMeta {
140
+ Name : bucketCacheName ,
141
+ Namespace : namespace ,
142
+ Labels : map [string ]string {
143
+ "app.kubernetes.io/name" : bucketCacheName ,
144
+ },
145
+ },
146
+ Type : corev1 .SecretTypeOpaque ,
147
+ StringData : map [string ]string {
148
+ "bucket-cache.yaml" : `type: REDIS
149
+ config:
150
+ addr: ${BUCKET_CACHE_ADDR}:${BUCKET_CACHE_PORT}
151
+ password: ${BUCKET_CACHE_AUTH_TOKEN}
152
+ db: 0
153
+ max_item_size: 12428800 # 10 MiB
154
+ ttl: 24h
155
+ max_ascent_ttl: 24h
156
+ max_size: 0 # Unlimited
157
+ tls_enabled: true` ,
158
+ },
159
+ },
160
+ }
161
+ }
162
+
76
163
// thanosObjectStoreTemplate creates a templated version for stage environment
77
164
func thanosObjectStoreSecret (name , namespace string ) * corev1.Secret {
78
165
return & corev1.Secret {
0 commit comments