Skip to content

Commit 92ae7d9

Browse files
authored
Remove chunks (#6)
* Remove chunks from jsonnet deployment * Adjust examples * Adjust changelog * Fix test-readme * Include tanka v0.21.0 updating build-image
1 parent a6318c7 commit 92ae7d9

21 files changed

+418
-648
lines changed

.github/workflows/lint.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
jobs:
77
lint:
88
runs-on: ubuntu-18.04
9-
container: grafana/cortex-jsonnet-build-image:3527936
9+
container: quay.io/cortexproject/cortex-jsonnet-build-image:c924d52
1010
steps:
1111
- uses: actions/checkout@v2
1212
name: Checkout
@@ -20,7 +20,7 @@ jobs:
2020
run: make lint-playbooks
2121
build:
2222
runs-on: ubuntu-18.04
23-
container: grafana/cortex-jsonnet-build-image:3527936
23+
container: quay.io/cortexproject/cortex-jsonnet-build-image:c924d52
2424
steps:
2525
- uses: actions/checkout@v2
2626
name: Checkout
@@ -31,7 +31,7 @@ jobs:
3131
run: make build-mixin
3232
readme:
3333
runs-on: ubuntu-18.04
34-
container: grafana/cortex-jsonnet-build-image:3527936
34+
container: quay.io/cortexproject/cortex-jsonnet-build-image:c924d52
3535
steps:
3636
- uses: actions/checkout@v2
3737
name: Checkout

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
## master / unreleased
44

55
* [CHANGE] Updated readme to use this repo with tanka
6+
* [CHANGE] Removed chunks support
67
* [CHANGE] Use integrated cortex overrides exporter
8+
* [ENHANCEMENT] Added main.jsonnet examples for azure, gcs and s3
79
* [ENHANCEMENT] How to rename buckets in AWS and Azure for `not healthy index found` playbook. #5
810
* [BUGFIX] Updated blocks_storage_s3_endpoint in config.libsonnet to include the correct aws region
911

Makefile

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ fmt:
3232
xargs -n 1 -- $(JSONNET_FMT) -i
3333

3434
build-image:
35-
docker build -t grafana/cortex-jsonnet-build-image:$(shell git rev-parse --short HEAD) build-image
35+
docker build -t quay.io/cortexproject/cortex-jsonnet-build-image:$(shell git rev-parse --short HEAD) build-image
3636

3737
publish-build-image:
38-
docker push grafana/cortex-jsonnet-build-image:$(shell git rev-parse --short HEAD)
38+
docker push quay.io/cortexproject/cortex-jsonnet-build-image:$(shell git rev-parse --short HEAD)
3939

4040
build-mixin:
4141
@cd cortex-mixin && \
@@ -44,16 +44,16 @@ build-mixin:
4444
mixtool generate all --output-alerts out/alerts.yaml --output-rules out/rules.yaml --directory out/dashboards mixin.libsonnet && \
4545
zip -q -r cortex-mixin.zip out
4646

47-
test-readme:
48-
rm -rf test-readme && \
49-
mkdir test-readme && cd test-readme && \
50-
tk init --k8s=false && \
51-
jb install github.com/jsonnet-libs/k8s-alpha/1.18 && \
52-
printf '(import "github.com/jsonnet-libs/k8s-alpha/1.18/main.libsonnet")\n+(import "github.com/jsonnet-libs/k8s-alpha/1.18/extensions/kausal-shim.libsonnet")' > lib/k.libsonnet && \
53-
jb install github.com/grafana/cortex-jsonnet/cortex@main && \
47+
test-readme: test-readme/azure test-readme/gcs test-readme/s3
48+
49+
test-readme/%:
50+
rm -rf $@ && \
51+
mkdir -p $@ && cd $@ && \
52+
tk init --k8s=1.21 && \
53+
jb install github.com/cortexproject/cortex-jsonnet/cortex@main && \
5454
rm -fr ./vendor/cortex && \
55-
cp -r ../cortex ./vendor/ && \
56-
cp vendor/cortex/cortex-manifests.jsonnet.example environments/default/main.jsonnet && \
55+
cp -r ../../cortex ./vendor/ && \
56+
cp vendor/cortex/$(notdir $@)/main.jsonnet.example environments/default/main.jsonnet && \
5757
PAGER=cat tk show environments/default
5858

5959
clean-white-noise:

README.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,18 @@ To generate the YAMLs for deploying Cortex:
2929
$ jb install github.com/cortexproject/cortex-jsonnet/cortex@main
3030
```
3131

32-
1. Use the example cortex-manifests.jsonnet.example:
32+
1. Use any of the examples to get a main.jsonnet and adjust as needed
3333

3434
```console
35-
$ cp vendor/cortex/cortex-manifests.jsonnet.example environments/default/main.jsonnet
35+
$ cp vendor/cortex/azure/main.jsonnet.example environments/default/main.jsonnet
36+
```
37+
38+
```console
39+
$ cp vendor/cortex/gcs/main.jsonnet.example environments/default/main.jsonnet
40+
```
41+
42+
```console
43+
$ cp vendor/cortex/s3/main.jsonnet.example environments/default/main.jsonnet
3644
```
3745

3846
1. Check what is in the example:

build-image/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ RUN chmod +x /usr/bin/jb
1818

1919
# Build tanka
2020
FROM alpine:3.13 AS tk-builder
21-
ARG TANKA_VERSION=0.11.1
22-
ARG TANKA_CHECKSUM="3b253ca7d7bf01189604c10a8f7cead20a553ddc04c813f0f836d80338cfad71 /usr/bin/tk"
21+
ARG TANKA_VERSION=0.21.0
22+
ARG TANKA_CHECKSUM="cd60a005f84fd99763f26d07d4cb626e7585a62800aae97234d8187129eed1ec /usr/bin/tk"
2323
RUN apk add --no-cache curl
2424
RUN curl -fSL -o "/usr/bin/tk" "https://github.com/grafana/tanka/releases/download/v${TANKA_VERSION}/tk-linux-amd64"
2525
RUN echo "${TANKA_CHECKSUM}" | sha256sum -c || (printf "wanted: %s\n got: %s\n" "${TANKA_CHECKSUM}" "$(sha256sum /usr/bin/tk)"; exit 1)

cortex/azure/main.jsonnet.example

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
local cortex = import 'cortex/cortex.libsonnet';
2+
3+
cortex {
4+
_config+:: {
5+
namespace: 'default',
6+
7+
blocks_storage_backend: 'azure',
8+
blocks_storage_bucket_name: 'example-bucket',
9+
blocks_storage_azure_account_key: 'replace-with-valid-key',
10+
blocks_storage_azure_account_name: 'example-account',
11+
12+
// Cortex Ruler config.
13+
ruler_enabled: true,
14+
ruler_client_type: 'azure',
15+
ruler_storage_bucket_name: 'ruler-example-bucket',
16+
ruler_storage_azure_account_name: 'example-account',
17+
ruler_storage_azure_account_key: 'replace-with-valid-key',
18+
19+
// Cortex Alertmanager config
20+
alertmanager_enabled: true,
21+
alertmanager_client_type: 'azure',
22+
alertmanager_azure_container_name: 'alertmanager-example-bucket',
23+
alertmanager_azure_account_key: 'replace-with-valid-key',
24+
alertmanager_azure_account_name: 'example-account',
25+
external_url: 'https://cortex.example.com', //Alertmanager UI
26+
cluster: 'cluster',
27+
},
28+
}

cortex/compactor.libsonnet

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
{
2+
local container = $.core.v1.container,
3+
local pvc = $.core.v1.persistentVolumeClaim,
4+
local statefulSet = $.apps.v1.statefulSet,
5+
local volumeMount = $.core.v1.volumeMount,
6+
7+
// The compactor runs a statefulset with a single replica, because
8+
// it does not support horizontal scalability yet.
9+
local compactor_data_pvc =
10+
pvc.new() +
11+
pvc.mixin.spec.resources.withRequests({ storage: $._config.cortex_compactor_data_disk_size }) +
12+
pvc.mixin.spec.withAccessModes(['ReadWriteOnce']) +
13+
pvc.mixin.spec.withStorageClassName($._config.cortex_compactor_data_disk_class) +
14+
pvc.mixin.metadata.withName('compactor-data'),
15+
16+
compactor_args::
17+
$._config.grpcConfig +
18+
$._config.blocksStorageConfig +
19+
$._config.compactorLimitsConfig +
20+
{
21+
target: 'compactor',
22+
23+
// Compactor config.
24+
'compactor.block-ranges': '2h,12h,24h',
25+
'compactor.data-dir': '/data',
26+
'compactor.compaction-interval': '30m',
27+
'compactor.compaction-concurrency': $._config.cortex_compactor_max_concurrency,
28+
'compactor.cleanup-interval': $._config.cortex_compactor_cleanup_interval,
29+
30+
// Enable sharding.
31+
'compactor.sharding-enabled': true,
32+
'compactor.ring.store': 'consul',
33+
'compactor.ring.consul.hostname': 'consul.%s.svc.cluster.local:8500' % $._config.namespace,
34+
'compactor.ring.prefix': '',
35+
36+
// Limits config.
37+
'runtime-config.file': '/etc/cortex/overrides.yaml',
38+
},
39+
40+
compactor_ports:: $.util.defaultPorts,
41+
42+
compactor_container::
43+
container.new('compactor', $._images.compactor) +
44+
container.withPorts($.compactor_ports) +
45+
container.withArgsMixin($.util.mapToFlags($.compactor_args)) +
46+
container.withVolumeMountsMixin([volumeMount.new('compactor-data', '/data')]) +
47+
// Do not limit compactor CPU and request enough cores to honor configured max concurrency.
48+
$.util.resourcesRequests($._config.cortex_compactor_max_concurrency, '6Gi') +
49+
$.util.resourcesLimits(null, '6Gi') +
50+
$.util.readinessProbe +
51+
$.jaeger_mixin,
52+
53+
newCompactorStatefulSet(name, container)::
54+
statefulSet.new(name, 1, [container], compactor_data_pvc) +
55+
statefulSet.mixin.spec.withServiceName(name) +
56+
statefulSet.mixin.metadata.withNamespace($._config.namespace) +
57+
statefulSet.mixin.metadata.withLabels({ name: name }) +
58+
statefulSet.mixin.spec.template.metadata.withLabels({ name: name }) +
59+
statefulSet.mixin.spec.selector.withMatchLabels({ name: name }) +
60+
statefulSet.mixin.spec.template.spec.securityContext.withRunAsUser(0) +
61+
statefulSet.mixin.spec.updateStrategy.withType('RollingUpdate') +
62+
statefulSet.mixin.spec.template.spec.withTerminationGracePeriodSeconds(900) +
63+
// Parallelly scale up/down compactor instances instead of starting them
64+
// one by one. This does NOT affect rolling updates: they will continue to be
65+
// rolled out one by one (the next pod will be rolled out once the previous is
66+
// ready).
67+
statefulSet.mixin.spec.withPodManagementPolicy('Parallel') +
68+
$.util.configVolumeMount($._config.overrides_configmap, '/etc/cortex'),
69+
70+
compactor_statefulset:
71+
$.newCompactorStatefulSet('compactor', $.compactor_container),
72+
}

0 commit comments

Comments
 (0)