Deploying Microservice App on K8s

Deploying Microservice App on K8s

Part 8: Final Deployment

Β·

5 min read

This blog is Part 8 of the blog series it is recommended that you read the previous blogs before this one. Here is the Part 1 of the series.

Clone the project repository-

In this blog, we will finally deploy the microservices application so let's deploy

To deploy the application, you first need to build the cloud architecture, so build the cloud architecture and follow all the steps of all the previous blogs.

Check These Before Deployment

Once you have built the cloud architecture check these manifest files in the private repository of your manifest files.

  1. Check the storage_class.yaml manifest and update fileSystemId with the ID of your EFS file system, you built with this cloud architecture.

  2. Check auth-configs.yaml manifest and ensure DB_HOST has the endpoint of your AWS RDS MySQL database. The endpoint of your database will remain same even if you destroy the architecture and rebuild it still you need to ensure this. I have discussed how to see the database endpoint in PART 4 of this blog series.

  3. Check if you have deployed both the auth and backend Image to your AWS ECR Repository. I have discussed how to upload the Image to your AWS ECR repository in Part 5 of this blog series.

  4. Check if you have the correct URI of the Image in backend_deploy.yaml and auth_deploy.yaml manifest files.

  5. Check argo-secret.yaml file and ensure that have made a private repository for manifest and paste the link and Personal Access Token of the repository in the file. You can refer to part 6 of this blog series.

  6. Check argocd.yaml file and ensure you have pasted the link to your private manifest repository in the file. You can refer to part 6 of this blog series.

Make Table in Database

To make the table in the database, you need to install PopSQL which is a tool using which you can connect and run commands in a remote database. You can install PopSQL from here.

After installing PopSQL, open it and create a new connection. You can go to the new connection option by clicking in your profile picture in the bottom left.

You will see Manage connection option there, click on it.

You will be on the connections page now, click on New connection.

Now in name, the connection as you like, paste the endpoint of your AWS RDS MySQL database in Hostname field and paste 3306 in the Port field.

In the Database field paste tasklist_db.

Paste senpai in Username field and onlysenpaiknows in Password field.

Click on Test to test if you are able to connect to the database. If test failed check the endpoint, username, port, Database or password that you have provided.

If the test passes click on Connect option.

Create a query and paste the below code one the query

CREATE TABLE users (
    id INT AUTO_INCREMENT PRIMARY KEY,
    username VARCHAR(20) UNIQUE,
    name VARCHAR(20),
    email VARCHAR(50) UNIQUE,
    user_password VARCHAR(100)
);

Run this query in your AWS RDS MySQL database. Make sure you have connection set to your AWS RDS Connection. After successfully running this query you will have created a table in your database which will store username, password, email and name of the users.

Deploy

Open the private repository of manifests in your local machine. Open the terminal in the same repository.

I have mentioned these commands as a script in one-click-deploy.sh file so that you don't have to run these commands one by one. So instead of entering these commands one by one you can run this script with the command-

bash one-click-deploy.sh
  1. You need to update your Kubeconfig file so that it targets the command you are going to type to your cluster. To update just enter the command below in terminal-

     aws eks update-kubeconfig --region ap-south-1 --name Tasklist
    
  2. Apply the storage_class.yaml file, type the command below in terminal-

     kubectl apply -f storage_class.yaml
    
  3. Create namespace for backend, type the command below in terminal-

     kubectl create namespace backend
    
  4. Create namespace for auth, type the command below in terminal-

     kubectl create namespace auth
    
  5. Create namespace for argocd, type the command below in terminal-

     kubectl create namespace argocd
    
  6. Apply pvc.yaml file, type the command below in terminal-

     kubectl apply -f pvc.yaml
    
  7. Apply auth-configs.yaml file, type the command below in terminal-

     kubectl apply -f auth-configs.yaml
    
  8. Apply auth-secrets.yaml file, type the command below in terminal-

     kubectl apply -f auth-secrets.yaml
    
  9. Apply backend-configs.yaml file, type the command below in terminal-

     kubectl apply -f backend-configs.yaml
    
  10. Apply backend-secrets.yaml file, type the command below in terminal-

    kubectl apply -f backend-secrets.yaml
    
  11. Apply cluster-autoscaler.yaml file, type the command below in terminal-

    kubectl apply -f cluster-autoscaler.yaml
    
  12. Apply auth_deploy.yaml file, type the command below in terminal-

    kubectl apply -f auth_deploy.yaml
    
  13. Apply backend_deploy.yaml file, type the command below in terminal-

    kubectl apply -f backend_deploy.yaml
    
  14. Install ArgoCD in the cluster, type the command below in terminal-

    kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml
    
  15. Apply argo-secret.yaml file, type the command below in terminal-

    kubectl apply -f argo-secret.yaml
    
  16. Set the ArgoCD server to LoadBalancer type so that we can access it from the browser, type the command below in terminal-

    kubectl patch svc argocd-server -n argocd -p '{"spec": {"type": "LoadBalancer"}}'
    
  17. Apply argocd.yaml file, type the command below in terminal-

    kubectl apply -f argocd.yaml
    

Check the website

After running the above commands successfully, the microservices will be deployed. You can now go the website. To go to the website get the endpoint of the LoadBalancer of Backend Microservice by entering the command below-

kubectl get svc -n backend

Copy the EXTERNAL-IP of the LoadBalancer

Go to the website and paste this EXTERNAL-IP and prefix it with :5000 for port.

For example-

aa730261d4a534f1482782015def4e8b-1027384791.ap-south-1.elb.amazonaws.com:5000

After searching this in your browser you will see the websiteπŸŽ‰πŸŽ‰πŸŽ‰πŸŽ‰πŸŽ‰

You can now explore the website.


The project does not end here, in the next blog We will implement CI/CD, so I will meet you in the next blog.

If you are facing any problems, errors and difficulties don't shy away from asking in the comment section so that I can help you with the project.

Share the blog on socials and tag me on X and LinkedIn for the #buildinpublic initiative.

Follow me on X and LinkedIn

******Thank you for following alongπŸ˜πŸ˜‡******

Β