{"id":21651,"date":"2021-09-18T05:15:00","date_gmt":"2021-09-18T03:15:00","guid":{"rendered":"https:\/\/blog.mi.hdm-stuttgart.de\/?p=21651"},"modified":"2023-06-18T17:56:14","modified_gmt":"2023-06-18T15:56:14","slug":"deploy-random-chat-application-on-aws-ec2-with-kubernetes","status":"publish","type":"post","link":"https:\/\/blog.mi.hdm-stuttgart.de\/index.php\/2021\/09\/18\/deploy-random-chat-application-on-aws-ec2-with-kubernetes\/","title":{"rendered":"Deploying Random Chat Application on AWS EC2 with Kubernetes"},"content":{"rendered":"\n<p><strong>1. Introduction<\/strong><\/p>\n\n\n\n<p>For the examination of the lecture \u201cSoftware Development for Cloud Computing\u201d, I want to build a simple Random Chat Application. The idea of this application is based on the famous chat application called Omegle. Omegle is where people can meet random people in the world and can have a one-on-one chat. With Omegle people can have a conversation with not only normal chat but also a video chat. Not like Omegle, my application has only a normal texting function.<\/p>\n\n\n\n<p><strong>2. Technologies for the development of application<\/strong><\/p>\n\n\n\n<p>     a. Frontend<\/p>\n\n\n\n<p>React<\/p>\n\n\n\n<p>For Frontend Development there are a great number of open-source libraries. React is recently one of the most popular and widely used libraries. There are many reasons for a developer to choose and use React. It is one of the most popular front-end technologies in the market. Compared to other libraries out there React seems to be easier to learn. As it doesn\u2019t take much time to learn this technology, the developers can rapidly practice and build their own very first project. React helps increase productivity by using reusable components and development tools. There are many development tools available for React that speech up the project. The most important reason is that it has very strong community support. There are thousands of free React tutorial videos and blog posts on the internet which is very helpful for the developer. Therefore, I decided to learn this library during previous semesters. This project gives me a chance to have real practice.<\/p>\n\n\n\n<p>     b. Backend<\/p>\n\n\n\n<p>Node.js<\/p>\n\n\n\n<p>Node.js has become one of the most popular JavaScript tools. Node.js is a JavaScript runtime environment, which allows companies to improve their efficiency of the web development process. The frontend and Backend teams can now work more easily together. Since Node.js is written in JavaScript and bases on Google V8 Engine, everything is done very quickly. Node.js can create an Event Loop, which can cover all asynchronous input-output operations.&nbsp; And the best part is that it can increase the speed of any other framework as well. By allowing developers to write JavaScript code for both the Frontend and the Backend, Node.js makes it easy to send data between the server and the client, which makes it easier to synchronize data immediately.<\/p>\n\n\n\n<p>Socket.io<\/p>\n\n\n\n<p>When I decided to develop a chat application, I already thought about Socket.io. I had a chance to know this JavaScript library during the course Web Development 2. To build a real-time application we should use Socket.io. Socket.io will help parties in different locations connect with each other, transmitting data instantly through an intermediary server. Socket.io can be used in many applications such as chat, online games, updating the results of an ongoing match, &#8230; It is used a lot by the developer community, because of its speed and convenience. Socket.io provides us with many methods as well as outstanding features such as security, auto-connect, disconnection detection, multiplexing, room creation, \u2026<\/p>\n\n\n\n<p><strong>3. Application explanation<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><a href=\"https:\/\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2021\/09\/image-10.png\"><img loading=\"lazy\" decoding=\"async\" data-attachment-id=\"21654\" data-permalink=\"https:\/\/blog.mi.hdm-stuttgart.de\/index.php\/2021\/09\/18\/deploy-random-chat-application-on-aws-ec2-with-kubernetes\/image-10-3\/\" data-orig-file=\"https:\/\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2021\/09\/image-10.png\" data-orig-size=\"859,454\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"image-10\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2021\/09\/image-10.png\" src=\"https:\/\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2021\/09\/image-10.png\" alt=\"\" class=\"wp-image-21654\" width=\"554\" height=\"292\" srcset=\"https:\/\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2021\/09\/image-10.png 859w, https:\/\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2021\/09\/image-10-300x159.png 300w, https:\/\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2021\/09\/image-10-768x406.png 768w\" sizes=\"auto, (max-width: 554px) 100vw, 554px\" \/><\/a><\/figure>\n\n\n\n<p>       a. Client<\/p>\n\n\n\n<p>As I mentioned, for the client-side I use React. Therefore, I have a chance to know the concept of a Single Page Application, whose content is loaded only once and updated dynamically. For the interaction with the page or with subsequent pages, we don\u2019t need another server, which means that the page is not reloaded. To apply this concept of the web application, React offer a packet names \u201creact-router-dom\u201d. My application is very simple, so it only has two paths to be loaded. The root path is where the user inputs his name, and it will load the Join component. The other path is the Chat component, in which the user sends messages after getting a room.<\/p>\n\n\n\n<p>Socket.io library for the client is imported because it is not provided by JavaScript. This will expose the \u2018io\u2019 namespace.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2021\/09\/image-11.png\"><img loading=\"lazy\" decoding=\"async\" width=\"912\" height=\"27\" data-attachment-id=\"21655\" data-permalink=\"https:\/\/blog.mi.hdm-stuttgart.de\/index.php\/2021\/09\/18\/deploy-random-chat-application-on-aws-ec2-with-kubernetes\/image-11-3\/\" data-orig-file=\"https:\/\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2021\/09\/image-11.png\" data-orig-size=\"912,27\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"image-11\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2021\/09\/image-11.png\" src=\"https:\/\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2021\/09\/image-11.png\" alt=\"\" class=\"wp-image-21655\" srcset=\"https:\/\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2021\/09\/image-11.png 912w, https:\/\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2021\/09\/image-11-300x9.png 300w, https:\/\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2021\/09\/image-11-768x23.png 768w\" sizes=\"auto, (max-width: 912px) 100vw, 912px\" \/><\/a><\/figure>\n\n\n\n<p>Endpoint URL will be given for \u2018io\u2019 to connect with the socket.io server.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2021\/09\/image-12.png\"><img loading=\"lazy\" decoding=\"async\" width=\"912\" height=\"51\" data-attachment-id=\"21656\" data-permalink=\"https:\/\/blog.mi.hdm-stuttgart.de\/index.php\/2021\/09\/18\/deploy-random-chat-application-on-aws-ec2-with-kubernetes\/image-12-3\/\" data-orig-file=\"https:\/\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2021\/09\/image-12.png\" data-orig-size=\"912,51\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"image-12\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2021\/09\/image-12.png\" src=\"https:\/\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2021\/09\/image-12.png\" alt=\"\" class=\"wp-image-21656\" srcset=\"https:\/\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2021\/09\/image-12.png 912w, https:\/\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2021\/09\/image-12-300x17.png 300w, https:\/\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2021\/09\/image-12-768x43.png 768w\" sizes=\"auto, (max-width: 912px) 100vw, 912px\" \/><\/a><\/figure>\n\n\n\n<p>Now users can send and receive messages from the server after the room is created.<\/p>\n\n\n\n<p>      b. Server<\/p>\n\n\n\n<p>To setup server, some packets need to be imported:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2021\/09\/image-13.png\"><img loading=\"lazy\" decoding=\"async\" width=\"913\" height=\"76\" data-attachment-id=\"21657\" data-permalink=\"https:\/\/blog.mi.hdm-stuttgart.de\/index.php\/2021\/09\/18\/deploy-random-chat-application-on-aws-ec2-with-kubernetes\/image-13-3\/\" data-orig-file=\"https:\/\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2021\/09\/image-13.png\" data-orig-size=\"913,76\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"image-13\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2021\/09\/image-13.png\" src=\"https:\/\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2021\/09\/image-13.png\" alt=\"\" class=\"wp-image-21657\" srcset=\"https:\/\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2021\/09\/image-13.png 913w, https:\/\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2021\/09\/image-13-300x25.png 300w, https:\/\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2021\/09\/image-13-768x64.png 768w\" sizes=\"auto, (max-width: 913px) 100vw, 913px\" \/><\/a><\/figure>\n\n\n\n<p>The server is set up and listen on port 5000<\/p>\n\n\n\n<p>The server can also save users temporally, so it will know which user\u2019s name already existed. And then it can remove users after they terminate their chat. To execute all those actions, I write a users.js file, which will have some functions such as, addUser, removeUser, getUser, &#8230;<\/p>\n\n\n\n<p>I want to create a chat application where users don\u2019t have to have an already known friend and a Chat room will be automatically created for them. With this application, they can meet a new friend and the server will get them a chat room.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2021\/09\/image-15.png\"><img loading=\"lazy\" decoding=\"async\" width=\"757\" height=\"560\" data-attachment-id=\"21659\" data-permalink=\"https:\/\/blog.mi.hdm-stuttgart.de\/index.php\/2021\/09\/18\/deploy-random-chat-application-on-aws-ec2-with-kubernetes\/image-15-3\/\" data-orig-file=\"https:\/\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2021\/09\/image-15.png\" data-orig-size=\"757,560\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"image-15\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2021\/09\/image-15.png\" src=\"https:\/\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2021\/09\/image-15.png\" alt=\"\" class=\"wp-image-21659\" srcset=\"https:\/\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2021\/09\/image-15.png 757w, https:\/\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2021\/09\/image-15-300x222.png 300w\" sizes=\"auto, (max-width: 757px) 100vw, 757px\" \/><\/a><\/figure>\n\n\n\n<p>I created a variable queue, which is an array. It will save a user, who has not had any partner yet, temporarily. Every user, who already inputted their names, will be connected to the socket. Socket knows that he wants to join a room. In the callback function of the socket, the name and socket ID of the user will be saved by function \u2018addUser\u2019, which is in users.js. Then socket will check if any other user is waiting for a partner in a queue. If someone is waiting for a partner, he will be popped from the queue. His socket and partner\u2019s socket will be connected. And their room ID will be a combination of the 2 socket IDs. If no one is waiting for a room, the current socket is pushed to a queue and wait for another user to join.<\/p>\n\n\n\n<p>        c. Problem<\/p>\n\n\n\n<p>CORS:&nbsp;<\/p>\n\n\n\n<p>It is an abbreviation for Cross-Origin Request Sharing, which means that all data should come from the same resource. They use it as a security measure because JavaScript can load content from other servers without the knowledge of the user. This problem can be solved when both websites are aware of the data exchange, then the process will be allowed.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2021\/09\/image-16.png\"><img loading=\"lazy\" decoding=\"async\" width=\"437\" height=\"135\" data-attachment-id=\"21660\" data-permalink=\"https:\/\/blog.mi.hdm-stuttgart.de\/index.php\/2021\/09\/18\/deploy-random-chat-application-on-aws-ec2-with-kubernetes\/image-16-3\/\" data-orig-file=\"https:\/\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2021\/09\/image-16.png\" data-orig-size=\"437,135\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"image-16\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2021\/09\/image-16.png\" src=\"https:\/\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2021\/09\/image-16.png\" alt=\"\" class=\"wp-image-21660\" srcset=\"https:\/\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2021\/09\/image-16.png 437w, https:\/\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2021\/09\/image-16-300x93.png 300w\" sizes=\"auto, (max-width: 437px) 100vw, 437px\" \/><\/a><\/figure>\n\n\n\n<p>I installed the CORS package on my server. Origin will configure the\u00a0Access-Control-Allow-Origin\u00a0CORS header. Now client and server can communicate without error.<\/p>\n\n\n\n<p><strong>4. Testing<\/strong><\/p>\n\n\n\n<p>Testing is very important during the development of the application. Testing helps developers to discover existing errors\/bugs before releasing the application. Therefore, the quality of the application would be enhanced. I decided to test only the server-side because it is more complicated than the client-side. Two tests are being created.<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>A single user testing: tests if he can connect to a server and receive a welcome message from the server.<\/li><li>Two users testing: tests if a room can be created when there are two users and both of them can receive the same welcome message from the same room.<\/li><\/ul>\n\n\n\n<p><strong>5. Deployment<\/strong><\/p>\n\n\n\n<p>     a. Docker Swarm and Kubernetes<\/p>\n\n\n\n<p>When deploying this project, I create a container for each of the client and server sites. Docker is the most popular solution for the container platform. I want to learn to write a DockerFile and a docker-compose to create a container.<\/p>\n\n\n\n<p>For the cloud development environment, I choose Amazon Web Service. It is currently one of the most comprehensive platforms for cloud computing services. I use an EC2 virtual server to make my project online. I would like to work with Kubernetes to manage the containers. I choose EKS, which is a service from Amazon web service.<\/p>\n\n\n\n<p>If you work with a lot of containers, you have to be able to manage them efficiently. An orchestration tool enables exactly that. With the orchestration tool, you can integrate containers that you created with Docker. Then you use orchestration to manage, scale, and move the containers.<\/p>\n\n\n\n<p>Although Kubernetes and Docker can work well together, there is competition when it comes to Docker Swarm. I have considered some features of Docker Swarm and Kubernetes.<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Scaling: The load on our application is too high, Kubernetes can add more nodes to our cluster. Of course, we have to configure Kubernetes correctly so that it can create a new virtual machine. Then a node is added to the cluster.<\/li><li>Installation: with Docker Swarm, it is easy to create a new node, then integrate it with Swarm. On the other hand, to configure Kubernetes you have to determine the size of the node, how many master nodes, and worker nodes.<\/li><li>Load balancing: Docker swarm offers application auto load balancing. However, Kubernetes gives the flexibility to configure load balancing manually.<\/li><li>Storage volume participation: since the docker swarm manages Docker containers, containers find it easy to share data. Not just data, as well as other things. Kubernetes puts the container in a pod so the container cannot simply communicate with another. You need other components from Kubernetes, e.g., Service to create the connection.<\/li><li>Monitoring: While Swarm requires additional resources for monitoring and keeping a log, these tasks are already provided for in Kubernetes.<\/li><\/ul>\n\n\n\n<p>     b. Amazon EKS and Kops<\/p>\n\n\n\n<p>When deploying Kubernetes on AWS, you can configure and manage the deployment yourself for full flexibility and control. There are a few options for self-management: Amazon Elastic Kubernetes Service and Kops.<\/p>\n\n\n\n<p>EKS is a managed service offered by AWS. EKS uses automatically provided instances and offers a managed control plane for deployment.<\/p>\n\n\n\n<p>Kops is an open-source tool that can be used to automate the deployment and management of clusters on AWS. It is officially supported by AWS.<\/p>\n\n\n\n<p>     c. Docker File<\/p>\n\n\n\n<p>To work with Kubernetes, I need to create all necessary containers. Containers are created by writing docker files. These docker files contain all information about the container, e.g.: name of the image, directory store our application, port, \u2026 Docker will follow this information, then step by step, create containers. Besides, I use Docker Compose to start the process of creating containers.<\/p>\n\n\n\n<p>     d. Kubernetes architecture on AWS cloud<\/p>\n\n\n\n<p>I choose Kubernetes, Amazon EC2, EKS, ECR for the deployment of my project. What is showed below is the architecture of Kubernetes on AWS cloud.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><a href=\"https:\/\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2021\/09\/image-17.png\"><img loading=\"lazy\" decoding=\"async\" data-attachment-id=\"21662\" data-permalink=\"https:\/\/blog.mi.hdm-stuttgart.de\/index.php\/2021\/09\/18\/deploy-random-chat-application-on-aws-ec2-with-kubernetes\/image-17-3\/\" data-orig-file=\"https:\/\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2021\/09\/image-17.png\" data-orig-size=\"605,289\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"image-17\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2021\/09\/image-17.png\" src=\"https:\/\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2021\/09\/image-17.png\" alt=\"\" class=\"wp-image-21662\" width=\"541\" height=\"259\" srcset=\"https:\/\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2021\/09\/image-17.png 605w, https:\/\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2021\/09\/image-17-300x143.png 300w\" sizes=\"auto, (max-width: 541px) 100vw, 541px\" \/><\/a><figcaption>Source: https:\/\/blogs.tensult.com\/2019\/08\/14\/guide-to-setup-kubernetes-in-aws-eks-using-terraform-and-deploy-sample-applications\/<\/figcaption><\/figure>\n\n\n\n<p>Kubernetes server is a control panel. It creates a cubic cluster. In the cluster, there are master nodes that create and manage worker nodes. When you call deployment commands, the Kubernetes server sends messages to EKS, then EKS sends the tasks to the worker nodes.<\/p>\n\n\n\n<p>Worker node contains some pods, in which the docker container will be run. I choose controller Deployment to keep these pods running and observe them. For the worker node, I create a pod for the client, 2 pods for the server, and a pod for Redis. The load balancer can be used to communicate with the application from outside.&nbsp;<\/p>\n\n\n\n<p>I decided to have 2 pods Server because I want to scale my application. In case when more people try to connect to my application, the request will be handled faster when we have 2 pods instead of 1 pod. The picture below shows a horizontal scaling, which means that it has more copies of the application and these copies can work with each other at the same time.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2021\/09\/image-18.png\"><img loading=\"lazy\" decoding=\"async\" width=\"915\" height=\"324\" data-attachment-id=\"21664\" data-permalink=\"https:\/\/blog.mi.hdm-stuttgart.de\/index.php\/2021\/09\/18\/deploy-random-chat-application-on-aws-ec2-with-kubernetes\/image-18-3\/\" data-orig-file=\"https:\/\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2021\/09\/image-18.png\" data-orig-size=\"915,324\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"image-18\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2021\/09\/image-18.png\" src=\"https:\/\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2021\/09\/image-18.png\" alt=\"\" class=\"wp-image-21664\" srcset=\"https:\/\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2021\/09\/image-18.png 915w, https:\/\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2021\/09\/image-18-300x106.png 300w, https:\/\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2021\/09\/image-18-768x272.png 768w\" sizes=\"auto, (max-width: 915px) 100vw, 915px\" \/><\/a><\/figure>\n\n\n\n<p>For example: for the pod client I write a client-deployment.yaml file<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh6.googleusercontent.com\/eajc9wE9IeLjCOXLqkcscWOWRi_PG2zZ4DAc5wkHgNsld0yAAW6quvlP3IHyp4OqFXA023z0cA4gDWN0qBFj_6L84uppXcRSQloxfrvLJndm0KLNGdVq4SmGJqO6VzpJHLVHVaM=s0\" alt=\"\"\/><\/figure>\n\n\n\n<ul class=\"wp-block-list\"><li>A deployment named client is created, indicated by the <em>.metadata.name field<\/em>.<\/li><li>The <em>.spec.selector<\/em> field defines how the deployment finds the pods to be managed.<\/li><li>The deployment creates one replica pod, indicated by the <em>.spec.replicas<\/em> field.<\/li><li>the <em>.template.spec<\/em> field indicates that the pod is running a container. The container is created by docker image, which has been saved in ECR (Elastic Container Registry)<\/li><li>The container is created using the <em>.spec.template.spec.containers.name <\/em>field which is called client.<\/li><\/ul>\n\n\n\n<p>To enable network access to the set of pods I have to create a Service, which is written in client-service.yaml.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2021\/09\/image-19.png\"><img loading=\"lazy\" decoding=\"async\" width=\"479\" height=\"485\" data-attachment-id=\"21666\" data-permalink=\"https:\/\/blog.mi.hdm-stuttgart.de\/index.php\/2021\/09\/18\/deploy-random-chat-application-on-aws-ec2-with-kubernetes\/image-19-3\/\" data-orig-file=\"https:\/\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2021\/09\/image-19.png\" data-orig-size=\"479,485\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"image-19\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2021\/09\/image-19.png\" src=\"https:\/\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2021\/09\/image-19.png\" alt=\"\" class=\"wp-image-21666\" srcset=\"https:\/\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2021\/09\/image-19.png 479w, https:\/\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2021\/09\/image-19-296x300.png 296w\" sizes=\"auto, (max-width: 479px) 100vw, 479px\" \/><\/a><\/figure>\n\n\n\n<p>This specification creates a new service object called &#8220;client&#8221; that targets TCP port 3000 on each pod, which is labeled as app = random-chat.<\/p>\n\n\n\n<p>For pods Server and Redis, I also create Deployment and Service for each.<\/p>\n\n\n\n<p>     e. Problem<\/p>\n\n\n\n<p>Service of pod Server:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh5.googleusercontent.com\/x8nNlGqCM-ClIAfpzpR-IfDbboXTqrZt-L07Jnj_-uy-7TTPPWN0EjPdVq12cGecCY9GdOhL_gQMXI9AqxbzhljATNm5r03aFWktbGKrxPgWrRxkzO0PCq_Ujq_SdJOkIzJC064=s0\" alt=\"\"\/><\/figure>\n\n\n\n<p>Pods can usually send requests with each other by using a normal type of Service, which means, in my case, that the pod Client can send a request to the pod Server without having an attribute \u2018type\u2019 in server-service.yaml. The Endpoint of the Client will be \u2018server:5000\u2019, which is the combination of the name of the service and the targetPort. But after many attempts, it still does not work. So, I decided to make the Service of pod Server as type Load Balancer, which is shown in the picture above. Now the Endpoint of the client will be the address of this Load Balancer.<\/p>\n\n\n\n<p><strong>6. Conclusion<\/strong><\/p>\n\n\n\n<p>During the course \u2018Software Development for Cloud Computing\u2019 and this project, I have a chance to know the concept of Docker containers and how to manage them with Kubernetes. I gain not only theoretical knowledge but also practical experience by developing and deploying the application. Moreover, working with cloud computing is new and interesting for me. Cloud computing is nowadays applied in the development of applications a lot. What I applied in my project is just a small part of cloud computing and I want to learn more about it in the future.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>1. Introduction For the examination of the lecture \u201cSoftware Development for Cloud Computing\u201d, I want to build a simple Random Chat Application. The idea of this application is based on the famous chat application called Omegle. Omegle is where people can meet random people in the world and can have a one-on-one chat. With Omegle [&hellip;]<\/p>\n","protected":false},"author":1058,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[120,262,650],"tags":[7,3,154,25,530,445],"ppma_author":[860],"class_list":["post-21651","post","type-post","status-publish","format-standard","hentry","category-cloud-technologies","category-rich-media-systems","category-scalable-systems","tag-cloud","tag-docker","tag-kubernetes","tag-nodejs","tag-react","tag-socketio"],"aioseo_notices":[],"jetpack_featured_media_url":"","jetpack-related-posts":[{"id":25999,"url":"https:\/\/blog.mi.hdm-stuttgart.de\/index.php\/2023\/09\/15\/automate-pdf-a-cloud-driven-workflow-tool-with-cloud-functions-and-kubernetes\/","url_meta":{"origin":21651,"position":0},"title":"Automate PDF &#8211; A Cloud-Driven Workflow Tool with Cloud Functions and Kubernetes","author":"fb089","date":"15. September 2023","format":false,"excerpt":"Gitlab You can find the Project under this link https:\/\/gitlab.mi.hdm-stuttgart.de\/fb089\/automatecloud Wiki You can find all the Infos in our Gitlab Wiki (https:\/\/gitlab.mi.hdm-stuttgart.de\/fb089\/automatecloud\/-\/wikis\/AutomateCloud). You can even try it urself. Feel free Short Description Automate PDF is a workflow automation tool created in the course \u201cSoftware Development for Cloud Computing\u201d. The application\u2026","rel":"","context":"In &quot;Allgemein&quot;","block_context":{"text":"Allgemein","link":"https:\/\/blog.mi.hdm-stuttgart.de\/index.php\/category\/allgemein\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2023\/09\/Bildschirmfoto-2023-09-15-um-19.23.39.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2023\/09\/Bildschirmfoto-2023-09-15-um-19.23.39.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2023\/09\/Bildschirmfoto-2023-09-15-um-19.23.39.png?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":25708,"url":"https:\/\/blog.mi.hdm-stuttgart.de\/index.php\/2023\/09\/07\/chatscape-scalable-serverless-chat\/","url_meta":{"origin":21651,"position":1},"title":"ChatScape &#8211; Scalable Serverless Chat","author":"Pojtinger Felicitas","date":"7. September 2023","format":false,"excerpt":"Introduction The corresponding repository containing our code can be found publicly on GitHub Since there are at least a quintillion chat applications out there, we thought that we\u2019d do no harm in releasing another one. ChatScape is a chat application, designed as a hands-on approach to dive deep into AWS.\u2026","rel":"","context":"In &quot;Allgemein&quot;","block_context":{"text":"Allgemein","link":"https:\/\/blog.mi.hdm-stuttgart.de\/index.php\/category\/allgemein\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":12060,"url":"https:\/\/blog.mi.hdm-stuttgart.de\/index.php\/2020\/09\/30\/a-beginners-approach-at-a-cloud-backed-browser-game\/","url_meta":{"origin":21651,"position":2},"title":"A beginners approach at a cloud backed browser game","author":"mk321","date":"30. September 2020","format":false,"excerpt":"Foreword: This article reflects my experiences while developing a real time browser-based game. The game of choice was Tic-Tac-Toe as it is straight forward to implement and does not have complex game mechanics. The following paragraphs explain my experiences I got while developing this game with a cloud-based infrastructure in\u2026","rel":"","context":"In &quot;Allgemein&quot;","block_context":{"text":"Allgemein","link":"https:\/\/blog.mi.hdm-stuttgart.de\/index.php\/category\/allgemein\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2020\/09\/image-28.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2020\/09\/image-28.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2020\/09\/image-28.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2020\/09\/image-28.png?resize=700%2C400&ssl=1 2x"},"classes":[]},{"id":12267,"url":"https:\/\/blog.mi.hdm-stuttgart.de\/index.php\/2021\/02\/23\/__trashed\/","url_meta":{"origin":21651,"position":3},"title":"Micro Frontends: Benefits of Webpack 5 Module Federation &#8211; A comparison","author":"Dominik Utler","date":"23. February 2021","format":false,"excerpt":"In this article I am going to have a look at the benefits of module federation in micro frontends with Webpack 5. We will be creating two similar micro frontend websites using two different approaches and compare the amount of resources that will be transferred over the network. Short overview\u2026","rel":"","context":"In &quot;Allgemein&quot;","block_context":{"text":"Allgemein","link":"https:\/\/blog.mi.hdm-stuttgart.de\/index.php\/category\/allgemein\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2021\/02\/Screenshot-2021-02-23-at-12.13.16.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2021\/02\/Screenshot-2021-02-23-at-12.13.16.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2021\/02\/Screenshot-2021-02-23-at-12.13.16.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2021\/02\/Screenshot-2021-02-23-at-12.13.16.png?resize=700%2C400&ssl=1 2x, https:\/\/i0.wp.com\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2021\/02\/Screenshot-2021-02-23-at-12.13.16.png?resize=1050%2C600&ssl=1 3x, https:\/\/i0.wp.com\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2021\/02\/Screenshot-2021-02-23-at-12.13.16.png?resize=1400%2C800&ssl=1 4x"},"classes":[]},{"id":27618,"url":"https:\/\/blog.mi.hdm-stuttgart.de\/index.php\/2025\/02\/28\/crowdconnect-developing-a-scalable-live-chat-application-with-aws-cloud-services\/","url_meta":{"origin":21651,"position":4},"title":"CrowdConnect &#8211; Developing a Scalable Live Chat Application with AWS Cloud Services","author":"Jannik Scheider","date":"28. February 2025","format":false,"excerpt":"Imagine you're developing a live chat application in the cloud that needs to serve a growing number of users simultaneously and in real time across multiple chat rooms. Sounds like a challenge? It is. But with proven approaches and valuable insights from real-world experience, this task can be successfully and\u2026","rel":"","context":"In &quot;Cloud Technologies&quot;","block_context":{"text":"Cloud Technologies","link":"https:\/\/blog.mi.hdm-stuttgart.de\/index.php\/category\/scalable-systems\/cloud-technologies\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2025\/02\/image-14.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2025\/02\/image-14.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2025\/02\/image-14.png?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":11460,"url":"https:\/\/blog.mi.hdm-stuttgart.de\/index.php\/2020\/09\/29\/get-car-location-using-raspberrypi-and-google-cloud-iot-core\/","url_meta":{"origin":21651,"position":5},"title":"Get car location using Raspberry Pi and Google Cloud IoT Core","author":"Simon L\u00f6bert","date":"29. September 2020","format":false,"excerpt":"Project idea Have you ever been in the situation, that you parked your car somewhere in the city and some hours later, you couldn't remember where you parked it? You may wish to have an application on your smartphone, which is able to locate your car. From this consideration, the\u2026","rel":"","context":"In &quot;Allgemein&quot;","block_context":{"text":"Allgemein","link":"https:\/\/blog.mi.hdm-stuttgart.de\/index.php\/category\/allgemein\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/blog.mi.hdm-stuttgart.de\/wp-content\/uploads\/2020\/09\/grafik.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]}],"jetpack_sharing_enabled":true,"authors":[{"term_id":860,"user_id":1058,"is_guest":0,"slug":"dv029","display_name":"dv029","avatar_url":"https:\/\/secure.gravatar.com\/avatar\/0c1ca9770361f3c22dce518e461e001c0f32c9072ceef36636c4d6768a338bf4?s=96&d=mm&r=g","0":null,"1":"","2":"","3":"","4":"","5":"","6":"","7":"","8":""}],"_links":{"self":[{"href":"https:\/\/blog.mi.hdm-stuttgart.de\/index.php\/wp-json\/wp\/v2\/posts\/21651","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.mi.hdm-stuttgart.de\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.mi.hdm-stuttgart.de\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.mi.hdm-stuttgart.de\/index.php\/wp-json\/wp\/v2\/users\/1058"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.mi.hdm-stuttgart.de\/index.php\/wp-json\/wp\/v2\/comments?post=21651"}],"version-history":[{"count":4,"href":"https:\/\/blog.mi.hdm-stuttgart.de\/index.php\/wp-json\/wp\/v2\/posts\/21651\/revisions"}],"predecessor-version":[{"id":21681,"href":"https:\/\/blog.mi.hdm-stuttgart.de\/index.php\/wp-json\/wp\/v2\/posts\/21651\/revisions\/21681"}],"wp:attachment":[{"href":"https:\/\/blog.mi.hdm-stuttgart.de\/index.php\/wp-json\/wp\/v2\/media?parent=21651"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.mi.hdm-stuttgart.de\/index.php\/wp-json\/wp\/v2\/categories?post=21651"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.mi.hdm-stuttgart.de\/index.php\/wp-json\/wp\/v2\/tags?post=21651"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/blog.mi.hdm-stuttgart.de\/index.php\/wp-json\/wp\/v2\/ppma_author?post=21651"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}