Skip to content

Thanos setup on kind #29

Thanos setup on kind

Thanos setup on kind #29

Workflow file for this run

name: Thanos setup on kind
on:
workflow_dispatch:
env:
kind-image: 'kindest/node:v1.31.0'
kind-version: 'v0.24.0'
jobs:
thanos_test:
# The type of runner that the job will run on
runs-on: ubuntu-20.04
steps:
- name: Start kind cluster
uses: helm/[email protected]
with:
version: ${{ env.kind-version }}
node_image: ${{ env.kind-image }}
wait: 10s
cluster_name: kind
- name: Wait for cluster to bootstrap and setup thanos operator
run: |
kubectl wait --for=condition=Ready pods --all --all-namespaces --timeout=300s
- name: Clone autotune repository
uses: actions/checkout@v3
with:
repository: kruize/autotune
ref: mvp_demo
path: autotune
- name: Install Prometheus
run: |
cd autotune
echo "Installing prometheus..."
./scripts/prometheus_on_kind.sh -as
- name: Setup thanos operator
run: |
#LATEST=$(curl -s https://api.github.com/repos/prometheus-operator/prometheus-operator/releases/latest | jq -cr .tag_name)
#curl -sL https://github.com/prometheus-operator/prometheus-operator/releases/download/${LATEST}/bundle.yaml | kubectl create -f -
git clone https://github.com/thanos-community/thanos-operator.git
cd thanos-operator
echo "***********************************"
echo "Install Thanos CRDS"
echo "***********************************"
make install
kubectl get crds -n thanos-operator
echo "***********************************"
echo "Install Thanos operator"
echo "***********************************"
make deploy IMG="quay.io/thanos/thanos-operator:main-2024-12-24-5e131ef"
kubectl get pods -n thanos-operator-system
echo "***********************************"
echo "Install Thanos components"
echo "***********************************"
make install-example
kubectl get pods -n thanos-operator-system
- name: Create tsdb blocks using thanosbench
run: |
echo "***********************************"
echo "Creating TSDB blocks"
echo "***********************************"
git clone -b kruize_profile https://github.com/chandrams/thanosbench.git
cd thanosbench
make build
maxtime=$(date -u +"%Y-%m-%dT%H:%M:%S.000Z")
echo "${maxtime}"
echo " ./thanosbench block plan -p kruize-1d-tiny --max-time="${maxtime}" | ./thanosbench block gen --workers=20 --output.dir=${GITHUB_WORKSPACE}/tsdb"
./thanosbench block plan -p kruize-1d-tiny --max-time="${maxtime}" | ./thanosbench block gen --workers=20 --output.dir=${GITHUB_WORKSPACE}/tsdb
ls ${GITHUB_WORKSPACE}/tsdb
- name: Copy the tsdb blocks to minio
run: |
kubectl port-forward -n thanos-operator-system svc/thanos-query-frontend-example-query 9090:9090 &
kubectl port-forward -n thanos-operator-system svc/minio 9000:9000 &
ps -ef | grep kubectl
curl https://dl.min.io/client/mc/release/linux-amd64/mc --create-dirs -o ${GITHUB_WORKSPACE}/mc
chmod +x ${GITHUB_WORKSPACE}/mc
export PATH=$PATH:${GITHUB_WORKSPACE}
mc alias set myminio http://localhost:9000 thanos thanos-secret
mc cp -r tsdb/* myminio/thanos
- name: Clone autotune repository
uses: actions/checkout@v3
with:
repository: kruize/autotune
ref: mvp_demo
path: autotune
- name: Deploy kruize with thanos datasource
run: |
cd autotune
echo "Deploying kruize..."
manifest_file="./manifests/crc/default-db-included-installation/minikube/kruize-crc-minikube.yaml"
ds_url="http://127.0.0.1:9090"
sed -i 's/"name": "prometheus-1"/"name": "thanos"/' ${manifest_file}
sed -i 's/"serviceName": "prometheus-k8s"/"serviceName": ""/' ${manifest_file}
sed -i 's/"namespace": "monitoring"/"namespace": ""/' ${manifest_file}
sed -i 's#"url": ""#"url": "'"${ds_url}"'"#' ${manifest_file}
sed -i 's/\([[:space:]]*\)\(storage:\)[[:space:]]*[0-9]\+Mi/\1\2 1Gi/' ${manifest_file}
sed -i 's/\([[:space:]]*\)\(memory:\)[[:space:]]*".*"/\1\2 "2Gi"/; s/\([[:space:]]*\)\(cpu:\)[[:space:]]*".*"/\1\2 "2"/' ${manifest_file}
cat ${manifest_file}
./deploy.sh -c minikube -i quay.io/kruize/autotune_operator:0.3 -m crc
echo "Port forward for kruize"
kubectl port-forward -n monitoring svc/kruize 8080:8080 &
sleep 20
ps -ef | grep port-forward
echo "Creating performance profile..."
curl -s -X POST http://127.0.0.1:8080/createMetricProfile -d @./manifests/autotune/performance-profiles/resource_optimization_local_monitoring.json
echo ""
echo "List Datasources..."
curl POST http://127.0.0.1:8080/datasources
echo ""
echo "Invoking Bulk API..."
curl -s -X POST http://127.0.0.1:8080/bulk -d '{"filter": {"exclude": {"namespace": [], "workload": [], "containers": [], "labels": {}}, "include": {"namespace": [], "workload": [], "containers": [], "labels": {}}}, "datasource": "thanos"}'