Skip to content
This repository was archived by the owner on Apr 28, 2025. It is now read-only.

Commit 3308e09

Browse files
authored
Merge pull request #162 from grafana/readme-ci
Add README instructions to CI tests
2 parents 2527cf8 + 9d30355 commit 3308e09

File tree

5 files changed

+55
-20
lines changed

5 files changed

+55
-20
lines changed

.circleci/config.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,27 @@ workflows:
66
jobs:
77
- lint
88
- build
9+
- test-readme
910

1011
jobs:
1112
lint:
1213
docker:
13-
- image: grafana/cortex-jsonnet-build-image:387f7ca
14+
- image: grafana/cortex-jsonnet-build-image:55f5699
1415
steps:
1516
- checkout
1617
- run: make lint
1718

1819
build:
1920
docker:
20-
- image: grafana/cortex-jsonnet-build-image:387f7ca
21+
- image: grafana/cortex-jsonnet-build-image:55f5699
2122
steps:
2223
- checkout
2324
- run: make build-mixin
2425
- store_artifacts:
2526
path: cortex-mixin.zip
27+
test-readme:
28+
docker:
29+
- image: grafana/cortex-jsonnet-build-image:55f5699
30+
steps:
31+
- checkout
32+
- run: make test-readme

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
cortex-mixin.zip
22
cortex-mixin/out
33
cortex-mixin/vendor
4+
/test-readme/

Makefile

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.PHONY: lint build-image publish-build-image
1+
.PHONY: lint build-image publish-build-image test-readme
22

33
JSONNET_FMT := jsonnetfmt
44

@@ -28,3 +28,13 @@ build-mixin:
2828
jsonnet -J vendor -S recording_rules.jsonnet > out/rules.yaml && \
2929
jsonnet -J vendor -S alerts.jsonnet > out/alerts.yaml
3030
zip -r cortex-mixin.zip cortex-mixin/out
31+
32+
test-readme:
33+
rm -rf test-readme && \
34+
mkdir test-readme && cd test-readme && \
35+
tk init --k8s=false && \
36+
jb install github.com/jsonnet-libs/k8s-alpha/1.18 && \
37+
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 && \
38+
jb install github.com/grafana/cortex-jsonnet/cortex && \
39+
cp vendor/cortex/cortex-manifests.jsonnet.example environments/default/main.jsonnet && \
40+
PAGER=cat tk show environments/default

README.md

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,47 +8,53 @@ To generate the YAMLs for deploying Cortex:
88

99
Follow the steps at https://tanka.dev/install. If you have `go` installed locally you can also use:
1010

11-
```
12-
# make sure to be outside of GOPATH or a go.mod project
11+
```console
12+
$ # make sure to be outside of GOPATH or a go.mod project
1313
$ GO111MODULE=on go get github.com/grafana/tanka/cmd/tk
1414
$ GO111MODULE=on go get github.com/jsonnet-bundler/jsonnet-bundler/cmd/jb
1515
```
1616

17-
1. Initialise the application and download the cortex jsonnet lib.
17+
1. Initialise the Tanka, and install the Cortex and Kubernetes Jsonnet libraries.
1818

19-
```
19+
```console
2020
$ mkdir <name> && cd <name>
21-
$ tk init
21+
$ tk init --k8s=false
22+
$ # The k8s-alpha library supports Kubernetes versions 1.14+
23+
$ jb install github.com/jsonnet-libs/k8s-alpha/1.18
24+
$ cat <<EOF > lib/k.libsonnet
25+
(import "github.com/jsonnet-libs/k8s-alpha/1.18/main.libsonnet")
26+
+ (import "github.com/jsonnet-libs/k8s-alpha/1.18/extensions/kausal-shim.libsonnet")
27+
EOF
2228
$ jb install github.com/grafana/cortex-jsonnet/cortex
2329
```
2430
1. Use the example monitoring.jsonnet.example:
2531

26-
```
32+
```console
2733
$ cp vendor/cortex/cortex-manifests.jsonnet.example environments/default/main.jsonnet
2834
```
2935

3036
1. Check what is in the example:
3137

32-
```
38+
```console
3339
$ cat environments/default/main.jsonnet
3440
...
3541
```
3642

3743
1. Generate the YAML manifests:
3844

39-
```
45+
```console
4046
$ tk show environments/default
4147
```
4248

4349
To output YAML manifests to `./manifests`, run:
4450

45-
```
51+
```console
4652
$ tk export environments/default manifests
4753
```
4854

4955
To generate the dashboards and alerts for Cortex:
5056

51-
```
57+
```console
5258
$ cd cortex-mixin
5359
$ jb install
5460
$ mkdir out

build-image/Dockerfile

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,26 @@ RUN git clone https://github.com/google/jsonnet && \
88
cp jsonnet/jsonnetfmt /usr/bin
99

1010
# Build jb
11-
FROM golang:1.14.1-alpine3.11 AS jb-builder
12-
RUN apk add --no-cache git make
13-
RUN git clone https://github.com/jsonnet-bundler/jsonnet-bundler /jsonnet-bundler && \
14-
cd /jsonnet-bundler && \
15-
git checkout v0.2.0 && \
16-
make install
11+
FROM alpine:3.11 AS jb-builder
12+
ARG JSONNET_BUNDLER_VERSION=0.4.0
13+
ARG JSONNET_BUNDLER_CHECKSUM="433edab5554a88a0371e11e93080408b225d41c31decf321c02b50d2e44993ce /usr/bin/jb"
14+
RUN apk add --no-cache curl
15+
RUN curl -fSL -o "/usr/bin/jb" "https://github.com/jsonnet-bundler/jsonnet-bundler/releases/download/v${JSONNET_BUNDLER_VERSION}/jb-linux-amd64"
16+
RUN echo "${JSONNET_BUNDLER_CHECKSUM}" | sha256sum -c || (printf "wanted: %s\n got: %s\n" "${JSONNET_BUNDLER_CHECKSUM}" "$(sha256sum /usr/bin/jb)"; exit 1)
17+
RUN chmod +x /usr/bin/jb
18+
19+
# Build tanka
20+
FROM alpine:3.11 AS tk-builder
21+
ARG TANKA_VERSION=0.11.1
22+
ARG TANKA_CHECKSUM="3b253ca7d7bf01189604c10a8f7cead20a553ddc04c813f0f836d80338cfad71 /usr/bin/tk"
23+
RUN apk add --no-cache curl
24+
RUN curl -fSL -o "/usr/bin/tk" "https://github.com/grafana/tanka/releases/download/v${TANKA_VERSION}/tk-linux-amd64"
25+
RUN echo "${TANKA_CHECKSUM}" | sha256sum -c || (printf "wanted: %s\n got: %s\n" "${TANKA_CHECKSUM}" "$(sha256sum /usr/bin/tk)"; exit 1)
26+
RUN chmod +x /usr/bin/tk
1727

1828
FROM alpine:3.11
1929
RUN apk add --no-cache git make libgcc libstdc++ zip
2030
COPY --from=jsonnet-builder /usr/bin/jsonnetfmt /usr/bin
2131
COPY --from=jsonnet-builder /usr/bin/jsonnet /usr/bin
22-
COPY --from=jb-builder /go/bin/jb /usr/bin
32+
COPY --from=jb-builder /usr/bin/jb /usr/bin
33+
COPY --from=tk-builder /usr/bin/tk /usr/bin

0 commit comments

Comments
 (0)