-
Notifications
You must be signed in to change notification settings - Fork 181
Add functions to implement Thanos Receive split functionality #244
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 3 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
0801cba
intial commit
bill3tt 2babb81
updates manifests & example
bill3tt efa90f5
add changelod
bill3tt af80a4f
review comments
bill3tt 330afb9
remove split library in favour of ingestor & router libs
bill3tt f358786
linter
bill3tt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
tmp | ||
vendor/ | ||
jsonnet/kube-thanos/jsonnetfile.lock.json | ||
.idea/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
160 changes: 160 additions & 0 deletions
160
jsonnet/kube-thanos/kube-thanos-receive-split.libsonnet
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,160 @@ | ||
local receiveConfigDefaults = import 'kube-thanos/kube-thanos-receive-default-params.libsonnet'; | ||
local receiveHashring = import 'kube-thanos/kube-thanos-receive-hashrings.libsonnet'; | ||
|
||
local defaults = receiveConfigDefaults { | ||
hashrings: [{ | ||
hashring: 'default', | ||
tenants: [], | ||
}], | ||
hashringConfigmapName: 'hashring-config', | ||
routerReplicas: 1, | ||
}; | ||
|
||
function(params) { | ||
local tr = self, | ||
// Combine the defaults and the passed params to make the component's config. | ||
config:: defaults + params, | ||
|
||
local ingestors = receiveHashring(tr.config { name: tr.config.name + '-ingestor' }), | ||
|
||
ingestors: { | ||
['ingestor-' + name]: ingestors.hashrings[name] | ||
for name in std.objectFields(ingestors.hashrings) | ||
}, | ||
|
||
ingestorStores:: [ | ||
'dnssrv+_grpc._tcp.%s.%s.svc.cluster.local:%d' % [ingestors.hashrings[name.hashring].service.metadata.name, tr.config.namespace, tr.config.ports.grpc] | ||
for name in tr.config.hashrings | ||
], | ||
|
||
ingestorEndpoints:: { | ||
[name.hashring]: [ | ||
'%s-%d.%s.%s.svc.cluster.local:%d' % [ | ||
ingestors.hashrings[name.hashring].service.metadata.name, | ||
i, | ||
ingestors.hashrings[name.hashring].service.metadata.name, | ||
tr.config.namespace, | ||
tr.config.ports.grpc, | ||
] | ||
// Replica specification is 1-based, but statefulSets are named 0-based. | ||
for i in std.range(0, tr.config.replicas - 1) | ||
] | ||
for name in tr.config.hashrings | ||
}, | ||
|
||
routerLabels:: tr.config.commonLabels { | ||
'app.kubernetes.io/component': tr.config.name + '-router', | ||
}, | ||
|
||
'router-service': { | ||
apiVersion: 'v1', | ||
kind: 'Service', | ||
metadata: { | ||
name: tr.config.name + '-router', | ||
namespace: tr.config.namespace, | ||
}, | ||
spec: { | ||
ports: [{ name: name, port: tr.config.ports[name] } for name in std.objectFields(tr.config.ports)], | ||
selector: tr.routerLabels, | ||
}, | ||
}, | ||
|
||
'router-configmap': { | ||
apiVersion: 'v1', | ||
kind: 'ConfigMap', | ||
metadata: { | ||
name: tr.config.hashringConfigMapName, | ||
namespace: tr.config.namespace, | ||
}, | ||
data: { | ||
'hashrings.json': std.toString([hashring { endpoints: tr.ingestorEndpoints[hashring.hashring] } for hashring in tr.config.hashrings]), | ||
}, | ||
}, | ||
|
||
// Create the deployment that acts as a router to the ingestor backends | ||
'router-deployment': { | ||
apiVersion: 'apps/v1', | ||
kind: 'Deployment', | ||
metadata: { | ||
name: tr.config.name + '-router', | ||
namespace: tr.config.namespace, | ||
labels: tr.routerLabels, | ||
}, | ||
spec: { | ||
replicas: tr.config.routerReplicas, | ||
selector: { matchLabels: tr.routerLabels }, | ||
template: { | ||
metadata: { | ||
labels: tr.routerLabels, | ||
}, | ||
spec: { | ||
serviceAccountName: ingestors.serviceAccount.metadata.name, | ||
securityContext: tr.config.securityContext, | ||
containers: [{ | ||
name: 'thanos-receive', | ||
image: tr.config.image, | ||
args: [ | ||
'receive', | ||
'--log.level=' + tr.config.logLevel, | ||
'--log.format=' + tr.config.logFormat, | ||
'--grpc-address=0.0.0.0:%d' % tr.config.ports.grpc, | ||
'--http-address=0.0.0.0:%d' % tr.config.ports.http, | ||
'--remote-write.address=0.0.0.0:%d' % tr.config.ports['remote-write'], | ||
'--receive.replication-factor=%d' % tr.config.replicationFactor, | ||
'--receive.hashrings-file=/var/lib/thanos-receive/hashrings.json', | ||
] + [ | ||
'--label=%s' % label | ||
for label in tr.config.labels | ||
] + ( | ||
if tr.config.tenantLabelName != null then [ | ||
'--receive.tenant-label-name=%s' % tr.config.tenantLabelName, | ||
] else [] | ||
) + ( | ||
if std.length(tr.config.tracing) > 0 then [ | ||
'--tracing.config=' + std.manifestYamlDoc( | ||
{ config+: { service_name: defaults.name } } + tr.config.tracing | ||
), | ||
] else [] | ||
), | ||
env: [ | ||
{ name: 'NAME', valueFrom: { fieldRef: { fieldPath: 'metadata.name' } } }, | ||
{ name: 'NAMESPACE', valueFrom: { fieldRef: { fieldPath: 'metadata.namespace' } } }, | ||
{ | ||
// Inject the host IP to make configuring tracing convenient. | ||
name: 'HOST_IP_ADDRESS', | ||
valueFrom: { | ||
fieldRef: { | ||
fieldPath: 'status.hostIP', | ||
}, | ||
}, | ||
}, | ||
], | ||
ports: [{ name: name, containerPort: tr.config.ports[name] } for name in std.objectFields(tr.config.ports)], | ||
volumeMounts: [{ name: 'hashring-config', mountPath: '/var/lib/thanos-receive' }], | ||
livenessProbe: { failureThreshold: 8, periodSeconds: 30, httpGet: { | ||
scheme: 'HTTP', | ||
port: tr.config.ports.http, | ||
path: '/-/healthy', | ||
} }, | ||
readinessProbe: { failureThreshold: 20, periodSeconds: 5, httpGet: { | ||
scheme: 'HTTP', | ||
port: tr.config.ports.http, | ||
path: '/-/ready', | ||
} }, | ||
resources: if tr.config.resources != {} then tr.config.resources else {}, | ||
terminationMessagePolicy: 'FallbackToLogsOnError', | ||
}], | ||
volumes: [{ | ||
name: 'hashring-config', | ||
configMap: { name: tr.config.hashringConfigMapName }, | ||
}], | ||
terminationGracePeriodSeconds: 30, | ||
nodeSelector: { | ||
'beta.kubernetes.io/os': 'linux', | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
serviceAccount: ingestors.serviceAccount, | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.