@@ -26,75 +26,79 @@ local k = import 'ksonnet/ksonnet.beta.4/k.libsonnet';
26
26
},
27
27
28
28
service:
29
- local service = k.core.v1.service;
30
- local ports = service.mixin.spec.portsType;
31
-
32
- service.new(
33
- tc.config.name,
34
- tc.config.podLabelSelector,
35
- [
36
- ports.newNamed('http' , 10902 , 'http' ),
37
- ],
38
- ) +
39
- service.mixin.metadata.withNamespace(tc.config.namespace) +
40
- service.mixin.metadata.withLabels(tc.config.commonLabels),
29
+ {
30
+ apiVersion: 'v1' ,
31
+ kind: 'Service' ,
32
+ metadata: {
33
+ name: tc.config.name,
34
+ namespace: tc.config.namespace,
35
+ labels: tc.config.commonLabels,
36
+ },
37
+ spec: {
38
+ selector: tc.config.podLabelSelector,
39
+ ports: [{ name: 'http' , targetPort: 'http' , port: 10902 }],
40
+ },
41
+ },
41
42
42
43
statefulSet:
43
- local statefulSet = k.apps.v1.statefulSet;
44
- local volume = statefulSet.mixin.spec.template.spec.volumesType;
45
- local container = statefulSet.mixin.spec.template.spec.containersType;
46
- local containerEnv = container.envType;
47
- local containerVolumeMount = container.volumeMountsType;
48
-
49
- local c =
50
- container.new('thanos-compact' , tc.config.image) +
51
- container.withTerminationMessagePolicy('FallbackToLogsOnError' ) +
52
- container.withArgs([
44
+ local c = {
45
+ name: 'thanos-compact' ,
46
+ image: tc.config.image,
47
+ args: [
53
48
'compact' ,
54
49
'--wait' ,
55
50
'--log.level=' + tc.config.logLevel,
56
51
'--objstore.config=$(OBJSTORE_CONFIG)' ,
57
52
'--data-dir=/var/thanos/compact' ,
58
53
'--debug.accept-malformed-index' ,
59
- ]) +
60
- container.withEnv([
61
- containerEnv.fromSecretRef(
62
- 'OBJSTORE_CONFIG' ,
63
- tc.config.objectStorageConfig.name,
64
- tc.config.objectStorageConfig.key,
65
- ),
66
- ]) +
67
- container.withPorts([
68
- { name: 'http' , containerPort: tc.service.spec.ports[0 ].port },
69
- ]) +
70
- container.withVolumeMounts([
71
- containerVolumeMount.new('data' , '/var/thanos/compact' , false ),
72
- ]) +
73
- container.mixin.livenessProbe +
74
- container.mixin.livenessProbe.withPeriodSeconds(30 ) +
75
- container.mixin.livenessProbe.withFailureThreshold(4 ) +
76
- container.mixin.livenessProbe.httpGet.withPort(tc.service.spec.ports[0 ].port) +
77
- container.mixin.livenessProbe.httpGet.withScheme('HTTP' ) +
78
- container.mixin.livenessProbe.httpGet.withPath('/-/healthy' ) +
79
- container.mixin.readinessProbe +
80
- container.mixin.readinessProbe.withPeriodSeconds(5 ) +
81
- container.mixin.readinessProbe.withFailureThreshold(20 ) +
82
- container.mixin.readinessProbe.httpGet.withPort(tc.service.spec.ports[0 ].port) +
83
- container.mixin.readinessProbe.httpGet.withScheme('HTTP' ) +
84
- container.mixin.readinessProbe.httpGet.withPath('/-/ready' );
54
+ ],
55
+ env: [
56
+ { name: 'OBJSTORE_CONFIG' , valueFrom: { secretKeyRef: {
57
+ key: tc.config.objectStorageConfig.key,
58
+ name: tc.config.objectStorageConfig.name,
59
+ } } },
60
+ ],
61
+ ports: [{ name: 'http' , containerPort: tc.service.spec.ports[0 ].port }],
62
+ livenessProbe: { failureThreshold: 4 , periodSeconds: 30 , httpGet: {
63
+ scheme: 'HTTP' ,
64
+ port: tc.service.spec.ports[0 ].port,
65
+ path: '/-/healthy' ,
66
+ } },
67
+ readinessProbe: { failureThreshold: 20 , periodSeconds: 5 , httpGet: {
68
+ scheme: 'HTTP' ,
69
+ port: tc.service.spec.ports[0 ].port,
70
+ path: '/-/ready' ,
71
+ } },
72
+ volumeMounts: [{
73
+ name: 'data' ,
74
+ mountPath: '/var/thanos/compact' ,
75
+ readOnly: false ,
76
+ }],
77
+ terminationMessagePolicy: 'FallbackToLogsOnError' ,
78
+ };
85
79
86
- statefulSet.new(tc.config.name, tc.config.replicas, c, [], tc.config.commonLabels) +
87
- statefulSet.mixin.metadata.withNamespace(tc.config.namespace) +
88
- statefulSet.mixin.metadata.withLabels(tc.config.commonLabels) +
89
- statefulSet.mixin.spec.withServiceName(tc.service.metadata.name) +
90
- statefulSet.mixin.spec.template.spec.withTerminationGracePeriodSeconds(120 ) +
91
- statefulSet.mixin.spec.template.spec.withVolumes([
92
- volume.fromEmptyDir('data' ),
93
- ]) +
94
- statefulSet.mixin.spec.selector.withMatchLabels(tc.config.podLabelSelector) +
95
80
{
96
- spec+: {
97
- volumeClaimTemplates: null ,
81
+ apiVersion: 'apps/v1' ,
82
+ kind: 'StatefulSet' ,
83
+ metadata: {
84
+ name: tc.config.name,
85
+ namespace: tc.config.namespace,
86
+ labels: tc.config.commonLabels,
87
+ },
88
+ spec: {
89
+ replicas: 1 ,
90
+ selector: { matchLabels: tc.config.podLabelSelector },
91
+ serviceName: tc.service.metadata.name,
92
+ template: {
93
+ metadata: {
94
+ labels: tc.config.commonLabels,
95
+ },
96
+ spec: {
97
+ containers: [c],
98
+ volumes: [],
99
+ terminationGracePeriodSeconds: 120 ,
100
+ },
101
+ },
98
102
},
99
103
},
100
104
0 commit comments