{"id":18238226,"url":"https://github.com/jbn1995/two-tier-application","last_synced_at":"2025-04-08T16:10:48.279Z","repository":{"id":258162450,"uuid":"873530402","full_name":"jbn1995/Two-Tier-Application","owner":"jbn1995","description":"This repository contains a two-tier Flask application with a MySQL database backend, deployed on Kubernetes using Helm. The application is designed to demonstrate how to deploy and manage a web service with a MySQL database in a Kubernetes environment, utilizing Helm for easy package management. ","archived":false,"fork":false,"pushed_at":"2024-11-26T16:53:47.000Z","size":85,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-14T12:35:50.661Z","etag":null,"topics":["docker","docker-compose","eks-cluster","helm","kubernetes"],"latest_commit_sha":null,"homepage":"","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jbn1995.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-10-16T10:19:38.000Z","updated_at":"2024-11-26T16:53:51.000Z","dependencies_parsed_at":"2024-12-22T05:40:59.885Z","dependency_job_id":"d8f8d562-04a8-4f78-8ec5-906d7f38f276","html_url":"https://github.com/jbn1995/Two-Tier-Application","commit_stats":null,"previous_names":["jbn1995/two-tier-application"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jbn1995%2FTwo-Tier-Application","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jbn1995%2FTwo-Tier-Application/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jbn1995%2FTwo-Tier-Application/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jbn1995%2FTwo-Tier-Application/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jbn1995","download_url":"https://codeload.github.com/jbn1995/Two-Tier-Application/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247878023,"owners_count":21011158,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker","docker-compose","eks-cluster","helm","kubernetes"],"created_at":"2024-11-05T03:04:27.817Z","updated_at":"2025-04-08T16:10:48.255Z","avatar_url":"https://github.com/jbn1995.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Flask App with MySQL \r\nThis is a simple Flask app that interacts with a MySQL database. The app allows users to submit messages, which are then stored in the database and displayed on the frontend.\r\n# Notes\r\n```\r\n- There is also a separate instruction-file in each of K8s-manifests and eks-manifests repository.\r\n\r\n- You can deploy this application in Kind-cluster (A cluster where kubernetes run as a docker containers)\r\n\r\n- Make sure you read before deploy the applications on Kubernetes(EKS,Kubeadm/Minikube).\r\n\r\n- Also You can Deploy the Two-Tier Flask Application on Kubernetes using Helm.\r\n```\r\n# Docker Setup\r\n\r\n# Prerequisits\r\n\r\nBefore you begin, make sure you have the following installed:\r\n- Docker\r\n- Git (optional, for cloning the repository)\r\n## Setup\r\n\r\n1. Clone this repository (if you haven't already):\r\n\r\n   ```bash\r\n   git clone https://github.com/jbn1995/Two-Tier-Application.git\r\n   ```\r\n\r\n2. Navigate to the project directory:\r\n\r\n3. Create a `.env` file in the project directory to store your MySQL environment variables:\r\n\r\n   ```bash\r\n   touch .env\r\n   ```\r\n\r\n4. Open the `.env` file and add your MySQL configuration:\r\n\r\n   ```\r\n   MYSQL_HOST=mysql\r\n   MYSQL_USER=your_username\r\n   MYSQL_PASSWORD=your_password\r\n   MYSQL_DB=your_database\r\n   ```\r\n\r\n## Usage\r\n\r\n1. Start the containers using Docker Compose:\r\n\r\n   ```bash\r\n   docker-compose up --build\r\n   ```\r\n\r\n2. Access the Flask app in your web browser:\r\n\r\n   - Frontend: http://localhost\r\n   - Backend: http://localhost:5000\r\n\r\n3. Create the `messages` table in your MySQL database:\r\n\r\n   - Use a MySQL client or tool (e.g., phpMyAdmin) to execute the following SQL commands:\r\n   \r\n     ```sql\r\n     CREATE TABLE messages (\r\n         id INT AUTO_INCREMENT PRIMARY KEY,\r\n         message TEXT\r\n     );\r\n     ```\r\n\r\n4. Interact with the app:\r\n\r\n   - Visit http://localhost to see the frontend. You can submit new messages using the form.\r\n   - Visit http://localhost:5000/insert_sql to insert a message directly into the `messages` table via an SQL query.\r\n\r\n## Cleaning Up\r\n\r\nTo stop and remove the Docker containers, press `Ctrl+C` in the terminal where the containers are running, or use the following command:\r\n\r\n```bash\r\ndocker-compose down\r\n```\r\n\r\n## To run this two-tier application using  without docker-compose\r\n\r\n- First create a docker image from Dockerfile\r\n```bash\r\ndocker build -t flaskapp .\r\n```\r\n\r\n- Now, make sure that you have created a network using following command\r\n```bash\r\ndocker network create \u003cnetwork-name\u003e\r\n```\r\n\r\n- Attach both the containers in the same network, so that they can communicate with each other\r\n\r\ni) MySQL container \r\n```bash\r\ndocker run -d \\\r\n    --name mysql \\\r\n    -v mysql-data:/var/lib/mysql \\\r\n    --network=\u003cnetwork-name\u003e \\\r\n    -e MYSQL_DATABASE=mydb \\\r\n    -e MYSQL_ROOT_PASSWORD=admin \\\r\n    -p 3306:3306 \\\r\n    mysql:5.7\r\n\r\n```\r\nii) Backend container\r\n```bash\r\ndocker run -d \\\r\n    --name flaskapp \\\r\n    --network=\u003cnetwork-name\u003e \\\r\n    -e MYSQL_HOST=mysql \\\r\n    -e MYSQL_USER=root \\\r\n    -e MYSQL_PASSWORD=admin \\\r\n    -e MYSQL_DB=mydb \\\r\n    -p 5000:5000 \\\r\n    flaskapp:latest\r\n\r\n```\r\n\r\n## Notes\r\n\r\n- Make sure to replace placeholders (e.g., `your_username`, `your_password`, `your_database`) with your actual MySQL configuration.\r\n\r\n- This is a basic setup for demonstration purposes. In a production environment, you should follow best practices for security and performance.\r\n\r\n- Be cautious when executing SQL queries directly. Validate and sanitize user inputs to prevent vulnerabilities like SQL injection.\r\n\r\n- If you encounter issues, check Docker logs and error messages for troubleshooting.\r\n\r\n```\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjbn1995%2Ftwo-tier-application","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjbn1995%2Ftwo-tier-application","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjbn1995%2Ftwo-tier-application/lists"}