1
- local k = import 'ksonnet/ksonnet.beta.4/k.libsonnet' ;
2
-
3
1
{
4
2
local tc = self ,
5
3
@@ -26,75 +24,79 @@ local k = import 'ksonnet/ksonnet.beta.4/k.libsonnet';
26
24
},
27
25
28
26
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),
27
+ {
28
+ apiVersion: 'v1' ,
29
+ kind: 'Service' ,
30
+ metadata: {
31
+ name: tc.config.name,
32
+ namespace: tc.config.namespace,
33
+ labels: tc.config.commonLabels,
34
+ },
35
+ spec: {
36
+ selector: tc.config.podLabelSelector,
37
+ ports: [{ name: 'http' , targetPort: 'http' , port: 10902 }],
38
+ },
39
+ },
41
40
42
41
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([
42
+ local c = {
43
+ name: 'thanos-compact' ,
44
+ image: tc.config.image,
45
+ args: [
53
46
'compact' ,
54
47
'--wait' ,
55
48
'--log.level=' + tc.config.logLevel,
56
49
'--objstore.config=$(OBJSTORE_CONFIG)' ,
57
50
'--data-dir=/var/thanos/compact' ,
58
51
'--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' );
52
+ ],
53
+ env: [
54
+ { name: 'OBJSTORE_CONFIG' , valueFrom: { secretKeyRef: {
55
+ key: tc.config.objectStorageConfig.key,
56
+ name: tc.config.objectStorageConfig.name,
57
+ } } },
58
+ ],
59
+ ports: [{ name: 'http' , containerPort: tc.service.spec.ports[0 ].port }],
60
+ livenessProbe: { failureThreshold: 4 , periodSeconds: 30 , httpGet: {
61
+ scheme: 'HTTP' ,
62
+ port: tc.service.spec.ports[0 ].port,
63
+ path: '/-/healthy' ,
64
+ } },
65
+ readinessProbe: { failureThreshold: 20 , periodSeconds: 5 , httpGet: {
66
+ scheme: 'HTTP' ,
67
+ port: tc.service.spec.ports[0 ].port,
68
+ path: '/-/ready' ,
69
+ } },
70
+ volumeMounts: [{
71
+ name: 'data' ,
72
+ mountPath: '/var/thanos/compact' ,
73
+ readOnly: false ,
74
+ }],
75
+ terminationMessagePolicy: 'FallbackToLogsOnError' ,
76
+ };
85
77
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
78
{
96
- spec+: {
97
- volumeClaimTemplates: null ,
79
+ apiVersion: 'apps/v1' ,
80
+ kind: 'StatefulSet' ,
81
+ metadata: {
82
+ name: tc.config.name,
83
+ namespace: tc.config.namespace,
84
+ labels: tc.config.commonLabels,
85
+ },
86
+ spec: {
87
+ replicas: 1 ,
88
+ selector: { matchLabels: tc.config.podLabelSelector },
89
+ serviceName: tc.service.metadata.name,
90
+ template: {
91
+ metadata: {
92
+ labels: tc.config.commonLabels,
93
+ },
94
+ spec: {
95
+ containers: [c],
96
+ volumes: [],
97
+ terminationGracePeriodSeconds: 120 ,
98
+ },
99
+ },
98
100
},
99
101
},
100
102
0 commit comments