-
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.
Simplify
Localstack
setup by utilizing S3 endpoint support (#713)
- Loading branch information
1 parent
227c876
commit ac3e156
Showing
7 changed files
with
190 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: S3 | ||
secretRef: | ||
name: etcd-backup-aws | ||
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,15 @@ | ||
apiVersion: v1 | ||
data: | ||
accessKeyID: QUNDRVNTS0VZQVdTVVNFUg== | ||
bucketName: ZXRjZC1idWNrZXQK | ||
endpoint: aHR0cDovL2xvY2Fsc3RhY2suZGVmYXVsdDo0NTY2 | ||
region: dXMtZWFzdC0y | ||
s3ForcePathStyle: dHJ1ZQ== | ||
secretAccessKey: c0VjcmVUS2V5 | ||
kind: Secret | ||
metadata: | ||
labels: | ||
garden.sapcloud.io/role: controlplane | ||
role: main | ||
name: etcd-backup-aws | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
# Getting Started with etcd-druid, LocalStack, and Kind | ||
|
||
This guide provides step-by-step instructions on how to set up etcd-druid with [LocalStack](https://localstack.cloud/) and Kind on your local machine. LocalStack emulates AWS services locally, which allows the etcd cluster to interact with AWS S3 without the need for an actual AWS connection. This setup is ideal for local development and testing. | ||
|
||
## Prerequisites | ||
|
||
- Docker (installed and running) | ||
- AWS CLI (version `>=1.29.0` or `>=2.13.0`) | ||
|
||
## Environment Setup | ||
|
||
### Step 1: Provision the Kind Cluster | ||
|
||
Execute the command below to provision a `kind` cluster. This command also forwards port `4566` from the [kind cluster](hack/e2e-test/infrastructure/kind/cluster.yaml) to your local machine, enabling LocalStack access: | ||
|
||
```bash | ||
make kind-up | ||
``` | ||
|
||
### Step 2: Deploy LocalStack | ||
|
||
Deploy LocalStack onto the Kubernetes cluster using the command below: | ||
|
||
```bash | ||
make deploy-localstack | ||
``` | ||
|
||
### Step 3: Set up an S3 Bucket | ||
|
||
1. Set up the AWS CLI to interact with LocalStack by setting the necessary environment variables. This configuration redirects S3 commands to the LocalStack endpoint and provides the required credentials for authentication: | ||
|
||
```bash | ||
export AWS_ENDPOINT_URL_S3="http://localhost:4566" | ||
export AWS_ACCESS_KEY_ID=ACCESSKEYAWSUSER | ||
export AWS_SECRET_ACCESS_KEY=sEcreTKey | ||
export AWS_DEFAULT_REGION=us-east-2 | ||
``` | ||
|
||
2. Create an S3 bucket for etcd-druid backup purposes: | ||
|
||
```bash | ||
aws s3api create-bucket --bucket etcd-bucket --region us-east-2 --create-bucket-configuration LocationConstraint=us-east-2 --acl private | ||
``` | ||
|
||
### Step 4: Deploy etcd-druid | ||
|
||
Deploy etcd-druid onto the Kind cluster using the command below: | ||
|
||
```bash | ||
make deploy | ||
``` | ||
|
||
### Step 5: Configure etcd with LocalStack Store | ||
|
||
Apply the required Kubernetes manifests to create an etcd custom resource (CR) and a secret for AWS credentials, facilitating LocalStack access: | ||
|
||
```bash | ||
export KUBECONFIG=hack/e2e-test/infrastructure/kind/kubeconfig | ||
kubectl apply -f config/samples/druid_v1alpha1_etcd_localstack.yaml -f config/samples/etcd-secret-localstack.yaml | ||
``` | ||
|
||
### Step 6: Reconcile the etcd | ||
|
||
Initiate etcd reconciliation by annotating the etcd resource with the `gardener.cloud/operation=reconcile` annotation: | ||
|
||
```bash | ||
kubectl annotate etcd etcd-test gardener.cloud/operation=reconcile | ||
``` | ||
|
||
Congratulations! You have successfully configured `etcd-druid`, `LocalStack`, and `kind` on your local machine. Inspect the etcd-druid logs and LocalStack to ensure the setup operates as anticipated. | ||
|
||
To validate the buckets, execute the following command: | ||
|
||
```bash | ||
aws s3 ls etcd-bucket/etcd-test/v2/ | ||
``` | ||
|
||
### Cleanup | ||
|
||
To dismantle the setup, execute the following command: | ||
|
||
```bash | ||
make kind-down | ||
unset AWS_ENDPOINT_URL_S3 AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY AWS_DEFAULT_REGION KUBECONFIG | ||
|
||
``` |
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
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