-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Gossip KV): Cleanup Local and AWS Deployments (#1545)
Closes #1529 (P0), #1528 (P1). Summary of changes: 1. Local Deployments use Terraform. 2. Both Local / AWS Terraform projects have been split into separate "infra" and "application" sections because there are intervening steps (building images, etc.) that need to be done before applications can be deployed. 3. Independent documentation for each local/AWS deployment - should make it less confusing because these are expected to diverge.
- Loading branch information
1 parent
656ee32
commit 33c2de2
Showing
25 changed files
with
1,468 additions
and
250 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,76 @@ | ||
INFRA_PATH=./terraform/infra | ||
APPLICATION_PATH=./terraform/application | ||
|
||
BASE_IMAGE_VERSION:=latest | ||
SERVER_IMAGE_VERSION:=latest | ||
CLI_IMAGE_VERSION:=latest | ||
LOAD_TEST_IMAGE_VERSION:=latest | ||
|
||
# Docker Image Tags | ||
BASE_IMAGE_TAG:=hydroflow-gossip-kv-base-image:$(BASE_IMAGE_VERSION) | ||
SERVER_IMAGE_TAG:=hydroflow-gossip-kv-server:$(SERVER_IMAGE_VERSION) | ||
CLI_IMAGE_TAG:=hydroflow-gossip-kv-cli:$(CLI_IMAGE_VERSION) | ||
LOAD_TEST_IMAGE_TAG:=hydroflow-gossip-kv-load-test:$(LOAD_TEST_IMAGE_VERSION) | ||
|
||
.PHONY : init infra docker_images base_image server_image cli_image upload_docker_images application config clean | ||
|
||
init: | ||
terraform -chdir="$(INFRA_PATH)" init | ||
terraform -chdir="$(APPLICATION_PATH)" init | ||
|
||
infra: | ||
terraform -chdir="$(INFRA_PATH)" apply -auto-approve | ||
|
||
kubectl_setup: | ||
@echo "Setting up kubectl to work with AWS EKS Cluster" | ||
aws eks update-kubeconfig --region $$(terraform -chdir=$(INFRA_PATH) output -raw region) --name $$(terraform -chdir=$(INFRA_PATH) output -raw cluster_name) | ||
|
||
docker_images: base_image server_image cli_image | ||
|
||
base_image: | ||
docker build -t "$(BASE_IMAGE_TAG)" -f ../../../../datastores/gossip_kv/server/baseimage.Dockerfile ../../../.. | ||
|
||
server_image: | ||
docker build -t "$(SERVER_IMAGE_TAG)" -f ../../../../datastores/gossip_kv/server/Dockerfile ../../../.. | ||
|
||
cli_image: | ||
docker build -t "$(CLI_IMAGE_TAG)" -f ../../../../datastores/gossip_kv/cli/Dockerfile ../../../.. | ||
|
||
upload_docker_images: docker_images | ||
$(eval SERVER_REPO_URL := $(shell terraform -chdir=$(INFRA_PATH) output -json repository_urls | jq -r '.["gossip_kv_server"]')) | ||
$(eval CLI_REPO_URL := $(shell terraform -chdir=$(INFRA_PATH) output -json repository_urls | jq -r '.["gossip_kv_cli"]')) | ||
$(eval LOAD_TEST_REPO_URL := $(shell terraform -chdir=$(INFRA_PATH) output -json repository_urls | jq -r '.["gossip_kv_load_test"]')) | ||
$(eval REGION := $(shell terraform -chdir=$(INFRA_PATH) output -raw region)) | ||
echo $(SERVER_REPO_URL) | ||
docker tag $(SERVER_IMAGE_TAG) $(SERVER_REPO_URL):$(SERVER_IMAGE_VERSION) | ||
docker tag $(CLI_IMAGE_TAG) $(CLI_REPO_URL):$(CLI_IMAGE_VERSION) | ||
docker tag $(LOAD_TEST_IMAGE_TAG) $(LOAD_TEST_REPO_URL):$(LOAD_TEST_IMAGE_VERSION) | ||
aws ecr get-login-password --region $(REGION) | docker login --username AWS --password-stdin $(SERVER_REPO_URL) | ||
docker push $(SERVER_REPO_URL):$(SERVER_IMAGE_VERSION) | ||
aws ecr get-login-password --region $(REGION) | docker login --username AWS --password-stdin $(CLI_REPO_URL) | ||
docker push $(CLI_REPO_URL):$(CLI_IMAGE_VERSION) | ||
aws ecr get-login-password --region $(REGION) | docker login --username AWS --password-stdin $(LOAD_TEST_REPO_URL) | ||
docker push $(LOAD_TEST_REPO_URL):$(LOAD_TEST_IMAGE_VERSION) | ||
|
||
application: | ||
terraform -chdir="$(APPLICATION_PATH)" apply -auto-approve | ||
|
||
tunnel_grafana: | ||
$(eval GRAFANA_PORT := $(shell terraform -chdir=$(APPLICATION_PATH) output -raw grafana_port)) | ||
@echo "Grafana will be accessible at http://localhost:$(GRAFANA_PORT)" | ||
kubectl port-forward svc/grafana $(GRAFANA_PORT):$(GRAFANA_PORT) | ||
|
||
tunnel_prometheus: | ||
$(eval PROMETHEUS_PORT := $(shell terraform -chdir=$(APPLICATION_PATH) output -raw prometheus_port)) | ||
@echo "Prometheus will be accessible at http://localhost:$(PROMETHEUS_PORT)" | ||
kubectl port-forward svc/prometheus $(PROMETHEUS_PORT):$(PROMETHEUS_PORT) | ||
|
||
|
||
config: | ||
kubectl apply -f seed_node_config.yaml | ||
|
||
clean: | ||
terraform -chdir="$(APPLICATION_PATH)" destroy -auto-approve | ||
terraform -chdir="$(INFRA_PATH)" destroy -auto-approve | ||
rm -rf $(INFRA_PATH)/.terraform $(INFRA_PATH)/terraform.tfstate $(INFRA_PATH)/terraform.tfstate.backup | ||
rm -rf $(APPLICATION_PATH)/.terraform $(APPLICATION_PATH)/terraform.tfstate $(APPLICATION_PATH)/terraform.tfstate.backup |
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,89 @@ | ||
# AWS Deployment | ||
|
||
## Pre-requisites | ||
- [Terraform](https://learn.hashicorp.com/tutorials/terraform/install-cli) | ||
- [AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-install.html) | ||
- [Docker](https://docs.docker.com/get-docker/) | ||
- [Kubectl](https://kubernetes.io/docs/tasks/tools/install-kubectl/) | ||
- [Make](https://www.gnu.org/software/make/) | ||
- [k9s](https://k9scli.io/) | ||
|
||
### Mac Setup Using Homebrew | ||
```shell | ||
brew install terraform | ||
brew install awscli | ||
brew install docker | ||
brew install kubernetes-cli | ||
brew install k9s | ||
``` | ||
|
||
## Initialize Setup | ||
Initializes terraform providers required for local deployment. | ||
```shell | ||
make init | ||
``` | ||
|
||
## Configure AWS Credentials | ||
Make sure you have the AWS credentials configured. Subsequent terraform commands will use these credentials to create | ||
the infrastructure. | ||
```shell | ||
aws configure | ||
``` | ||
|
||
## Create Infrastructure | ||
Creates a local kubernetes cluster using minikube. | ||
|
||
```shell | ||
make infra | ||
``` | ||
|
||
## Kubectl | ||
To enable kubectl usage with the newly created AWS EKS cluster, use the following command. | ||
|
||
```shell | ||
make kubectl_setup | ||
``` | ||
|
||
## K9s | ||
To monitor the cluster using k9s, use the following command. | ||
|
||
```shell | ||
k9s | ||
``` | ||
|
||
## Build & Upload Docker Image | ||
Build and upload the docker image for the application, into ECR. | ||
```shell | ||
make upload_docker_images | ||
``` | ||
|
||
## Create Application | ||
```shell | ||
make application | ||
``` | ||
|
||
## Check if the application is running | ||
```shell | ||
kubectl get pods # All gossip-kv-* pods should show status as "Running" | ||
```` | ||
|
||
## Access Grafana Dashboards | ||
```shell | ||
make tunnel_grafana | ||
``` | ||
|
||
## Access Prometheus | ||
```shell | ||
make tunnel_prometheus | ||
``` | ||
|
||
## Update seed node configuration | ||
```shell | ||
make config | ||
``` | ||
|
||
## Clean | ||
Destroys the AWS resources and cleans up terraform state. | ||
```shell | ||
make clean | ||
``` |
File renamed without changes.
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 |
---|---|---|
@@ -1 +1,30 @@ | ||
.terraform | ||
### TERRAFORM IGNORES ### | ||
# Terraform Plugin and module directories | ||
**/.terraform/* | ||
|
||
# .tfstate files | ||
*.tfstate | ||
*.tfstate.* | ||
|
||
# Crash log files | ||
crash.log | ||
crash.*.log | ||
|
||
*.tfvars | ||
*.tfvars.json | ||
|
||
# Ignore local override files | ||
override.tf | ||
override.tf.json | ||
*_override.tf | ||
*_override.tf.json | ||
|
||
# Terraform CLI configuration files | ||
.terraformrc | ||
terraform.rc | ||
|
||
# Backup files created by Terraform during state edits | ||
*.backup | ||
|
||
# Terraform plan files (these are generated and can be large) | ||
*.tfplan |
22 changes: 22 additions & 0 deletions
22
datastores/gossip_kv/deployment/aws/terraform/application/.terraform.lock.hcl
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.