https://github.com/cloudacademy/stocks-app-eks
🚀 Kubernetes Stocks App - Cloud Native Development
https://github.com/cloudacademy/stocks-app-eks
aws cloudacademy containers devops eks kubernetes terraform
Last synced: about 1 year ago
JSON representation
🚀 Kubernetes Stocks App - Cloud Native Development
- Host: GitHub
- URL: https://github.com/cloudacademy/stocks-app-eks
- Owner: cloudacademy
- Created: 2023-07-20T21:19:17.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-12-01T03:11:36.000Z (over 2 years ago)
- Last Synced: 2024-04-14T07:42:47.509Z (about 2 years ago)
- Topics: aws, cloudacademy, containers, devops, eks, kubernetes, terraform
- Language: HCL
- Homepage:
- Size: 2.39 MB
- Stars: 0
- Watchers: 3
- Forks: 4
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README


## EKS Cluster and Stocks Cloud Native App Deployment
The following instructions are provided to demonstrate how to provision a new EKS cluster and automatically deploy a fully functional Stocks cloud native web application.
An equivalent **ECS** setup is located here:
https://github.com/cloudacademy/stocks-app-ecs

### Kubernetes Architecture
Two different Kubernetes architectures are provided for the deployment of the Stocks cloud native web app. The main difference between architectures is the Stock API routing path. To swap between the different architectures, set the `k8s.stocks_app_architecture` local variable to be either `arch1` or `arch2`.
```
locals {
name = "cloudacademydevops"
environment = "prod"
vpc_cidr = "10.0.0.0/16"
azs = slice(data.aws_availability_zones.available.names, 0, 2)
//returns
# tolist([
# "us-west-2a",
# "us-west-2b"
# ])
k8s = {
stocks_app_architecture = "arch1" #either arch1 or arch2
cluster_name = "${local.name}-eks-${local.environment}"
version = "1.31"
instance_types = ["m5.large"]
capacity_type = "ON_DEMAND"
disk_size = 20
min_size = 2
max_size = 2
desired_size = 2
}
rds = {
master_username = "root"
master_password = "followthewhiterabbit"
db_name = "cloudacademy"
engine = "aurora-mysql"
engine_version = "8.0.mysql_aurora.3.08.0"
acu = {
min = 0.5
max = 1.0
}
}
}
```
#### Architecture 1 (arch1):

#### Architecture 2 (arch2):

### Web Application Architecture
The Stocks cloud native web app consists of the following 3 main components:
#### Stocks Frontend (App)
Implements a web UI using the following languages/frameworks/tools:
- React 16
- Yarn
- Nginx
Source Code and Artifacts:
- GitHub Repo: https://github.com/cloudacademy/stocks-app
- Container Image: [cloudacademydevops/stocks-app:v2](https://hub.docker.com/r/cloudacademydevops/stocks-app)
#### Stocks API
Implements a RESTful based API using the following languages/frameworks/tools:
- Java 17
- Spring Boot
- Maven 3
Source Code and Artifacts:
- GitHub Repo: https://github.com/cloudacademy/stocks-api
- Container Image: [cloudacademydevops/stocks-api:v2](https://hub.docker.com/r/cloudacademydevops/stocks-api)
#### Stocks DB
Aurora RDS DB (serverless v2) SQL database:
- MySQL 8.0
### Prerequisites
Ensure that the following tools are installed and configured appropriately.
- Terraform CLI
- AWS CLI
- Helm CLI
- Kubectl CLI
**Note**: The terraforming commands below have been tested successfully using the following versions:
- `terraform`: 1.5.3
- `aws`: aws-cli/2.13.2
- `helm`: 3.12.2
- `kubectl`: 1.27.4
### Installation
1. Application Deployment
1.1. Initialise the Terraform working directory. Execute the following commands:
```
cd terraform
terraform init
```
1.2. Provision a new EKS cluster and deploy the Stocks cloud native application automatically. Execute the following command:
```
terraform apply -auto-approve
```
2. Confirm Access to the EKS Cluster
2.1. Examine the EKS nodes setup. If this command returns successfully then the EKS cluster and access to it has been established successfully.
```
kubectl get nodes
```
If the previous command errors out due to an authentication issue, consider running the following AWS CLI command to re-establish a KUBECONFIG settings file:
```
export KUBECONFIG=$(pwd)/config
aws eks --region us-west-2 update-kubeconfig --name cloudacademydevops-eks
```
3. Examine EKS Cluster Resources
3.1. Check Namespaces
```
kubectl get ns
```
3.2. Check Ingress Controller Setup
```
kubectl get all -n nginx-ingress
```
3.3. Check Cloud Native App Setup
```
kubectl get all,ingress,secret -n cloudacademy
```
4. Examine Aurora RDS DB
4.1. List Database Clusters
```
aws rds describe-db-clusters --region us-west-2
```
4.2. List Database Cluster Endpoints
```
aws rds describe-db-cluster-endpoints --db-cluster-identifier cloudacademy --region us-west-2
```
5. Generate and Test Stocks API Endpoint
Execute the following command to generate Stocks API URL:
```
echo http://$(kubectl get ing -n cloudacademy public -o jsonpath="{.spec.rules[0].host}")/api/stocks/csv
```
Copy the URL from the previous output and browse to it within your own browser. Confirm that the Stocks CSV formatted data is accessible.
6. Generate and Test Stocks APP (frontend) Endpoint
Execute the following command to generate Stocks API URL:
```
echo http://$(kubectl get ing -n cloudacademy public -o jsonpath="{.spec.rules[0].host}")
```
Copy the URL from the previous output and browse to it within your own browser. Confirm that the Stocks App (frontend) loads successfully, complete with stocks data.