Skip to content

Commit

Permalink
Update dev container and add Codespaces docs (thanos-io#6232)
Browse files Browse the repository at this point in the history
Signed-off-by: Samruddhi Khandale <[email protected]>
  • Loading branch information
samruddhikhandale authored Mar 24, 2023
1 parent dead391 commit 527e65d
Show file tree
Hide file tree
Showing 7 changed files with 103 additions and 22 deletions.
16 changes: 16 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# For details, see https://github.com/devcontainers/images/tree/main/src/go
FROM mcr.microsoft.com/devcontainers/go:0-1.20

RUN echo "Downloading prometheus..." \
&& curl -sSL -H "Accept: application/vnd.github.v3+json" "https://api.github.com/repos/prometheus/prometheus/tags" -o /tmp/tags.json \
&& VERSION_LIST="$(jq -r '.[] | select(.name | contains("rc") | not) | .name | split("v") | .[1]' /tmp/tags.json | tr -d '"' | sort -rV)" \
&& PROMETHEUS_LATEST_VERSION="$(echo "${VERSION_LIST}" | head -n 1)" \
&& PROMETHEUS_FILE_NAME="prometheus-${PROMETHEUS_LATEST_VERSION}.linux-amd64" \
&& curl -fsSLO "https://github.com/prometheus/prometheus/releases/download/v${PROMETHEUS_LATEST_VERSION}/${PROMETHEUS_FILE_NAME}.tar.gz" \
&& tar -xzf "${PROMETHEUS_FILE_NAME}.tar.gz" \
&& rm "${PROMETHEUS_FILE_NAME}.tar.gz" \
&& mv ${PROMETHEUS_FILE_NAME}/prometheus /go/bin/
ENV GOPROXY "https://proxy.golang.org"
COPY .devcontainer/welcome-message.txt /usr/local/etc/vscode-dev-containers/first-run-notice.txt
86 changes: 66 additions & 20 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,68 @@
// For more details, see https://aka.ms/devcontainer.json.
{
"name": "Codespaces for Thanos",
"customizations": {
"vscode": {
"settings": {
"go.toolsManagement.checkForUpdates": "local",
"go.useLanguageServer": true,
"go.gopath": "/go"
}
}
},
"extensions": [
"ms-azuretools.vscode-docker",
"ms-kubernetes-tools.vscode-kubernetes-tools",
"davidanson.vscode-markdownlint",
"timonwong.shellcheck",
"docsmsft.docs-yaml",
"Grafana.vscode-jsonnet",
"codezombiech.gitignore",
"golang.Go"
]
"name": "Codespaces for Thanos",
"build": {
"context": "..",
"dockerfile": "Dockerfile"
},

"workspaceFolder": "/go/src/github.com/thanos-io/thanos",
"workspaceMount": "source=${localWorkspaceFolder},target=/go/src/github.com/thanos-io/thanos,type=bind,consistency=cached",

// Features to add to the dev container. More info: https://containers.dev/features.
"features": {
"ghcr.io/devcontainers/features/docker-in-docker:2": {},
"ghcr.io/devcontainers/features/node:1": {},
"ghcr.io/devcontainers/features/kubectl-helm-minikube:1": {}
},

"onCreateCommand": "make build",
"postAttachCommand": {
"Run quickstart": "bash scripts/quickstart.sh"
},

// Use 'forwardPorts' to make a list of ports inside the container available locally.
"forwardPorts": [
1313,
9090,
9091,
9092,
10904,
10914
],
"portsAttributes": {
"1313": {
"label": "Website"
},
"9090": {
"label": "Prometheus Instance 1"
},
"9091": {
"label": "Prometheus Instance 2"
},
"9092": {
"label": "Prometheus Instance 3"
},
"10904": {
"label": "Thanos Query 1"
},
"10914": {
"label": "Thanos Query 2"
}
},

// Configure tool-specific properties.
"customizations": {
"vscode": {
"extensions": [
"ms-azuretools.vscode-docker",
"ms-kubernetes-tools.vscode-kubernetes-tools",
"davidanson.vscode-markdownlint",
"timonwong.shellcheck",
"docsmsft.docs-yaml",
"Grafana.vscode-jsonnet",
"codezombiech.gitignore"
]
}
}
}
10 changes: 10 additions & 0 deletions .devcontainer/welcome-message.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
👋 Welcome to "Thanos" in GitHub Codespaces!

🛠️ Your environment is fully setup with all the required software.

🚀 All the components of Thanos are spinning up with the "quickstart" script, navigate over to the "Ports" tab to access it.

ℹ️ Note: Change the visibility of "Prometheus instances" to "public" so that the API endpoints can be updated.

🔍 To explore VS Code to its fullest, search using the Command Palette (Cmd/Ctrl + Shift + P or F1).

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ kube/.minikube
# Ignore e2e working dirs.
/data/
test/e2e/e2e_*
scripts/data/

# Ignore benchmarks dir.
benchmarks/
Expand Down
3 changes: 3 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ It's key to get familiarized with the style guide and mechanics of Thanos, espec
* Reading the [getting started docs](docs/getting-started.md) and working through them, or alternatively working through the [Thanos tutorial](https://killercoda.com/thanos).
* Familiarizing yourself with our [coding style guidelines.](docs/contributing/coding-style-guide.md).
* Familiarizing yourself with the [Makefile](Makefile) commands, for example `format`, `build`, `proto`, `docker` and `test`. `make help` will print most of available commands with relevant details.
* To get started, create a codespace for this repository by clicking this 👉 [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://github.com/codespaces/new?hide_repo_select=true&ref=main&repo=109162639)
* A codespace will open in a web-based version of Visual Studio Code. The [dev container](.devcontainer/devcontainer.json) is fully configured with software needed for this project.
* **Note**: Dev containers is an open spec which is supported by [GitHub Codespaces](https://github.com/codespaces) and [other tools](https://containers.dev/supporting).
* Spin up a prebuilt dev environment using Gitpod.io [![Gitpod Ready-to-Code](https://img.shields.io/badge/Gitpod-ready--to--code-blue?logo=gitpod)](https://gitpod.io/#https://github.com/thanos-io/thanos)
* In case you want to develop the project locally, install **Golang** in your machine. Here is a nice [gist](https://gist.github.com/nikhita/432436d570b89cab172dcf2894465753) for this purpose.
* You can run an interactive example, which populates some data as well, by following the steps mentioned [here](https://github.com/thanos-io/thanos/blob/main/tutorials/interactive-example/README.md).
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[![Latest Release](https://img.shields.io/github/release/thanos-io/thanos.svg?style=flat-square)](https://github.com/thanos-io/thanos/releases/latest) [![Go Report Card](https://goreportcard.com/badge/github.com/thanos-io/thanos)](https://goreportcard.com/report/github.com/thanos-io/thanos) [![Go Code reference](https://img.shields.io/badge/code%20reference-go.dev-darkblue.svg)](https://pkg.go.dev/github.com/thanos-io/thanos?tab=subdirectories) [![Slack](https://img.shields.io/badge/join%20slack-%23thanos-brightgreen.svg)](https://slack.cncf.io/) [![Netlify Status](https://api.netlify.com/api/v1/badges/664a5091-934c-4b0e-a7b6-bc12f822a590/deploy-status)](https://app.netlify.com/sites/thanos-io/deploys) [![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/3048/badge)](https://bestpractices.coreinfrastructure.org/projects/3048)

[![CI](https://github.com/thanos-io/thanos/workflows/CI/badge.svg)](https://github.com/thanos-io/thanos/actions?query=workflow%3ACI) [![CI](https://circleci.com/gh/thanos-io/thanos.svg?style=svg)](https://circleci.com/gh/thanos-io/thanos) [![go](https://github.com/thanos-io/thanos/workflows/go/badge.svg)](https://github.com/thanos-io/thanos/actions?query=workflow%3Ago) [![react](https://github.com/thanos-io/thanos/workflows/react/badge.svg)](https://github.com/thanos-io/thanos/actions?query=workflow%3Areact) [![docs](https://github.com/thanos-io/thanos/workflows/docs/badge.svg)](https://github.com/thanos-io/thanos/actions?query=workflow%3Adocs) [![Gitpod ready-to-code](https://img.shields.io/badge/Gitpod-ready--to--code-blue?logo=gitpod)](https://gitpod.io/#https://github.com/thanos-io/thanos)
[![CI](https://github.com/thanos-io/thanos/workflows/CI/badge.svg)](https://github.com/thanos-io/thanos/actions?query=workflow%3ACI) [![CI](https://circleci.com/gh/thanos-io/thanos.svg?style=svg)](https://circleci.com/gh/thanos-io/thanos) [![go](https://github.com/thanos-io/thanos/workflows/go/badge.svg)](https://github.com/thanos-io/thanos/actions?query=workflow%3Ago) [![react](https://github.com/thanos-io/thanos/workflows/react/badge.svg)](https://github.com/thanos-io/thanos/actions?query=workflow%3Areact) [![docs](https://github.com/thanos-io/thanos/workflows/docs/badge.svg)](https://github.com/thanos-io/thanos/actions?query=workflow%3Adocs) [![Gitpod ready-to-code](https://img.shields.io/badge/Gitpod-ready--to--code-blue?logo=gitpod)](https://gitpod.io/#https://github.com/thanos-io/thanos) [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://github.com/codespaces/new?hide_repo_select=true&ref=main&repo=109162639)

## Overview

Expand Down
7 changes: 6 additions & 1 deletion scripts/quickstart.sh
Original file line number Diff line number Diff line change
Expand Up @@ -147,14 +147,19 @@ fi

# Start one sidecar for each Prometheus server.
for i in $(seq 0 2); do
if [ -z ${CODESPACE_NAME+x} ]; then
PROMETHEUS_URL="http://localhost:909${i}"
else
PROMETHEUS_URL="https://${CODESPACE_NAME}-909${i}.${GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN}"
fi
${THANOS_EXECUTABLE} sidecar \
--debug.name sidecar-"${i}" \
--log.level debug \
--grpc-address 0.0.0.0:109"${i}"1 \
--grpc-grace-period 1s \
--http-address 0.0.0.0:109"${i}"2 \
--http-grace-period 1s \
--prometheus.url http://localhost:909"${i}" \
--prometheus.url "${PROMETHEUS_URL}" \
--tsdb.path data/prom"${i}" \
${OBJSTORECFG} &

Expand Down

0 comments on commit 527e65d

Please sign in to comment.