Section 2: A Mini-Microservices App
- which services will we recreate? One separate service for every resource in our app: Posts and Comments
- Consider the goals and responsibilities of each service
- Dependencies: comments will have to know to tie to certain (existing) post
- Create a new app via create react app
npx create-react-app client
- Create an express-based project for the posts service
mkdir posts
,cd posts
,npm init -y
,npm install express cors axios nodemon
- Create an express-based project for the comments service, repeat posts process
Posts
- Create a post
- List all posts
Comments
- Create a comment
- List all comments
- App
- PostList
- CommentList
- CommentCreate
- PostCreate
- PostList
- Listen for events
- Change React app to look at query for posts/comments for READing data only
- Posts and Comments services are still used for creating
- Instead of passing the post ID to the CommentsList component, pass the post object returned from query service
- Create Dockerfile in each (query, posts, etc) service folder
- Push Docker images to Docker hub
- Create depl.yaml files for each K8s config; has K8s Service and Deployment information for each
- Add Ingress (
ingress-nginx
) for communication between clusters/pods and Load Balancer - Add localhost host routes to /etc/host
- Install Skaffold
- Run with
skaffold dev