Skip to content

Commit

Permalink
1. Added key.yml
Browse files Browse the repository at this point in the history
2. changed upload-download function to extract key
3. updated bash.sh file

Signed-off-by: Kushal Shukla <[email protected]>
  • Loading branch information
kushalShukla-web committed Nov 3, 2024
1 parent d01a5d7 commit 44ff81c
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 272 deletions.
16 changes: 16 additions & 0 deletions prombench/manifests/prombench/benchmark/2a_prometheus-secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: v1
kind: Secret
metadata:
name: s3-secret
namespace: prombench-{{ .PR_NUMBER }} # Replace with your actual namespace
type: Opaque
stringData:
object-config.yml: |
type: S3
config:
bucket: {{ .BUCKET_KEY }}
endpoint: minio:9000
access_key: {{ .ACCESS_KEY }}
secret_key: {{ .SECRET_KEY }}
insecure: true
Original file line number Diff line number Diff line change
Expand Up @@ -44,25 +44,34 @@ spec:
- name: GITHUB_ORG
value: "{{ .GITHUB_ORG }}"
- name: GITHUB_REPO
value: "{{ .GITHUB_REPO }}"
value: "{{ .GITHUB_REPO }}"
volumeMounts:
- name: prometheus-executable
mountPath: /prometheus-builder
- name: config
mountPath: /config
- name: key
mountPath: /config
- name: data-downloader
image: kushalshukla/writer
imagePullPolicy: Always
imagePullPolicy: Always
env:
- name: ACCESS_KEY
value: "{{ .ACCESS_KEY }}"
- name: SECRET_KEY
value: "{{ .SECRET_KEY }}"
- name: BUCKET_KEY
value: "{{ .BUCKET_KEY }}"
volumeMounts:
- name: instance-ssd
mountPath: /data
- name: config
mountPath: /mnc
- name: s3-config
mountPath: /config
- name: key
mountPath: /key
args: [
"download",
"--tsdb-path=/data",
"--objstore.config-file=/mnc/objectconfig.yml",
"--key=gendata"
"--objstore.config-file=/config/object-config.yml",
"--key=/key/key.yml"
]
containers:
- name: prometheus
Expand Down Expand Up @@ -104,9 +113,11 @@ spec:
path: /mnt/disks/ssd0 #gke ssds
- name: prometheus-executable
emptyDir: {}
- name: config
hostPath:
path: /config-file
- name: s3-config # Define the Secret volume
secret:
secretName: s3-secret
- name: key
emptyDir: {}
terminationGracePeriodSeconds: 300
nodeSelector:
node-name: prometheus-{{ .PR_NUMBER }}
Expand Down Expand Up @@ -175,30 +186,41 @@ spec:
cd /repo1 && \
git fetch origin pull/{{ .PR_NUMBER }}/head:pr-branch && \
git checkout pr-branch && \
cp objectconfig.yml /mnt/repo/objectconfig.yml && \
cp key.yml /config/key.yml && \
rm -rf /repo1
volumeMounts:
- name: config
mountPath: /mnt/repo
- name: key
mountPath: /config
- name: data-downloader
image: kushalshukla/writer
imagePullPolicy: Always
imagePullPolicy: Always
env:
- name: ACCESS_KEY
value: "{{ .ACCESS_KEY }}"
- name: SECRET_KEY
value: "{{ .SECRET_KEY }}"
- name: BUCKET_KEY
value: "{{ .BUCKET_KEY }}"
volumeMounts:
- name: instance-ssd
mountPath: /data
- name: config
mountPath: /mnc
mountPath: /mnc
- name: s3-config
mountPath: /config
- name: key
mountPath: /key
args: [
"download",
"--tsdb-path=/data",
"--objstore.config-file=/mnc/objectconfig.yml",
"--key=gendata"
"--objstore.config-file=/config/object-config.yml",
"--key=/key/key.yml"
]
containers:
- name: prometheus
image: quay.io/prometheus/prometheus:{{ .RELEASE }}
imagePullPolicy: Always
command: [ "/bin/prometheus"]
command: [ "/bin/prometheus" ]
args: [
"--web.external-url=http://{{ .DOMAIN_NAME }}/{{ .PR_NUMBER }}/prometheus-release",
"--storage.tsdb.path=/prometheus",
Expand All @@ -224,7 +246,12 @@ spec:
path: /mnt/disks/ssd0
- name: config
hostPath:
path: /object-config
path: /object-config
- name: s3-config # Define the Secret volume
secret:
secretName: s3-secret
- name: key
emptyDir: {}
terminationGracePeriodSeconds: 300
nodeSelector:
node-name: prometheus-{{ .PR_NUMBER }}
Expand Down
4 changes: 2 additions & 2 deletions tools/block-sync/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ The `download` command allows you to retrieve TSDB data from an object storage b
The configuration file is essential for connecting to your object storage solution. Below are basic templates for different object storage systems.

```yaml
type: s3
type: s3, GCS , AZURE , etc.
config:
bucket: your-bucket-name
endpoint: https://your-minio-endpoint.com
endpoint: https://your-endpoint
access_key: your-access-key
secret_key: your-secret-key
insecure: false # Set to true if using HTTP instead of HTTPS
Expand Down
17 changes: 16 additions & 1 deletion tools/block-sync/upload_download.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"fmt"
"log/slog"
"os"
"strings"

"github.com/go-kit/log"
"github.com/thanos-io/objstore"
Expand All @@ -42,10 +43,24 @@ func newStore(tsdbPath, objectConfig, objectKey string, logger *slog.Logger) (*S
if err != nil {
return nil, fmt.Errorf("failed to create bucket existence:%w", err)
}
key, err := os.ReadFile(objectKey)
if err != nil {
return nil, fmt.Errorf("failed to read objectKey file: %w", err)
}

content := strings.TrimSpace(string(key))
var value string
if strings.HasPrefix(content, "key:") {
value = strings.TrimSpace(strings.TrimPrefix(content, "key:"))
fmt.Println(value)
} else {
fmt.Println("Expected 'key:' prefix not found")
}

return &Store{
bucket: bucket,
tsdbpath: tsdbPath,
objectkey: objectKey,
objectkey: value,
objectconfig: objectConfig,
bucketlogger: logger,
}, nil
Expand Down
Loading

0 comments on commit 44ff81c

Please sign in to comment.