In this section, you will configure MySQL and Redis as AWS Managed Services. Following the configuration steps below:
- Create DB Subnet Group
- Name: mysql
- Description: mysql
- VPC: cmpe281
- Add All Subnets Related to this VPC
- Create an RDS MySQL Instance
- Select "Dev/Test - MySQL" Use Case
- Select Version 5.5.61
- Select "Only enable options eligible for RDS Free Usage Tier"
- Select Instance Type "db.t2.micro"
- Instance Name: mysql
- DB User: admin
- DB Pass: midterm281
- VPC: cmpe281
- DB Subnet Group: mysql
- Public accessibility: No
- AZ Info: No Preference
- Security Group: Chose or Create one with MySQL Port Open
- DB Name: cmpe281
- Port: 3306
- IAM DB authentication: Disable
- Disable auto minor version upgrade
- Remaining Options: Use Defaults
sudo yum update
Install mysql client
sudo yum install mysql
mysql -u admin -p -h <host>
- Cluster Engine: redis
- Name: redis
- Description: redis
- Version: 4.0.10
- Port: 6379
- Parameter group: default.redis4.0
- Node type: cache.t2.micro
- Number of Replicas: 2
- Subnet Group: Create New
- Subnet Group Name: redis
- SG Description: redis
- VPC: cmpe281
- Subnets: select the two private subnets
- Security Group: Chose or Create one with Redis Port Open
sudo yum install gcc
sudo yum install wget
wget http://download.redis.io/redis-stable.tar.gz
tar xvzf redis-stable.tar.gz
cd redis-stable
make
src/redis-cli -h <host> -p 6379
- Modify the Go Gumball Code to connect to your Redis and MySQL Servers from Part 1.
- Build the Code and deploy it to AWS (as two EC2 Instances running as Docker Hosts)
- Then put these two EC2 instances behind an Internal Elastic Load Balancer
After you have the this up, test the Gumball API with the following CURL commands: Note: Replace "host" with the DNS name of your ELB.
curl http://host:3000/ping (Links to an external site.)Links to an external site.
curl -X GET http://host:3000/gumball (Links to an external site.)Links to an external site.
curl -X POST http://host:3000/order (Links to an external site.)Links to an external site.
curl -X POST http://host:3000/order/<orderid> (Links to an external site.)Links to an external site.
Then connect to your MySQL and Redis instances and run the following commands:
MySQL:
select * from gumball
Redis:
keys *
get <key>
- Deploy Kong API gateway on your publicly facing Docker Host (from Labs)
- Configure Kong to route to the internal Gumball ELB as an upstream API
- Add an API Key in Kong to the Gumball Load Balanced API
Consumer Created
Key Value set
Testing