Skip to content

Commit dfc278d

Browse files
authored
Add support for missing objectstorage secret for thanos store (#307)
* Add support for missing objectstorage secret for thanos store Signed-off-by: Vibhu Prashar <vibhu.sharma2929@gmail.com> * Add review comments Signed-off-by: Vibhu Prashar <vibhu.sharma2929@gmail.com> --------- Signed-off-by: Vibhu Prashar <vibhu.sharma2929@gmail.com>
1 parent 04c9e46 commit dfc278d

25 files changed

+220
-50
lines changed

Makefile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,21 @@ lint: $(JSONNET_LINT) vendor
4242
vendor: | $(JB) jsonnetfile.json jsonnetfile.lock.json
4343
$(JB) install
4444

45+
.PHONY: deploy
46+
deploy:
47+
kubectl create ns thanos
48+
kubectl create ns minio
49+
kubectl apply -f https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/v$(PROM_OPERATOR_VERSION)/example/prometheus-operator-crd/monitoring.coreos.com_servicemonitors.yaml
50+
kubectl create -f examples/development-minio/
51+
kubectl create -f manifests/
52+
53+
.PHONY: teardown
54+
teardown:
55+
kubectl delete -f examples/development-minio/
56+
kubectl delete -f manifests/
57+
kubectl delete ns thanos
58+
kubectl delete ns minio
59+
4560
.PHONY: clean
4661
clean:
4762
-rm -rf tmp/bin

README.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,12 @@ This project is intended to be used as a library (i.e. the intent is not for you
2323
Though for a quickstart a compiled version of the Kubernetes [manifests](manifests) generated with this library (specifically with `example.jsonnet`) is checked into this repository in order to try the content out quickly. To try out the stack un-customized run:
2424
* Simply create the stack:
2525
```shell
26-
$ kubectl create ns thanos
27-
$ kubectl create -f manifests/
26+
$ make deploy
2827
```
2928

3029
* And to teardown the stack:
3130
```shell
32-
$ kubectl delete -f manifests/
31+
$ make teardown
3332
```
3433

3534
## Customizing kube-thanos
@@ -77,7 +76,7 @@ local commonConfig = {
7776
config+:: {
7877
local cfg = self,
7978
namespace: 'thanos',
80-
version: 'v0.29.0',
79+
version: 'v0.31.0',
8180
image: 'quay.io/thanos/thanos:' + cfg.version,
8281
imagePullPolicy: 'IfNotPresent',
8382
objectStorageConfig: {
@@ -167,10 +166,15 @@ find manifests -type f ! -name '*.yaml' -delete
167166
# The following script generates all components, mostly used for testing
168167

169168
rm -rf examples/all/manifests
169+
rm -rf examples/development-minio
170170
mkdir examples/all/manifests
171+
mkdir examples/development-minio
171172

172173
${JSONNET} -J vendor -m examples/all/manifests "${1-all.jsonnet}" | xargs -I{} sh -c "cat {} | ${GOJSONTOYAML} > {}.yaml; rm -f {}" -- {}
173174
find examples/all/manifests -type f ! -name '*.yaml' -delete
175+
176+
${JSONNET} -J vendor -m examples/development-minio "${1-minio.jsonnet}" | xargs -I{} sh -c "cat {} | ${GOJSONTOYAML} > {}.yaml; rm -f {}" -- {}
177+
find examples/development-minio -type f ! -name '*.yaml' -delete
174178
```
175179

176180
> Note you need `jsonnet` (`go get github.com/google/go-jsonnet/cmd/jsonnet`) and `gojsontoyaml` (`go get github.com/brancz/gojsontoyaml`) installed to run `build.sh`. If you just want json output, not yaml, then you can skip the pipe and everything afterwards.

build.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,12 @@ find manifests -type f ! -name '*.yaml' -delete
2121
# The following script generates all components, mostly used for testing
2222

2323
rm -rf examples/all/manifests
24+
rm -rf examples/development-minio
2425
mkdir examples/all/manifests
26+
mkdir examples/development-minio
2527

2628
${JSONNET} -J vendor -m examples/all/manifests "${1-all.jsonnet}" | xargs -I{} sh -c "cat {} | ${GOJSONTOYAML} > {}.yaml; rm -f {}" -- {}
2729
find examples/all/manifests -type f ! -name '*.yaml' -delete
30+
31+
${JSONNET} -J vendor -m examples/development-minio "${1-minio.jsonnet}" | xargs -I{} sh -c "cat {} | ${GOJSONTOYAML} > {}.yaml; rm -f {}" -- {}
32+
find examples/development-minio -type f ! -name '*.yaml' -delete

example.jsonnet

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ local commonConfig = {
66
config+:: {
77
local cfg = self,
88
namespace: 'thanos',
9-
version: 'v0.29.0',
9+
version: 'v0.31.0',
1010
image: 'quay.io/thanos/thanos:' + cfg.version,
1111
imagePullPolicy: 'IfNotPresent',
1212
objectStorageConfig: {

examples/development-minio/deployment.yaml renamed to examples/development-minio/minio-deployment.yaml

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ apiVersion: apps/v1
22
kind: Deployment
33
metadata:
44
name: minio
5+
namespace: thanos
56
spec:
67
selector:
78
matchLabels:
@@ -14,22 +15,25 @@ spec:
1415
app.kubernetes.io/name: minio
1516
spec:
1617
containers:
17-
- name: minio
18-
image: minio/minio
19-
command:
18+
- command:
2019
- /bin/sh
2120
- -c
22-
- "mkdir -p /storage/thanos && /opt/bin/minio server /storage"
21+
- |
22+
mkdir -p /storage/thanos && \
23+
/usr/bin/docker-entrypoint.sh minio server /storage
2324
env:
24-
- name: MINIO_ACCESS_KEY
25-
value: "minio"
26-
- name: MINIO_SECRET_KEY
27-
value: "minio123"
25+
- name: MINIO_ROOT_USER
26+
value: minio
27+
- name: MINIO_ROOT_PASSWORD
28+
value: minio123
29+
image: minio/minio:RELEASE.2023-05-27T05-56-19Z
30+
imagePullPolicy: IfNotPresent
31+
name: minio
2832
ports:
2933
- containerPort: 9000
3034
volumeMounts:
31-
- name: storage
32-
mountPath: "/storage"
35+
- mountPath: /storage
36+
name: storage
3337
volumes:
3438
- name: storage
3539
persistentVolumeClaim:
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
apiVersion: v1
22
kind: PersistentVolumeClaim
33
metadata:
4-
name: minio
54
labels:
65
app.kubernetes.io/name: minio
6+
name: minio
7+
namespace: thanos
78
spec:
89
accessModes:
9-
- ReadWriteOnce
10+
- ReadWriteOnce
1011
resources:
1112
requests:
12-
storage: 10Gi
13+
storage: 5Gi

examples/development-minio/secret.yaml renamed to examples/development-minio/minio-secret-thanos.yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@ apiVersion: v1
22
kind: Secret
33
metadata:
44
name: thanos-objectstorage
5-
type: Opaque
5+
namespace: thanos
66
stringData:
7-
thanos.yaml: |-
7+
thanos.yaml: |
88
type: s3
99
config:
1010
bucket: thanos
11-
endpoint: minio:9000
11+
endpoint: minio.thanos.svc.cluster.local:9000
1212
insecure: true
1313
access_key: minio
1414
secret_key: minio123
15+
type: Opaque

examples/development-minio/service.yaml renamed to examples/development-minio/minio-service.yaml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@ apiVersion: v1
22
kind: Service
33
metadata:
44
name: minio
5+
namespace: thanos
56
spec:
6-
type: ClusterIP
77
ports:
8-
- port: 9000
9-
targetPort: 9000
10-
protocol: TCP
8+
- port: 9000
9+
protocol: TCP
10+
targetPort: 9000
1111
selector:
1212
app.kubernetes.io/name: minio
13+
type: ClusterIP

jsonnet/minio/minio.libsonnet

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
// These are the defaults for this components configuration.
2+
// When calling the function to generate the component's manifest,
3+
// you can pass an object structured like the default to overwrite default values.
4+
local defaults = {
5+
namespace: error 'must provide namespace',
6+
buckets: error 'must provide buckets',
7+
accessKey: error 'must provide accessKey',
8+
secretKey: error 'must provide secretKey',
9+
10+
commonLabels:: { 'app.kubernetes.io/name': 'minio' },
11+
};
12+
13+
function(params) {
14+
local minio = self,
15+
16+
// Combine the defaults and the passed params to make the component's config.
17+
config:: defaults + params,
18+
19+
deployment: {
20+
apiVersion: 'apps/v1',
21+
kind: 'Deployment',
22+
metadata: {
23+
name: 'minio',
24+
namespace: minio.config.namespace,
25+
},
26+
spec: {
27+
selector: {
28+
matchLabels: minio.config.commonLabels,
29+
},
30+
strategy: { type: 'Recreate' },
31+
template: {
32+
metadata: {
33+
labels: minio.config.commonLabels,
34+
},
35+
spec: {
36+
containers: [
37+
{
38+
command: [
39+
'/bin/sh',
40+
'-c',
41+
|||
42+
mkdir -p %s && \
43+
/usr/bin/docker-entrypoint.sh minio server /storage
44+
||| % std.join(' ', ['/storage/%s' % bucket for bucket in minio.config.buckets]),
45+
],
46+
env: [
47+
{
48+
name: 'MINIO_ROOT_USER',
49+
value: minio.config.accessKey,
50+
},
51+
{
52+
name: 'MINIO_ROOT_PASSWORD',
53+
value: minio.config.secretKey,
54+
},
55+
],
56+
image: 'minio/minio:RELEASE.2023-05-27T05-56-19Z',
57+
imagePullPolicy: 'IfNotPresent',
58+
name: 'minio',
59+
ports: [
60+
{ containerPort: 9000 },
61+
],
62+
volumeMounts: [
63+
{ mountPath: '/storage', name: 'storage' },
64+
],
65+
},
66+
],
67+
volumes: [{
68+
name: 'storage',
69+
persistentVolumeClaim: { claimName: 'minio' },
70+
}],
71+
},
72+
},
73+
},
74+
},
75+
76+
pvc: {
77+
apiVersion: 'v1',
78+
kind: 'PersistentVolumeClaim',
79+
metadata: {
80+
labels: minio.config.commonLabels,
81+
name: 'minio',
82+
namespace: minio.config.namespace,
83+
},
84+
spec: {
85+
accessModes: ['ReadWriteOnce'],
86+
resources: {
87+
requests: { storage: '5Gi' },
88+
},
89+
},
90+
},
91+
92+
service: {
93+
apiVersion: 'v1',
94+
kind: 'Service',
95+
metadata: {
96+
name: 'minio',
97+
namespace: minio.config.namespace,
98+
},
99+
spec: {
100+
ports: [
101+
{ port: 9000, protocol: 'TCP', targetPort: 9000 },
102+
],
103+
selector: minio.config.commonLabels,
104+
type: 'ClusterIP',
105+
},
106+
},
107+
}

manifests/thanos-query-deployment.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ metadata:
55
app.kubernetes.io/component: query-layer
66
app.kubernetes.io/instance: thanos-query
77
app.kubernetes.io/name: thanos-query
8-
app.kubernetes.io/version: v0.29.0
8+
app.kubernetes.io/version: v0.31.0
99
name: thanos-query
1010
namespace: thanos
1111
spec:
@@ -21,7 +21,7 @@ spec:
2121
app.kubernetes.io/component: query-layer
2222
app.kubernetes.io/instance: thanos-query
2323
app.kubernetes.io/name: thanos-query
24-
app.kubernetes.io/version: v0.29.0
24+
app.kubernetes.io/version: v0.31.0
2525
spec:
2626
affinity:
2727
podAntiAffinity:
@@ -54,7 +54,7 @@ spec:
5454
valueFrom:
5555
fieldRef:
5656
fieldPath: status.hostIP
57-
image: quay.io/thanos/thanos:v0.29.0
57+
image: quay.io/thanos/thanos:v0.31.0
5858
imagePullPolicy: IfNotPresent
5959
livenessProbe:
6060
failureThreshold: 4

0 commit comments

Comments
 (0)