From 7e1ac51b580afa8e900206e7cc49791ed0a00d94 Mon Sep 17 00:00:00 2001 From: Quentin Dufour Date: Tue, 5 Apr 2022 15:04:27 +0200 Subject: [PATCH 1/2] Add files to quickly test k8s --- script/k8s/README.md | 13 +++++++++++ script/k8s/admin.yaml | 12 ++++++++++ script/k8s/config.yaml | 30 ++++++++++++++++++++++++ script/k8s/daemon.yaml | 52 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 107 insertions(+) create mode 100644 script/k8s/README.md create mode 100644 script/k8s/admin.yaml create mode 100644 script/k8s/config.yaml create mode 100644 script/k8s/daemon.yaml diff --git a/script/k8s/README.md b/script/k8s/README.md new file mode 100644 index 00000000..4231d3aa --- /dev/null +++ b/script/k8s/README.md @@ -0,0 +1,13 @@ +Spawn a cluster with minikube + +```bash +minikube start +minikube kubectl -- apply -f config.yaml +minikube kubectl -- apply -f daemon.yaml +minikube dashboard + +minikube kubectl -- exec -it garage-0 --container garage -- /garage status +# etc. +``` + + diff --git a/script/k8s/admin.yaml b/script/k8s/admin.yaml new file mode 100644 index 00000000..af8b54d5 --- /dev/null +++ b/script/k8s/admin.yaml @@ -0,0 +1,12 @@ +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + name: garage-admin +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: cluster-admin +subjects: +- apiGroup: rbac.authorization.k8s.io + kind: User + name: system:serviceaccount:default:default diff --git a/script/k8s/config.yaml b/script/k8s/config.yaml new file mode 100644 index 00000000..8cf40fc2 --- /dev/null +++ b/script/k8s/config.yaml @@ -0,0 +1,30 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: garage-config + namespace: default +data: + garage.toml: |- + metadata_dir = "/tmp/meta" + data_dir = "/tmp/data" + + replication_mode = "3" + + rpc_bind_addr = "[::]:3901" + rpc_secret = "1799bccfd7411eddcf9ebd316bc1f5287ad12a68094e1c6ac6abde7e6feae1ec" + + bootstrap_peers = [] + + kubernetes_namespace = "default" + kubernetes_service_name = "garage-daemon" + kubernetes_skip_crd = false + + [s3_api] + s3_region = "garage" + api_bind_addr = "[::]:3900" + root_domain = ".s3.garage.tld" + + [s3_web] + bind_addr = "[::]:3902" + root_domain = ".web.garage.tld" + index = "index.html" diff --git a/script/k8s/daemon.yaml b/script/k8s/daemon.yaml new file mode 100644 index 00000000..fedc46e0 --- /dev/null +++ b/script/k8s/daemon.yaml @@ -0,0 +1,52 @@ +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: garage +spec: + selector: + matchLabels: + app: garage + serviceName: "garage" + replicas: 3 + template: + metadata: + labels: + app: garage + spec: + terminationGracePeriodSeconds: 10 + containers: + - name: garage + image: dxflrs/amd64_garage:v0.7.0-rc1 + ports: + - containerPort: 3900 + name: s3-api + - containerPort: 3902 + name: web-api + volumeMounts: + - name: fast + mountPath: /mnt/fast + - name: slow + mountPath: /mnt/slow + - name: etc + mountPath: /etc/garage.toml + subPath: garage.toml + volumes: + - name: etc + configMap: + name: garage-config + volumeClaimTemplates: + - metadata: + name: fast + spec: + accessModes: [ "ReadWriteOnce" ] + resources: + requests: + storage: 100Mi + - metadata: + name: slow + spec: + accessModes: [ "ReadWriteOnce" ] + resources: + requests: + storage: 100Mi + -- 2.43.4 From 62f0715abe995e7ce8de1adbd62b67f7159a9945 Mon Sep 17 00:00:00 2001 From: Quentin Dufour Date: Wed, 6 Apr 2022 14:10:18 +0200 Subject: [PATCH 2/2] Add/Fix OpenTelemetry --- script/telemetry/README.md | 21 +++++++++++++++++++ .../provisioning/datasources/elastic.yaml | 7 +++---- script/telemetry/elastic/otel-config.yaml | 2 +- 3 files changed, 25 insertions(+), 5 deletions(-) create mode 100644 script/telemetry/README.md diff --git a/script/telemetry/README.md b/script/telemetry/README.md new file mode 100644 index 00000000..3b403454 --- /dev/null +++ b/script/telemetry/README.md @@ -0,0 +1,21 @@ +Configure your `[admin-api]` endpoint: + +``` +[admin] +api_bind_addr = "0.0.0.0:3903" +trace_sink = "http://localhost:4317" +``` + +Start the test stack: + +``` +cd telemetry +docker-compose up +``` + +Access the web interfaces: + - [Kibana](http://localhost:5601) - Click on the hamburger menu, in the Observability section, click APM + - [Grafana](http://localhost:3000) - Set a password, then on the left menu, click Dashboard -> Browse. On the new page click Import -> Choose the test dashboard we ship `grafana-garage-dashboard-elasticsearch.json` + + + diff --git a/script/telemetry/elastic/grafana/provisioning/datasources/elastic.yaml b/script/telemetry/elastic/grafana/provisioning/datasources/elastic.yaml index e46e7ac9..bcb96b95 100644 --- a/script/telemetry/elastic/grafana/provisioning/datasources/elastic.yaml +++ b/script/telemetry/elastic/grafana/provisioning/datasources/elastic.yaml @@ -4,17 +4,16 @@ datasources: - name: DS_ELASTICSEARCH type: elasticsearch access: proxy - url: http://elastic:9700 + url: http://localhost:9200 password: '' user: '' - database: metricbeat-* + database: apm-* basicAuth: false isDefault: true jsonData: - esVersion: 70 + esVersion: 7.10.0 logLevelField: '' logMessageField: '' maxConcurrentShardRequests: 5 timeField: "@timestamp" - timeInterval: 10s readOnly: false diff --git a/script/telemetry/elastic/otel-config.yaml b/script/telemetry/elastic/otel-config.yaml index cd119f0a..51ff3f5d 100644 --- a/script/telemetry/elastic/otel-config.yaml +++ b/script/telemetry/elastic/otel-config.yaml @@ -13,7 +13,7 @@ receivers: - job_name: "garage" scrape_interval: 5s static_configs: - - targets: ["localhost:3909"] + - targets: ["localhost:3903"] exporters: logging: -- 2.43.4