-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable Druid to use mock GCS server to run e2e tests
* Create gcp secret to use emulator for druid local setup * Add documentation for usage of fake-gcs-server for e2e tests * Add documentation to setup etcd-druid locally using fake-gcs-server
- Loading branch information
1 parent
b43756b
commit 2bdf09f
Showing
16 changed files
with
328 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
apiVersion: druid.gardener.cloud/v1alpha1 | ||
kind: Etcd | ||
metadata: | ||
name: etcd-test | ||
labels: | ||
app: etcd-statefulset | ||
gardener.cloud/role: controlplane | ||
role: test | ||
spec: | ||
selector: | ||
matchLabels: | ||
app: etcd-statefulset | ||
gardener.cloud/role: controlplane | ||
role: test | ||
annotations: | ||
app: etcd-statefulset | ||
gardener.cloud/role: controlplane | ||
# networking.gardener.cloud/to-dns: allowed | ||
# networking.gardener.cloud/to-private-networks: allowed | ||
# networking.gardener.cloud/to-public-networks: allowed | ||
role: test | ||
labels: | ||
app: etcd-statefulset | ||
gardener.cloud/role: controlplane | ||
# networking.gardener.cloud/to-dns: allowed | ||
# networking.gardener.cloud/to-private-networks: allowed | ||
# networking.gardener.cloud/to-public-networks: allowed | ||
role: test | ||
etcd: | ||
metrics: basic | ||
defragmentationSchedule: "0 */24 * * *" | ||
resources: | ||
limits: { cpu: 500m, memory: 1Gi } | ||
requests: { cpu: 100m, memory: 200Mi } | ||
clientPort: 2379 | ||
serverPort: 2380 | ||
quota: 8Gi | ||
# heartbeatDuration: 10s | ||
backup: | ||
port: 8080 | ||
fullSnapshotSchedule: "0 */24 * * *" | ||
resources: | ||
limits: { cpu: 200m, memory: 1Gi } | ||
requests: { cpu: 23m, memory: 128Mi } | ||
garbageCollectionPolicy: Exponential | ||
garbageCollectionPeriod: 43200s | ||
deltaSnapshotPeriod: 300s | ||
deltaSnapshotMemoryLimit: 1Gi | ||
store: | ||
container: etcd-bucket | ||
prefix: etcd-test | ||
provider: gcp | ||
secretRef: | ||
name: etcd-backup-gcp | ||
compression: | ||
enabled: false | ||
policy: "gzip" | ||
leaderElection: | ||
reelectionPeriod: 5s | ||
etcdConnectionTimeout: 5s | ||
|
||
sharedConfig: | ||
autoCompactionMode: periodic | ||
autoCompactionRetention: "30m" | ||
# schedulingConstraints: | ||
# affinity: {} | ||
# topologySpreadConstraints: | ||
# - maxSkew: 1 | ||
# topologyKey: topology.kubernetes.io/zone | ||
# whenUnsatisfiable: DoNotSchedule | ||
# labelSelector: | ||
# matchLabels: | ||
# app: etcd-statefulset | ||
|
||
replicas: 3 | ||
# priorityClassName: priority-class-name | ||
# storageClass: default | ||
# storageCapacity: 10Gi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
apiVersion: v1 | ||
data: | ||
bucketName: ZXRjZC1idWNrZXQ= | ||
serviceaccount.json: ZHVtbXk= #dummy | ||
storageAPIEndpoint: aHR0cDovL2Zha2UtZ2NzLmRlZmF1bHQ6ODAwMC9zdG9yYWdlL3YxLw== #http://fake-gcs.default:8000/storage/v1/ | ||
emulatorEnabled: dHJ1ZQ== #true | ||
kind: Secret | ||
metadata: | ||
labels: | ||
app: etcd-statefulset | ||
name: etcd-backup-gcp | ||
type: Opaque |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
docs/deployment/getting-started-locally/manage-gcs-emulator.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# Manage GCS Emulator | ||
|
||
This document is a step-by-step guide on how to configure, deploy and cleanup [GCS Emulator](https://github.com/fsouza/fake-gcs-server), within a [kind](https://kind.sigs.k8s.io/) cluster. GCS Emulator emulates Google Cloud Storage locally, which allows the `Etcd` cluster to interact with GCS. This setup is ideal for local development and testing. | ||
|
||
## 00-Prerequisites | ||
|
||
Ensure that you have setup the development environment as per the [documentation](../../development/prepare-dev-environment.md). | ||
|
||
> **Note:** It is assumed that you have already created kind cluster and the `KUBECONFIG` is pointing to this Kubernetes cluster. | ||
### Installing gsutil | ||
|
||
To interact with `GCS Emulator` you must also install the [gsutil](https://cloud.google.com/storage/docs/gsutil) utility. Follow the instructions [here](https://cloud.google.com/storage/docs/gsutil_install) to install `gsutil`. | ||
|
||
## 01-Deploy FakeGCS | ||
|
||
Deploy FakeGCS onto the Kubernetes cluster using the command below: | ||
|
||
```bash | ||
make deploy-fakegcs | ||
``` | ||
|
||
## 02-Setup GCS Bucket | ||
|
||
To create a GCS bucket for `Etcd` backup purposes, execute the following command: | ||
|
||
```bash | ||
gsutil -o "Credentials:gs_json_host=127.0.0.1" -o "Credentials:gs_json_port=4443" -o "Boto:https_validate_certificates=False" mb "gs://etcd-bucket" | ||
``` | ||
|
||
## 03-Configure Secret | ||
|
||
Connection details for a GCS Object Store are put into a Kubernetes [Secret](https://kubernetes.io/docs/concepts/configuration/secret/). Apply the Kubernetes Secret manifest through: | ||
|
||
```bash | ||
kubectl apply -f config/samples/etcd-secret-fakegcs.yaml | ||
``` | ||
|
||
> **Note:** The secret created should be referred to in the `Etcd` CR in `spec.backup.store.secretRef`. | ||
## 04-Cleanup | ||
|
||
To clean the setup, execute the following commands: | ||
|
||
```bash | ||
make kind-down | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/usr/bin/env bash | ||
# SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and Gardener contributors | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
set -o errexit | ||
set -o nounset | ||
set -o pipefail | ||
|
||
make kind-up | ||
|
||
trap '{ | ||
kind export logs "${ARTIFACTS:-/tmp}/etcd-druid-e2e" --name etcd-druid-e2e || true | ||
make kind-down | ||
}' EXIT | ||
|
||
kubectl wait --for=condition=ready node --all | ||
echo "{ \"serviceaccount.json\": \"\", \"storageAPIEndpoint\": \"http://fake-gcs.default:8000/storage/v1/\", \"emulatorEnabled\": \"true\" }" >/tmp/svc_acc.json | ||
|
||
export GOOGLE_STORAGE_API_ENDPOINT="http://localhost:8000/storage/v1/" | ||
|
||
# Deploy fake-gcs and run e2e tests | ||
make deploy-fakegcs | ||
make GCP_SERVICEACCOUNT_JSON_PATH="/tmp/svc_acc.json" \ | ||
GCP_PROJECT_ID="e2e-test" \ | ||
GOOGLE_EMULATOR_ENABLED="true" \ | ||
FAKEGCS_HOST="fake-gcs.default:8000" \ | ||
PROVIDERS="gcp" \ | ||
TEST_ID="$BUCKET_NAME" \ | ||
STEPS="setup,deploy,test" \ | ||
test-e2e |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/usr/bin/env bash | ||
# SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and Gardener contributors | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
set -o errexit | ||
set -o nounset | ||
set -o pipefail | ||
|
||
kubectl apply -f ./hack/e2e-test/infrastructure/fake-gcs-server/fake-gcs-server.yaml | ||
kubectl rollout status deploy/fake-gcs | ||
kubectl wait --for=condition=ready pod -l app=fake-gcs --timeout=240s |
Oops, something went wrong.