From 7a54f886ff8ee890272f4d79eaae11af8a364635 Mon Sep 17 00:00:00 2001 From: Robin Winters Date: Tue, 6 Feb 2024 17:06:45 +0000 Subject: [PATCH 1/9] initial state --- README.md | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 08407749..a2c82222 100644 --- a/README.md +++ b/README.md @@ -13,15 +13,15 @@ Welcome to the Web App DevOps Project repo! This application allows you to effic ## Features - **Order List:** View a comprehensive list of orders including details like date UUID, user ID, card number, store code, product code, product quantity, order date, and shipping date. - + ![Screenshot 2023-08-31 at 15 48 48](https://github.com/maya-a-iuga/Web-App-DevOps-Project/assets/104773240/3a3bae88-9224-4755-bf62-567beb7bf692) - **Pagination:** Easily navigate through multiple pages of orders using the built-in pagination feature. - + ![Screenshot 2023-08-31 at 15 49 08](https://github.com/maya-a-iuga/Web-App-DevOps-Project/assets/104773240/d92a045d-b568-4695-b2b9-986874b4ed5a) - **Add New Order:** Fill out a user-friendly form to add new orders to the system with necessary information. - + ![Screenshot 2023-08-31 at 15 49 26](https://github.com/maya-a-iuga/Web-App-DevOps-Project/assets/104773240/83236d79-6212-4fc3-afa3-3cee88354b1a) - **Data Validation:** Ensure data accuracy and completeness with required fields, date restrictions, and card number validation. @@ -53,10 +53,12 @@ To run the application, you simply need to run the `app.py` script in this repos - **Database:** The application employs an Azure SQL Database as its database system to store order-related data. -## Contributors +## Contributors -- [Maya Iuga]([https://github.com/yourusername](https://github.com/maya-a-iuga)) +- [Maya Iuga](<[https://github.com/yourusername](https://github.com/maya-a-iuga)>) ## License This project is licensed under the MIT License. For more details, refer to the [LICENSE](LICENSE) file. + +## Robin Winters Azure End-to-End DevOps Pipeline Project From df60a2dd38abcb633b2fcdc92808e9fe45076085 Mon Sep 17 00:00:00 2001 From: Robin Winters Date: Tue, 6 Feb 2024 17:14:38 +0000 Subject: [PATCH 2/9] delivery-date column add --- app.py | 5 +- templates/orders.html | 180 ++++++++++++++++++++++++++---------------- 2 files changed, 114 insertions(+), 71 deletions(-) diff --git a/app.py b/app.py index 50f4e29d..aeeb67fc 100644 --- a/app.py +++ b/app.py @@ -46,6 +46,7 @@ class Order(Base): product_quantity = Column('Product Quantity', Integer) order_date = Column('Order Date', DateTime) shipping_date = Column('Shipping Date', DateTime) + delivery_date = Column('Delivery Date', DateTime) # define routes # route to display orders @@ -85,6 +86,7 @@ def add_order(): product_quantity = request.form.get('product_quantity') order_date = request.form.get('order_date') shipping_date = request.form.get('shipping_date') + delivery_date = request.form['delivery_date'] # Create a session to interact with the database session = Session() @@ -98,7 +100,8 @@ def add_order(): product_code=product_code, product_quantity=product_quantity, order_date=order_date, - shipping_date=shipping_date + shipping_date=shipping_date, + delivery_date=delivery_date ) # Add the new order to the session and commit to the database diff --git a/templates/orders.html b/templates/orders.html index 9372e2d0..9c58f4ba 100644 --- a/templates/orders.html +++ b/templates/orders.html @@ -1,82 +1,122 @@ - + Order Management - - - + + +
-

Fictional Company Name

+

Fictional Company Name

- - + +
- +
-
-

Order List

- - - - - - - - - - - - - - - {% for order in orders %} - - - - - - - - - - - {% endfor %} - -
Date UUIDUser IDCard NumberStore CodeProduct CodeProduct QuantityOrder DateShipping Date
{{ order.date_uuid }}{{ order.user_id }}{{ order.card_number }}{{ order.store_code }}{{ order.product_code }}{{ order.product_quantity }}{{ order.order_date }}{{ order.shipping_date }}
- -
- - + From 9674fa9812397bae67beece003b66e6368b610b9 Mon Sep 17 00:00:00 2001 From: Robin Winters Date: Tue, 6 Feb 2024 17:24:49 +0000 Subject: [PATCH 3/9] Revert "delivery-date column add" This reverts commit df60a2dd38abcb633b2fcdc92808e9fe45076085. --- app.py | 5 +- templates/orders.html | 180 ++++++++++++++++-------------------------- 2 files changed, 71 insertions(+), 114 deletions(-) diff --git a/app.py b/app.py index aeeb67fc..50f4e29d 100644 --- a/app.py +++ b/app.py @@ -46,7 +46,6 @@ class Order(Base): product_quantity = Column('Product Quantity', Integer) order_date = Column('Order Date', DateTime) shipping_date = Column('Shipping Date', DateTime) - delivery_date = Column('Delivery Date', DateTime) # define routes # route to display orders @@ -86,7 +85,6 @@ def add_order(): product_quantity = request.form.get('product_quantity') order_date = request.form.get('order_date') shipping_date = request.form.get('shipping_date') - delivery_date = request.form['delivery_date'] # Create a session to interact with the database session = Session() @@ -100,8 +98,7 @@ def add_order(): product_code=product_code, product_quantity=product_quantity, order_date=order_date, - shipping_date=shipping_date, - delivery_date=delivery_date + shipping_date=shipping_date ) # Add the new order to the session and commit to the database diff --git a/templates/orders.html b/templates/orders.html index 9c58f4ba..9372e2d0 100644 --- a/templates/orders.html +++ b/templates/orders.html @@ -1,122 +1,82 @@ - + Order Management - - - + + +
-

Fictional Company Name

+

Fictional Company Name

- - + +
- +
-
-

Order List

- - - - - - - - - - - - - - - - {% for order in orders %} - - - - - - - - - - - - {% endfor %} - -
Date UUIDUser IDCard NumberStore CodeProduct CodeProduct QuantityOrder DateShipping DateDelivery Date
{{ order.date_uuid }}{{ order.user_id }}{{ order.card_number }}{{ order.store_code }}{{ order.product_code }}{{ order.product_quantity }}{{ order.order_date }}{{ order.shipping_date }}{{ order.delivery_date }}
- -
- + From b603792b2a4bbd5637cb335d9c1ab137cc60c191 Mon Sep 17 00:00:00 2001 From: Robin Winters Date: Tue, 6 Feb 2024 17:29:37 +0000 Subject: [PATCH 4/9] documentation - README.md updated --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index a2c82222..03a7035f 100644 --- a/README.md +++ b/README.md @@ -62,3 +62,6 @@ To run the application, you simply need to run the `app.py` script in this repos This project is licensed under the MIT License. For more details, refer to the [LICENSE](LICENSE) file. ## Robin Winters Azure End-to-End DevOps Pipeline Project + +1. _delivery-date column:_ delivery_date added to both backend (app.py) and frontend (order.html) files. +2. _removed delivery-date column:_ delivery_date removed from both backend (app.py) and frontend (order.html) files. From 77a572472a53adb7ee1a4fea8a2e7b9bcb26331e Mon Sep 17 00:00:00 2001 From: Robin Winters Date: Tue, 6 Feb 2024 18:34:27 +0000 Subject: [PATCH 5/9] Dockerfile create --- Dockerfile | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..b99f6912 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,27 @@ +# TODO: Step 1 - Use an official Python runtime as a parent image. You can use `python:3.8-slim`. +FROM python:3.8-slim +# TODO: Step 2 - Set the working directory in the container +WORKDIR /app.py +# TODO: Step 3 Copy the application files in the container +COPY . /app +# Install system dependencies and ODBC driver +RUN apt-get update && apt-get install -y \ + unixodbc unixodbc-dev odbcinst odbcinst1debian2 libpq-dev gcc && \ + apt-get install -y gnupg && \ + apt-get install -y wget && \ + wget -qO- https://packages.microsoft.com/keys/microsoft.asc | apt-key add - && \ + wget -qO- https://packages.microsoft.com/config/debian/10/prod.list > /etc/apt/sources.list.d/mssql-release.list && \ + apt-get update && \ + ACCEPT_EULA=Y apt-get install -y msodbcsql18 && \ + apt-get purge -y --auto-remove wget && \ + apt-get clean + +# Install pip and setuptools +RUN pip install --upgrade pip setuptools + +# TODO: Step 4 - Install Python packages specified in requirements.txt +RUN pip install --no-cache-dir -r requirements.txt +# TODO: Step 5 - Expose port +EXPOSE 5000 +# TODO: Step 6 - Define Startup Command +CMD ["python", "app.py"] \ No newline at end of file From 2bb3946ab4bcced5cd50999c24726b43afe323a8 Mon Sep 17 00:00:00 2001 From: Robin Winters Date: Tue, 6 Feb 2024 20:16:42 +0000 Subject: [PATCH 6/9] Dockerfile bug fixed and web-app-image created --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index b99f6912..53a970ba 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,9 @@ # TODO: Step 1 - Use an official Python runtime as a parent image. You can use `python:3.8-slim`. FROM python:3.8-slim # TODO: Step 2 - Set the working directory in the container -WORKDIR /app.py +WORKDIR /app # TODO: Step 3 Copy the application files in the container -COPY . /app +COPY . . # Install system dependencies and ODBC driver RUN apt-get update && apt-get install -y \ unixodbc unixodbc-dev odbcinst odbcinst1debian2 libpq-dev gcc && \ From 0ba8070f78e63dbf939b93c2c5eb88c43e036f1e Mon Sep 17 00:00:00 2001 From: Robin Winters Date: Tue, 6 Feb 2024 20:42:18 +0000 Subject: [PATCH 7/9] Readme.md updated docker info add --- README.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/README.md b/README.md index 03a7035f..e20b40b2 100644 --- a/README.md +++ b/README.md @@ -65,3 +65,14 @@ This project is licensed under the MIT License. For more details, refer to the [ 1. _delivery-date column:_ delivery_date added to both backend (app.py) and frontend (order.html) files. 2. _removed delivery-date column:_ delivery_date removed from both backend (app.py) and frontend (order.html) files. + +### Containerization + +1. Dockerfile created based on python:3.8-slim +2. Docker image builded. + **imagename:** web-app-image + **imagetag:** 1.0 +3. Image pushed to Docker Hub + +- Image can be seen from the link below +- https://hub.docker.com/repository/docker/robinwinters/web-app-image/general From 3c7a312dd6da3be15ab24122afb75c82d87b18b9 Mon Sep 17 00:00:00 2001 From: Robin Winters Date: Wed, 7 Feb 2024 15:31:31 +0000 Subject: [PATCH 8/9] aks-terraform modules setup --- .../networking-module/.terraform.lock.hcl | 21 ++++++ aks-terraform/networking-module/main.tf | 65 +++++++++++++++++++ aks-terraform/networking-module/output.tf | 25 +++++++ aks-terraform/networking-module/variables.tf | 18 +++++ 4 files changed, 129 insertions(+) create mode 100644 aks-terraform/networking-module/.terraform.lock.hcl create mode 100644 aks-terraform/networking-module/main.tf create mode 100644 aks-terraform/networking-module/output.tf create mode 100644 aks-terraform/networking-module/variables.tf diff --git a/aks-terraform/networking-module/.terraform.lock.hcl b/aks-terraform/networking-module/.terraform.lock.hcl new file mode 100644 index 00000000..49223d74 --- /dev/null +++ b/aks-terraform/networking-module/.terraform.lock.hcl @@ -0,0 +1,21 @@ +# This file is maintained automatically by "terraform init". +# Manual edits may be lost in future updates. + +provider "registry.terraform.io/hashicorp/azurerm" { + version = "3.90.0" + hashes = [ + "h1:8exKO4IgZ9qLImDCAig+cKgONFUV/gW6pIlXc9CnPVk=", + "zh:194a4342620958403beabf4d57d552133ca6ac18eef3027d6d1a98846b52f8ab", + "zh:1d8ee378aaa793e3288c9328e056763c98d0f2e8560357296bc3446fbd3b1b9d", + "zh:24aba7903e912570e36edb03f79c68028d3e254175947b588c96521f09f89df4", + "zh:27f91fbeef9d04c6382014b6c32883a96dbe91cf7a4fa07a97be5d6b03991f95", + "zh:59eeaa2f50f698bab6f36ada0e865d6b624625ff5d76309334b3c3aa366cb692", + "zh:732af42d18fa222ee88f7f97c0898d4955ae48fde5456e22af3b8f5d324c6b41", + "zh:766034eac5e6a66cf3631580956dd584b1c2e6134167302fc8b95d6b42ebf08b", + "zh:a5b2ec52abfc3fb154047af45ea692c98c646c2b5c336b12b6341a49be95025c", + "zh:bdd72f85d770fa4a2e6ebf542858341d3df7e858a4d70c0f94df758721bcd811", + "zh:e9f15f2399c667c24b3daf8a843f1cadd13bc619becf6362b46c3216b17009b1", + "zh:f569b65999264a9416862bca5cd2a6177d94ccb0424f3a4ef424428912b9cb3c", + "zh:f73b1ec8b372bc1480ca0d93e78914f1c9cebe81395f20273d7bc99579b84809", + ] +} diff --git a/aks-terraform/networking-module/main.tf b/aks-terraform/networking-module/main.tf new file mode 100644 index 00000000..cd8b42ba --- /dev/null +++ b/aks-terraform/networking-module/main.tf @@ -0,0 +1,65 @@ +# Create the Azure Resource Group for networking resources +resource "azurerm_resource_group" "networking" { + name = var.resource_group_name + location = var.location +} + +# Define the Virtual Network (VNet) for the AKS cluster +resource "azurerm_virtual_network" "aks_vnet" { + name = "aks-vnet" + address_space = var.vnet_address_space + location = azurerm_resource_group.networking.location + resource_group_name = azurerm_resource_group.networking.name +} + +# Define subnets within the VNet for control plane and worker nodes +resource "azurerm_subnet" "control_plane_subnet" { + name = "aks-subnet-control-plane" + resource_group_name = azurerm_resource_group.networking.name + virtual_network_name = azurerm_virtual_network.aks_vnet.name + address_prefixes = ["10.0.1.0/24"] +} + +resource "azurerm_subnet" "worker_node_subnet" { + name = "aks-node-subnet" + resource_group_name = azurerm_resource_group.networking.name + virtual_network_name = azurerm_virtual_network.aks_vnet.name + address_prefixes = ["10.0.2.0/24"] +} + +# Define Network Security Group (NSG) for the AKS subnet +resource "azurerm_network_security_group" "aks_nsg" { + name = "aks-nsg" + location = azurerm_resource_group.networking.location + resource_group_name = azurerm_resource_group.networking.name +} + +# Allow inbound traffic to kube-apiserver (TCP/443) from your public IP address +resource "azurerm_network_security_rule" "kube_apiserver" { + name = "aks-kubi-api-server" + priority = 1001 + direction = "Inbound" + access = "Allow" + protocol = "Tcp" + source_port_range = "*" + destination_port_range = "443" + source_address_prefix = "150.143.254.11" + destination_address_prefix = "*" + resource_group_name = azurerm_resource_group.networking.name + network_security_group_name = azurerm_network_security_group.aks_nsg.name +} + +# Allow inbound traffic for SSH (TCP/22) - Optional +resource "azurerm_network_security_rule" "ssh" { + name = "aks-ssh" + priority = 1002 + direction = "Inbound" + access = "Allow" + protocol = "Tcp" + source_port_range = "*" + destination_port_range = "22" + source_address_prefix = "150.143.254.11" + destination_address_prefix = "*" + resource_group_name = azurerm_resource_group.networking.name + network_security_group_name = azurerm_network_security_group.aks_nsg.name +} diff --git a/aks-terraform/networking-module/output.tf b/aks-terraform/networking-module/output.tf new file mode 100644 index 00000000..14d2da4b --- /dev/null +++ b/aks-terraform/networking-module/output.tf @@ -0,0 +1,25 @@ +output "vnet_id" { + description = "ID of the Virtual Network (VNet)." + value = azurerm_virtual_network.aks_vnet.id +} + +output "control_plane_subnet_id" { + description = "ID of the control plane subnet." + value = azurerm_subnet.control_plane_subnet.id +} + +output "worker_node_subnet_id" { + description = "ID of the worker node subnet." + value = azurerm_subnet.worker_node_subnet.id +} + +output "resource_group_name" { + description = "Name of the Azure Resource Group for networking resources." + value = azurerm_resource_group.networking.name +} + +# Define more output variables as needed... +output "aks_nsg_id" { + description = "ID of the Network Security Group (NSG) for AKS." + value = azurerm_network_security_group.aks_nsg.id +} diff --git a/aks-terraform/networking-module/variables.tf b/aks-terraform/networking-module/variables.tf new file mode 100644 index 00000000..d26938e1 --- /dev/null +++ b/aks-terraform/networking-module/variables.tf @@ -0,0 +1,18 @@ +variable "resource_group_name" { + description = "The Azure resource group where the networking resources will be created in" + type = string + default = "azure-devops-project-resource-group" + +} + +variable "location" { + description = "The Azure region where the networking resources will be deployed." + type = string + default = "UK South" +} + +variable "vnet_address_space" { + description = "Address space for the Virtual Network (VNet)." + type = list(string) + default = ["10.0.0.0/16"] +} From 10f0f9c8aff0e0d7071d2212cd6077de4b6125cd Mon Sep 17 00:00:00 2001 From: Robin Winters Date: Wed, 7 Feb 2024 16:06:43 +0000 Subject: [PATCH 9/9] terraform documentation --- .DS_Store | Bin 0 -> 6148 bytes .gitignore | 2 ++ README.md | 46 ++++++++++++++++++++++++++++++++++++++++ aks-terraform/.DS_Store | Bin 0 -> 6148 bytes 4 files changed, 48 insertions(+) create mode 100644 .DS_Store create mode 100644 .gitignore create mode 100644 aks-terraform/.DS_Store diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..c24bb85fc06f039a35800e9bdfbc883eb3393c1b GIT binary patch literal 6148 zcmeHK&ubGw6n>M&WYbc}L7^96!E22%l|u0n)8tT44_(oNO59Dhx^%M>vzw+80y&EQ zD}q=5lKwBA^m{W?*iE#jA}aI3%=c#Iee>gEXC^~LqB9-dC#n;XgTz?gMD`2gc1~+n zGBwN-s*j99n&9Wt$y&6nunJfO{x$`8?`~tio>EG8DZhUu_VMT_mV+Rc0itk3h>yUF zAI7d`2D5Z*nBRhN9Hm*ac_B(0Ol5nC3(J(~Fs~1r+l(UYUCc{*5J>B5coLaxWGoQEio4f8_>tM0#&JSAf zAMEWf7B%PAoqG?D`={|Jk)N;vn84YkY}?=^e1>y{HfP=>iDmK@QQSiXDvt4MAblw6 zMqkn1(6YfJ+N3T?8bEbEFHb0>=HSe}8RwQE+ueD}`QHTP?~vkF)R{(S}bd~lH%+Xj~!)zN`WJpq7a zR4aqeZwcnO2HOUg8qoq1nhMlZVV)R5(^2o5xVFKiMolMS9v{MtEX)f4H6s2Ej20% kGIJd(hp*xtBxPuG*#Wi5gg5S?}0MkWN@(m;-aUem^LN+9&2y6K_Usw9V|I8r215k(s$xjGnw&gqZI zHNT{Pr+u@#E)8x&LZFl|1G8^-cV=Y0k@tg$)M%1y5%r14gEDq{X#OBP&$=KTH_`CN@INxZwR=htouXPa<<%1_+;sC6FC?I_;Q(q`O$_Er~lloe@d0tNs&}0HnbC7&+Co* z>(l9QXRzUK4|iu9{&aT;`_=Z&Y}WJEo^QVXFh0%C3VmVNAcg;fkyVFt_y*$^Tzw78 zBG<(Uyyuzb83cs^VL%wTKLc)M@mB7iN-_uo!oUM#fY%2f${09oEt;hRjky8<`50*g zHXjc;#&;MvY%O92qHHM8hAMZ(P&ORnzVizlwiazTDR=o$?#asCP?UK(^83b}RA5nB zVL%wT&cKrG_Idw*_xJn%^&sg91H!