Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions .github/workflows/test-build-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
lint:
runs-on: ubuntu-20.04
container:
image: us.gcr.io/kubernetes-dev/mimir-build-image:20211111_update-go-1.17.3-4e9f65408
image: us.gcr.io/kubernetes-dev/mimir-build-image:import-jsonnet-readme-2418fd778-WIP
credentials:
username: _json_key
password: ${{ secrets.gcr_json_key }}
Expand Down Expand Up @@ -47,6 +47,13 @@ jobs:
run: make BUILD_IN_CONTAINER=false check-mixin
- name: Check Jsonnet Manifests
run: make BUILD_IN_CONTAINER=false check-jsonnet-manifests
- name: Check Jsonnet Getting Started
run: |
git config --global url."https://${GIT_USERNAME}:${GIT_PASSWORD}@github.com/grafana/mimir".insteadOf "https://github.com/grafana/mimir"
make BUILD_IN_CONTAINER=false check-jsonnet-getting-started
env:
GIT_PASSWORD: ${{ secrets.GIT_PASSWORD }}
GIT_USERNAME: ${{ secrets.GIT_USERNAME }}
- name: Check White Noise.
run: make BUILD_IN_CONTAINER=false check-white-noise
- name: Check License Header
Expand All @@ -57,7 +64,7 @@ jobs:
test:
runs-on: ubuntu-20.04
container:
image: us.gcr.io/kubernetes-dev/mimir-build-image:20211111_update-go-1.17.3-4e9f65408
image: us.gcr.io/kubernetes-dev/mimir-build-image:import-jsonnet-readme-2418fd778-WIP
credentials:
username: _json_key
password: ${{ secrets.gcr_json_key }}
Expand All @@ -75,7 +82,7 @@ jobs:
build-mimir:
runs-on: ubuntu-20.04
container:
image: us.gcr.io/kubernetes-dev/mimir-build-image:20211111_update-go-1.17.3-4e9f65408
image: us.gcr.io/kubernetes-dev/mimir-build-image:import-jsonnet-readme-2418fd778-WIP
credentials:
username: _json_key
password: ${{ secrets.gcr_json_key }}
Expand Down Expand Up @@ -107,7 +114,7 @@ jobs:
build-tools:
runs-on: ubuntu-20.04
container:
image: us.gcr.io/kubernetes-dev/mimir-build-image:20211111_update-go-1.17.3-4e9f65408
image: us.gcr.io/kubernetes-dev/mimir-build-image:import-jsonnet-readme-2418fd778-WIP
credentials:
username: _json_key
password: ${{ secrets.gcr_json_key }}
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ website/content/en/docs
e2e_integration_test*
active-query-tracker
dist/
jsonnet-example/

# Binaries built from ./cmd
/blocksconvert
Expand Down
17 changes: 14 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# WARNING: do not commit to a repository!
-include Makefile.local

.PHONY: all test test-with-race integration-tests cover clean images protos exes dist doc clean-doc check-doc push-multiarch-build-image license check-license format check-mixin check-mixin-jb check-mixin-mixtool checkin-mixin-playbook build-mixin format-mixin check-jsonnet-manifests format-jsonnet-manifests push-multiarch-mimir list-image-targets
.PHONY: all test test-with-race integration-tests cover clean images protos exes dist doc clean-doc check-doc push-multiarch-build-image license check-license format check-mixin check-mixin-jb check-mixin-mixtool checkin-mixin-playbook build-mixin format-mixin check-jsonnet-manifests format-jsonnet-manifests push-multiarch-mimir list-image-targets check-jsonnet-getting-started
.DEFAULT_GOAL := all

# Version number
Expand Down Expand Up @@ -163,7 +163,7 @@ mimir-build-image/$(UPTODATE): mimir-build-image/*
# All the boiler plate for building golang follows:
SUDO := $(shell docker info >/dev/null 2>&1 || echo "sudo -E")
BUILD_IN_CONTAINER := true
LATEST_BUILD_IMAGE_TAG ?= 20211111_update-go-1.17.3-4e9f65408
LATEST_BUILD_IMAGE_TAG ?= import-jsonnet-readme-2418fd778-WIP

# TTY is parameterized to allow Google Cloud Builder to run builds,
# as it currently disallows TTY devices. This value needs to be overridden
Expand Down Expand Up @@ -312,6 +312,7 @@ doc: clean-doc
go run ./tools/doc-generator ./docs/guides/encryption-at-rest.template > ./docs/guides/encryption-at-rest.md
embedmd -w docs/operations/requests-mirroring-to-secondary-cluster.md
embedmd -w docs/guides/overrides-exporter.md
embedmd -w operations/mimir/README.md

# Make up markdown files prettier. When running with check-doc target, it will fail if this produces any change.
prettier --write "**/*.md"
Expand Down Expand Up @@ -361,7 +362,7 @@ clean-doc:
./docs/guides/encryption-at-rest.md

check-doc: doc
@git diff --exit-code -- ./docs/configuration/config-file-reference.md ./docs/blocks-storage/*.md ./docs/configuration/*.md ./operations/mimir-mixin/docs/*.md
@git diff --exit-code -- ./docs/configuration/config-file-reference.md ./docs/blocks-storage/*.md ./docs/configuration/*.md ./operations/mimir/*.md ./operations/mimir-mixin/docs/*.md

clean-white-noise:
@find . -path ./.pkg -prune -o -path ./vendor -prune -o -path ./website -prune -or -type f -name "*.md" -print | \
Expand Down Expand Up @@ -405,6 +406,16 @@ check-jsonnet-manifests: format-jsonnet-manifests
format-jsonnet-manifests:
@find $(JSONNET_MANIFESTS_PATH) -type f -name '*.libsonnet' -print -o -name '*.jsonnet' -print | xargs jsonnetfmt -i

check-jsonnet-getting-started:
# Start from a clean setup.
rm -rf jsonnet-example

# We want to test any change in this branch/PR, so after installing Mimir jsonnet
# we replace it with the current code.
cat ./operations/mimir/getting-started.sh \
| sed 's/\(jb install github.com\/grafana\/mimir\/operations\/mimir@main\)/\1 \&\& rm -fr .\/vendor\/mimir \&\& cp -r ..\/operations\/mimir .\/vendor\/mimir\//g' \
| bash

check-tsdb-blocks-storage-s3-docker-compose-yaml:
cd development/tsdb-blocks-storage-s3 && make check

Expand Down
5 changes: 5 additions & 0 deletions mimir-build-image/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ RUN GOARCH=$(go env GOARCH) && \
chmod +x shfmt && \
mv shfmt /usr/bin

ENV TANKA_VERSION=0.19.0
RUN GOARCH=$(go env GOARCH) && \
curl -fSL -o "/usr/bin/tk" "https://github.com/grafana/tanka/releases/download/v${TANKA_VERSION}/tk-linux-${GOARCH}" && \
chmod a+x /usr/bin/tk

RUN curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s -- -b /usr/bin v1.27.0

RUN GO111MODULE=on \
Expand Down
53 changes: 53 additions & 0 deletions operations/mimir/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Jsonnet for Mimir on Kubernetes

This folder has the jsonnet for deploying Mimir in Kubernetes. To generate the YAMLs for deploying Mimir follow these instructions.

### 1. Make sure you have `tanka` and `jb` installed

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

```console
$ # make sure to be outside of GOPATH or a go.mod project
$ go install github.com/grafana/tanka/cmd/tk@latest
$ go install github.com/jsonnet-bundler/jsonnet-bundler/cmd/jb@latest
```

### 2. Setup Jsonnet project

Initialise the Tanka, install the Mimir and Kubernetes Jsonnet libraries, and setup an environment based on the provided example.

<!-- prettier-ignore-start -->
[embedmd]:# (./getting-started.sh)
```sh
#!/usr/bin/env bash
set -e

# Initialise the Tanka.
mkdir jsonnet-example && cd jsonnet-example
tk init --k8s=1.18

# Install Mimir jsonnet.
jb install github.com/grafana/mimir/operations/mimir@main

# Use the provided example.
cp vendor/mimir/mimir-manifests.jsonnet.example environments/default/main.jsonnet

# Generate the YAML manifests.
export PAGER=cat
tk show environments/default
```
<!-- prettier-ignore-end -->

### 3. Generate the YAML manifests

```console
$ cd jsonnet-example
$ tk show environments/default
```

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

```console
$ cd jsonnet-example
$ tk export manifests environments/default
```
16 changes: 16 additions & 0 deletions operations/mimir/getting-started.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env bash
set -e

# Initialise the Tanka.
mkdir jsonnet-example && cd jsonnet-example
tk init --k8s=1.18

# Install Mimir jsonnet.
jb install github.com/grafana/mimir/operations/mimir@main

# Use the provided example.
cp vendor/mimir/mimir-manifests.jsonnet.example environments/default/main.jsonnet

# Generate the YAML manifests.
export PAGER=cat
tk show environments/default
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
local cortex = import "cortex/cortex.libsonnet";
local mimir = import "mimir/cortex.libsonnet";

cortex {
mimir {
_config+:: {
namespace: "default",
schema: [{
Expand Down