From 1ec2e859910c048655e27bc1515dd0d4dcf66cd5 Mon Sep 17 00:00:00 2001 From: chaitanyakotagiri27 Date: Tue, 16 Sep 2025 15:22:19 +1000 Subject: [PATCH 01/33] Point manifests to my ACR and current backend IPs --- frontend/main.js | 4 ++-- k8s/configmaps.yaml | 2 +- k8s/frontend.yaml | 2 +- k8s/order-service.yaml | 2 +- k8s/product-service.yaml | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/frontend/main.js b/frontend/main.js index f321fd91..0acca093 100644 --- a/frontend/main.js +++ b/frontend/main.js @@ -4,8 +4,8 @@ document.addEventListener('DOMContentLoaded', () => { // API endpoints for the Product and Order services. // These ports (30000 for Product, 30001 for Order) are mapped // from the Docker containers to the host machine in docker-compose.yml for Example 2. - const PRODUCT_API_BASE_URL = '_PRODUCT_API_URL_'; - const ORDER_API_BASE_URL = '_ORDER_API_URL_'; + const PRODUCT_API_BASE_URL = 'http://4.237.230.232:8000'; + const ORDER_API_BASE_URL = 'http://104.209.84.9:8001'; // Product Service is named 'product-service-w04e2' and exposes port 8000 internally. //const PRODUCT_API_BASE_URL = 'http://product-service-w04e2:8000'; diff --git a/k8s/configmaps.yaml b/k8s/configmaps.yaml index 5b38627c..0df0ac6a 100644 --- a/k8s/configmaps.yaml +++ b/k8s/configmaps.yaml @@ -12,4 +12,4 @@ data: AZURE_SAS_TOKEN_EXPIRY_HOURS: "24" PRODUCT_SERVICE_URL: http://product-service-w08e1:8000 - ORDER_SERVICE_URL: http://order-service-w08e1:8001 \ No newline at end of file + ORDER_SERVICE_URL: http://order-service-w08e1:8001 diff --git a/k8s/frontend.yaml b/k8s/frontend.yaml index 1948536d..f0c3228d 100644 --- a/k8s/frontend.yaml +++ b/k8s/frontend.yaml @@ -18,7 +18,7 @@ spec: spec: containers: - name: frontend-container - image: durgeshsamariya.azurecr.io/frontend:latest + image: sit722w08acr5104.azurecr.io/frontend:latest imagePullPolicy: Always ports: - containerPort: 80 diff --git a/k8s/order-service.yaml b/k8s/order-service.yaml index c9d92e4d..aa5fb556 100644 --- a/k8s/order-service.yaml +++ b/k8s/order-service.yaml @@ -18,7 +18,7 @@ spec: spec: containers: - name: order-service-container - image: durgeshsamariya.azurecr.io/order_service:latest + image: sit722w08acr5104.azurecr.io/order_service:latest imagePullPolicy: Always ports: - containerPort: 8000 diff --git a/k8s/product-service.yaml b/k8s/product-service.yaml index 0cbbd505..a5be132c 100644 --- a/k8s/product-service.yaml +++ b/k8s/product-service.yaml @@ -18,7 +18,7 @@ spec: spec: containers: - name: product-service-container - image: durgeshsamariya.azurecr.io/product_service:latest + image: sit722w08acr5104.azurecr.io/product_service:latest imagePullPolicy: Always ports: - containerPort: 8000 From da9cd08da05e6270ee1354c8dae9771a2ec70eb7 Mon Sep 17 00:00:00 2001 From: chaitanyakotagiri27 Date: Tue, 16 Sep 2025 15:35:12 +1000 Subject: [PATCH 02/33] 9.2C: backend CI - PR triggers, SHA+latest tags, login v2, ACR login fix --- .github/workflows/backend_ci.yml | 133 +++++++++++++------------------ 1 file changed, 55 insertions(+), 78 deletions(-) diff --git a/.github/workflows/backend_ci.yml b/.github/workflows/backend_ci.yml index d69725aa..4e8e5c4d 100644 --- a/.github/workflows/backend_ci.yml +++ b/.github/workflows/backend_ci.yml @@ -1,92 +1,72 @@ -# week08/.github/workflows/backend_ci.yml - name: Backend CI - Test, Build and Push Images to ACR -# Trigger the workflow on pushes to the 'main' branch -# You can also add 'pull_request:' to run on PRs on: - # Manual trigger workflow_dispatch: - - # Automatically on pushes to main branch push: - branches: - - main - paths: # Only trigger if changes are in backend directories + branches: [ main, development ] + paths: + - 'backend/**' + - '.github/workflows/backend_ci.yml' + pull_request: + branches: [ main, development ] + paths: - 'backend/**' - - '.github/workflows/backend_ci.yml' # Trigger if this workflow file changes + - '.github/workflows/backend_ci.yml' -# Define global environment variables that can be used across jobs env: - # ACR Login Server (e.g., myregistry.azurecr.io) - # This needs to be set as a GitHub Repository Secret + # e.g. sit722w08acr1234.azurecr.io — set as a repo secret ACR_LOGIN_SERVER: ${{ secrets.AZURE_CONTAINER_REGISTRY }} - # Dynamically generate image tags based on Git SHA and GitHub Run ID - # This provides unique, traceable tags for each image build - IMAGE_TAG: ${{ github.sha }}-${{ github.run_id }} jobs: - # Job 1: Run tests and linting for all backend services test_and_lint_backends: - runs-on: ubuntu-latest # Use a GitHub-hosted runner - + runs-on: ubuntu-latest services: - # Product DB container product_db: image: postgres:15 env: POSTGRES_USER: postgres POSTGRES_PASSWORD: postgres POSTGRES_DB: products - # Make pg_isready available so the service is healthy before tests run options: >- --health-cmd "pg_isready -U postgres" --health-interval 10s --health-timeout 5s --health-retries 5 - ports: - - 5432:5432 - - # Order DB + ports: [ "5432:5432" ] + order_db: image: postgres:15 env: POSTGRES_USER: postgres POSTGRES_PASSWORD: postgres POSTGRES_DB: orders - ports: - - 5433:5432 options: >- --health-cmd "pg_isready -U postgres" --health-interval 10s --health-timeout 5s --health-retries 5 + ports: [ "5433:5432" ] steps: - # 1. Checkout the repository code to the runner - - name: Checkout repository - uses: actions/checkout@v4 # Action to check out your repository code + - name: Checkout + uses: actions/checkout@v4 - # 2. Set up Python environment - - name: Set up Python 3.10 - uses: actions/setup-python@v5 # Action to set up Python environment + - name: Set up Python 3.10 (with pip cache) + uses: actions/setup-python@v5 with: python-version: '3.10' + cache: 'pip' - # 3. Install dependencies and run code quality checks - - name: Install dependencies - run: | # Use a multi-line script to install pip dependencies + - name: Install deps + run: | pip install --upgrade pip - # Loop through each backend service folder for req in backend/*/requirements.txt; do echo "Installing $req" pip install -r "$req" done - # Install CI tools pip install pytest httpx - # 5. Run tests for product service - - name: Run product_service tests + - name: Test product_service working-directory: backend/product_service env: POSTGRES_HOST: localhost @@ -94,11 +74,9 @@ jobs: POSTGRES_DB: products POSTGRES_USER: postgres POSTGRES_PASSWORD: postgres - run: | - pytest tests --maxfail=1 --disable-warnings -q - - # 6. Run tests for order service - - name: Run order_service tests + run: pytest tests --maxfail=1 --disable-warnings -q + + - name: Test order_service working-directory: backend/order_service env: POSTGRES_HOST: localhost @@ -106,41 +84,40 @@ jobs: POSTGRES_DB: orders POSTGRES_USER: postgres POSTGRES_PASSWORD: postgres - run: | - pytest tests --maxfail=1 --disable-warnings -q + run: pytest tests --maxfail=1 --disable-warnings -q - # Job 2: Build and Push Docker Images (runs only if tests pass) build_and_push_images: runs-on: ubuntu-latest needs: test_and_lint_backends + # Don't push images on PRs + if: ${{ github.event_name != 'pull_request' }} steps: - - name: Checkout repository - uses: actions/checkout@v4 - - # Azure login using a Service Principal secret - - name: Azure Login - uses: azure/login@v1 - with: - creds: ${{ secrets.AZURE_CREDENTIALS }} # Needs to be set as a GitHub Secret (Service Principal JSON) - - # Login to Azure Container Registry (ACR) - - name: Login to Azure Container Registry - run: az acr login --name ${{ env.ACR_LOGIN_SERVER }} - - # Build and Push Docker image for Product Service - - name: Build and Push Product Service Image - run: | - docker build -t ${{ env.ACR_LOGIN_SERVER }}/product_service:latest ./backend/product_service/ - docker push ${{ env.ACR_LOGIN_SERVER }}/product_service:latest - - # Build and Push Docker image for Order Service - - name: Build and Push Order Service Image - run: | - docker build -t ${{ env.ACR_LOGIN_SERVER }}/order_service:latest ./backend/order_service/ - docker push ${{ env.ACR_LOGIN_SERVER }}/order_service:latest - - # Logout from Azure for security (runs even if image push fails) - - name: Logout from Azure - run: az logout - if: always() + - name: Checkout + uses: actions/checkout@v4 + + - name: Azure Login (OIDC or SP JSON) + uses: azure/login@v2 + with: + creds: ${{ secrets.AZURE_CREDENTIALS }} + + - name: Login to Azure Container Registry + run: az acr login --name ${{ secrets.ACR_NAME }} + + - name: Build & Push Product Service (SHA + latest) + run: | + docker build -t ${{ env.ACR_LOGIN_SERVER }}/product_service:${{ github.sha }} ./backend/product_service/ + docker tag ${{ env.ACR_LOGIN_SERVER }}/product_service:${{ github.sha }} ${{ env.ACR_LOGIN_SERVER }}/product_service:latest + docker push ${{ env.ACR_LOGIN_SERVER }}/product_service:${{ github.sha }} + docker push ${{ env.ACR_LOGIN_SERVER }}/product_service:latest + + - name: Build & Push Order Service (SHA + latest) + run: | + docker build -t ${{ env.ACR_LOGIN_SERVER }}/order_service:${{ github.sha }} ./backend/order_service/ + docker tag ${{ env.ACR_LOGIN_SERVER }}/order_service:${{ github.sha }} ${{ env.ACR_LOGIN_SERVER }}/order_service:latest + docker push ${{ env.ACR_LOGIN_SERVER }}/order_service:${{ github.sha }} + docker push ${{ env.ACR_LOGIN_SERVER }}/order_service:latest + + - name: Logout Azure + if: always() + run: az logout From b13d60fd3f3ed52702466ee1ca18fac044811c83 Mon Sep 17 00:00:00 2001 From: chaitanyakotagiri27 Date: Tue, 16 Sep 2025 17:15:19 +1000 Subject: [PATCH 03/33] 9.2C: frontend CI -> login v2, SHA+latest tags, correct ACR login --- .github/workflows/frontend_ci.yml | 70 +++++++++++++------------------ 1 file changed, 30 insertions(+), 40 deletions(-) diff --git a/.github/workflows/frontend_ci.yml b/.github/workflows/frontend_ci.yml index 9f9e76d9..0eca316e 100644 --- a/.github/workflows/frontend_ci.yml +++ b/.github/workflows/frontend_ci.yml @@ -1,53 +1,43 @@ -# week08/.github/workflows/frontend_ci.yml - name: Frontend CI - Build & Push Image on: - # Manual trigger - workflow_dispatch: - - # Automatically on pushes to main branch - push: - branches: - - main - paths: # Only trigger if changes are in the frontend directory + workflow_dispatch: # let you run it manually + push: # also run on pushes to your branches + branches: [ task/9.2c, main ] + paths: - 'frontend/**' - - '.github/workflows/frontend_ci.yml' # Trigger if this workflow file changes + - '.github/workflows/frontend_ci.yml' -# Define global environment variables that can be used across jobs env: - # ACR Login Server (e.g., myregistry.azurecr.io) - # This needs to be set as a GitHub Repository Secret + # e.g. sit722w08acr1234.azurecr.io (set as repo secret) ACR_LOGIN_SERVER: ${{ secrets.AZURE_CONTAINER_REGISTRY }} - # Dynamically generate image tags based on Git SHA and GitHub Run ID - # This provides unique, traceable tags for each image build - IMAGE_TAG: ${{ github.sha }}-${{ github.run_id }} jobs: build_and_push_frontend: runs-on: ubuntu-latest steps: - - name: Checkout repository - uses: actions/checkout@v4 - - # Azure login using a Service Principal secret - - name: Azure Login - uses: azure/login@v1 - with: - creds: ${{ secrets.AZURE_CREDENTIALS }} - - # Login to Azure Container Registry (ACR) - - name: Login to Azure Container Registry - run: az acr login --name ${{ env.ACR_LOGIN_SERVER }} - - # Build and Push Docker image for Frontend - - name: Build and Push Frontend Image - run: | - docker build -t ${{ env.ACR_LOGIN_SERVER }}/frontend:latest ./frontend/ - docker push ${{ env.ACR_LOGIN_SERVER }}/frontend:latest - - # Logout from Azure for security (runs even if image push fails) - - name: Logout from Azure - run: az logout - if: always() + - name: Checkout repository + uses: actions/checkout@v4 + + # Use the newer login action + - name: Azure Login + uses: azure/login@v2 + with: + creds: ${{ secrets.AZURE_CREDENTIALS }} + + # IMPORTANT: az acr login expects the ACR **name**, not the login server + - name: Login to Azure Container Registry + run: az acr login --name ${{ secrets.ACR_NAME }} + + # Build once, tag twice (SHA + latest) + - name: Build and Push Frontend Image + run: | + docker build -t ${{ env.ACR_LOGIN_SERVER }}/frontend:${{ github.sha }} ./frontend/ + docker tag ${{ env.ACR_LOGIN_SERVER }}/frontend:${{ github.sha }} ${{ env.ACR_LOGIN_SERVER }}/frontend:latest + docker push ${{ env.ACR_LOGIN_SERVER }}/frontend:${{ github.sha }} + docker push ${{ env.ACR_LOGIN_SERVER }}/frontend:latest + + - name: Logout from Azure + if: always() + run: az logout From 9fa89443dea0740e0677af754fb5264fce82a740 Mon Sep 17 00:00:00 2001 From: chaitanyakotagiri27 Date: Tue, 16 Sep 2025 18:38:19 +1000 Subject: [PATCH 04/33] CD: use azure/login@v2 for backend-cd --- .github/workflows/backend-cd.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/backend-cd.yml b/.github/workflows/backend-cd.yml index 6035ed15..ab3bcefb 100644 --- a/.github/workflows/backend-cd.yml +++ b/.github/workflows/backend-cd.yml @@ -30,7 +30,7 @@ jobs: uses: actions/checkout@v4 - name: Log in to Azure - uses: azure/login@v1 + uses: azure/login@v2 with: creds: ${{ secrets.AZURE_CREDENTIALS }} enable-AzPSSession: true From 67ca86ddf147a7819467ead880653bcd3d365143 Mon Sep 17 00:00:00 2001 From: chaitanyakotagiri27 Date: Tue, 16 Sep 2025 19:59:59 +1000 Subject: [PATCH 05/33] Update frontend-cd.yml --- .github/workflows/frontend-cd.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/frontend-cd.yml b/.github/workflows/frontend-cd.yml index 0a0879c8..61d3ecae 100644 --- a/.github/workflows/frontend-cd.yml +++ b/.github/workflows/frontend-cd.yml @@ -50,7 +50,7 @@ jobs: # Azure login using a Service Principal secret - name: Azure Login - uses: azure/login@v1 + uses: azure/login@v2 with: creds: ${{ secrets.AZURE_CREDENTIALS }} From dd5db196f90157606c65434843e52cc620c0e63b Mon Sep 17 00:00:00 2001 From: chaitanyakotagiri27 Date: Tue, 16 Sep 2025 20:18:48 +1000 Subject: [PATCH 06/33] Update backend_ci.yml --- .github/workflows/backend_ci.yml | 95 ++++++++++++++------------------ 1 file changed, 40 insertions(+), 55 deletions(-) diff --git a/.github/workflows/backend_ci.yml b/.github/workflows/backend_ci.yml index 4e8e5c4d..a060ffd2 100644 --- a/.github/workflows/backend_ci.yml +++ b/.github/workflows/backend_ci.yml @@ -1,25 +1,20 @@ -name: Backend CI - Test, Build and Push Images to ACR +name: Backend CI — test, build & push (ACR) on: workflow_dispatch: push: - branches: [ main, development ] + branches: [ main, task/9.2c ] paths: - - 'backend/**' - - '.github/workflows/backend_ci.yml' - pull_request: - branches: [ main, development ] - paths: - - 'backend/**' - - '.github/workflows/backend_ci.yml' + - "backend/**" + - ".github/workflows/backend_ci.yml" env: - # e.g. sit722w08acr1234.azurecr.io — set as a repo secret - ACR_LOGIN_SERVER: ${{ secrets.AZURE_CONTAINER_REGISTRY }} + ACR_NAME: ${{ secrets.ACR_NAME }} # <— ACR registry NAME (no .azurecr.io) jobs: - test_and_lint_backends: + test_and_build: runs-on: ubuntu-latest + services: product_db: image: postgres:15 @@ -27,12 +22,10 @@ jobs: POSTGRES_USER: postgres POSTGRES_PASSWORD: postgres POSTGRES_DB: products + ports: [ "5432:5432" ] options: >- --health-cmd "pg_isready -U postgres" - --health-interval 10s - --health-timeout 5s - --health-retries 5 - ports: [ "5432:5432" ] + --health-interval 10s --health-timeout 5s --health-retries 5 order_db: image: postgres:15 @@ -40,31 +33,28 @@ jobs: POSTGRES_USER: postgres POSTGRES_PASSWORD: postgres POSTGRES_DB: orders + ports: [ "5433:5432" ] options: >- --health-cmd "pg_isready -U postgres" - --health-interval 10s - --health-timeout 5s - --health-retries 5 - ports: [ "5433:5432" ] + --health-interval 10s --health-timeout 5s --health-retries 5 steps: - - name: Checkout - uses: actions/checkout@v4 + - uses: actions/checkout@v4 - - name: Set up Python 3.10 (with pip cache) + - name: Set REGISTRY_SERVER env + run: echo "REGISTRY_SERVER=${{ env.ACR_NAME }}.azurecr.io" >> $GITHUB_ENV + + - name: Set up Python uses: actions/setup-python@v5 with: - python-version: '3.10' - cache: 'pip' + python-version: "3.10" - - name: Install deps + - name: Install deps (all backends) run: | - pip install --upgrade pip + pip install --upgrade pip pytest httpx for req in backend/*/requirements.txt; do - echo "Installing $req" - pip install -r "$req" + echo "Installing $req"; pip install -r "$req"; done - pip install pytest httpx - name: Test product_service working-directory: backend/product_service @@ -74,7 +64,7 @@ jobs: POSTGRES_DB: products POSTGRES_USER: postgres POSTGRES_PASSWORD: postgres - run: pytest tests --maxfail=1 --disable-warnings -q + run: pytest -q - name: Test order_service working-directory: backend/order_service @@ -84,39 +74,34 @@ jobs: POSTGRES_DB: orders POSTGRES_USER: postgres POSTGRES_PASSWORD: postgres - run: pytest tests --maxfail=1 --disable-warnings -q - - build_and_push_images: - runs-on: ubuntu-latest - needs: test_and_lint_backends - # Don't push images on PRs - if: ${{ github.event_name != 'pull_request' }} - - steps: - - name: Checkout - uses: actions/checkout@v4 + run: pytest -q - - name: Azure Login (OIDC or SP JSON) + # Build & push only on non-PR pushes + - name: Azure Login + if: github.event_name == 'push' uses: azure/login@v2 with: creds: ${{ secrets.AZURE_CREDENTIALS }} - - name: Login to Azure Container Registry - run: az acr login --name ${{ secrets.ACR_NAME }} + - name: ACR login (name, not FQDN) + if: github.event_name == 'push' + run: az acr login -n "${{ env.ACR_NAME }}" - - name: Build & Push Product Service (SHA + latest) + - name: Build & push product_service (SHA + latest) + if: github.event_name == 'push' run: | - docker build -t ${{ env.ACR_LOGIN_SERVER }}/product_service:${{ github.sha }} ./backend/product_service/ - docker tag ${{ env.ACR_LOGIN_SERVER }}/product_service:${{ github.sha }} ${{ env.ACR_LOGIN_SERVER }}/product_service:latest - docker push ${{ env.ACR_LOGIN_SERVER }}/product_service:${{ github.sha }} - docker push ${{ env.ACR_LOGIN_SERVER }}/product_service:latest + docker build -t $REGISTRY_SERVER/product_service:${GITHUB_SHA} ./backend/product_service + docker tag $REGISTRY_SERVER/product_service:${GITHUB_SHA} $REGISTRY_SERVER/product_service:latest + docker push $REGISTRY_SERVER/product_service:${GITHUB_SHA} + docker push $REGISTRY_SERVER/product_service:latest - - name: Build & Push Order Service (SHA + latest) + - name: Build & push order_service (SHA + latest) + if: github.event_name == 'push' run: | - docker build -t ${{ env.ACR_LOGIN_SERVER }}/order_service:${{ github.sha }} ./backend/order_service/ - docker tag ${{ env.ACR_LOGIN_SERVER }}/order_service:${{ github.sha }} ${{ env.ACR_LOGIN_SERVER }}/order_service:latest - docker push ${{ env.ACR_LOGIN_SERVER }}/order_service:${{ github.sha }} - docker push ${{ env.ACR_LOGIN_SERVER }}/order_service:latest + docker build -t $REGISTRY_SERVER/order_service:${GITHUB_SHA} ./backend/order_service + docker tag $REGISTRY_SERVER/order_service:${GITHUB_SHA} $REGISTRY_SERVER/order_service:latest + docker push $REGISTRY_SERVER/order_service:${GITHUB_SHA} + docker push $REGISTRY_SERVER/order_service:latest - name: Logout Azure if: always() From 24eb55657737a54fdf0826901c2a739d1a937903 Mon Sep 17 00:00:00 2001 From: chaitanyakotagiri27 Date: Tue, 16 Sep 2025 20:19:22 +1000 Subject: [PATCH 07/33] Update frontend_ci.yml --- .github/workflows/frontend_ci.yml | 41 ++++++++++++++----------------- 1 file changed, 18 insertions(+), 23 deletions(-) diff --git a/.github/workflows/frontend_ci.yml b/.github/workflows/frontend_ci.yml index 0eca316e..de446f52 100644 --- a/.github/workflows/frontend_ci.yml +++ b/.github/workflows/frontend_ci.yml @@ -1,43 +1,38 @@ -name: Frontend CI - Build & Push Image +name: Frontend CI — build & push (ACR) on: - workflow_dispatch: # let you run it manually - push: # also run on pushes to your branches - branches: [ task/9.2c, main ] + workflow_dispatch: + push: + branches: [ main, task/9.2c ] paths: - - 'frontend/**' - - '.github/workflows/frontend_ci.yml' + - "frontend/**" + - ".github/workflows/frontend_ci.yml" env: - # e.g. sit722w08acr1234.azurecr.io (set as repo secret) - ACR_LOGIN_SERVER: ${{ secrets.AZURE_CONTAINER_REGISTRY }} + ACR_NAME: ${{ secrets.ACR_NAME }} # <— ACR registry NAME jobs: - build_and_push_frontend: + build_frontend: runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@v4 + - uses: actions/checkout@v4 + + - name: Set REGISTRY_SERVER env + run: echo "REGISTRY_SERVER=${{ env.ACR_NAME }}.azurecr.io" >> $GITHUB_ENV - # Use the newer login action - name: Azure Login uses: azure/login@v2 with: creds: ${{ secrets.AZURE_CREDENTIALS }} - # IMPORTANT: az acr login expects the ACR **name**, not the login server - - name: Login to Azure Container Registry - run: az acr login --name ${{ secrets.ACR_NAME }} + - name: ACR login + run: az acr login -n "${{ env.ACR_NAME }}" - # Build once, tag twice (SHA + latest) - - name: Build and Push Frontend Image + - name: Build & push frontend (latest) run: | - docker build -t ${{ env.ACR_LOGIN_SERVER }}/frontend:${{ github.sha }} ./frontend/ - docker tag ${{ env.ACR_LOGIN_SERVER }}/frontend:${{ github.sha }} ${{ env.ACR_LOGIN_SERVER }}/frontend:latest - docker push ${{ env.ACR_LOGIN_SERVER }}/frontend:${{ github.sha }} - docker push ${{ env.ACR_LOGIN_SERVER }}/frontend:latest + docker build -t $REGISTRY_SERVER/frontend:latest ./frontend + docker push $REGISTRY_SERVER/frontend:latest - - name: Logout from Azure + - name: Logout Azure if: always() run: az logout From d20dc86b660495282ef00fc9208c0ad925ca30af Mon Sep 17 00:00:00 2001 From: chaitanyakotagiri27 Date: Tue, 16 Sep 2025 20:19:50 +1000 Subject: [PATCH 08/33] Update backend-cd.yml --- .github/workflows/backend-cd.yml | 101 ++++++++++++++----------------- 1 file changed, 45 insertions(+), 56 deletions(-) diff --git a/.github/workflows/backend-cd.yml b/.github/workflows/backend-cd.yml index ab3bcefb..ffb9a0a7 100644 --- a/.github/workflows/backend-cd.yml +++ b/.github/workflows/backend-cd.yml @@ -1,101 +1,90 @@ -name: CD - Deploy Backend Services to AKS +name: CD — Deploy Backend Services to AKS on: workflow_dispatch: inputs: aks_cluster_name: - description: 'Name of the AKS Cluster to deploy to' + description: "AKS cluster name" required: true - default: '' + default: "sit722-w08-aks" aks_resource_group: - description: 'Resource Group of the AKS Cluster' + description: "AKS resource group" required: true - default: '' + default: "sit722-w08-rg" aks_acr_name: - description: 'Name of ACR' + description: "ACR registry NAME" required: true - default: '' + default: "sit722w08acr27234" jobs: deploy_backend: runs-on: ubuntu-latest environment: Production - + outputs: - PRODUCT_API_IP: ${{ steps.get_product_ip.outputs.external_ip }} - ORDER_API_IP: ${{ steps.get_order_ip.outputs.external_ip }} + PRODUCT_API_IP: ${{ steps.out_prod_ip.outputs.external_ip }} + ORDER_API_IP: ${{ steps.out_order_ip.outputs.external_ip }} steps: - - name: Checkout repository - uses: actions/checkout@v4 + - uses: actions/checkout@v4 - - name: Log in to Azure + - name: Azure Login uses: azure/login@v2 with: creds: ${{ secrets.AZURE_CREDENTIALS }} enable-AzPSSession: true - - name: Set Kubernetes context (get AKS credentials) + - name: Get AKS credentials run: | - az aks get-credentials --resource-group ${{ github.event.inputs.aks_resource_group }} --name ${{ github.event.inputs.aks_cluster_name }} --overwrite-existing + az aks get-credentials \ + --resource-group "${{ github.event.inputs.aks_resource_group }}" \ + --name "${{ github.event.inputs.aks_cluster_name }}" \ + --overwrite-existing - - name: Attach ACR + - name: Attach ACR (safe if already attached) run: | - az aks update --name ${{ github.event.inputs.aks_cluster_name }} --resource-group ${{ github.event.inputs.aks_resource_group }} --attach-acr ${{ github.event.inputs.aks_acr_name }} + az aks update \ + --name "${{ github.event.inputs.aks_cluster_name }}" \ + --resource-group "${{ github.event.inputs.aks_resource_group }}" \ + --attach-acr "${{ github.event.inputs.aks_acr_name }}" - - name: Deploy Backend Infrastructure (Namespace, ConfigMaps, Secrets, Databases) + - name: Apply infra (config, secrets, DBs) + working-directory: k8s run: | - echo "Deploying backend infrastructure..." - cd k8s/ kubectl apply -f configmaps.yaml kubectl apply -f secrets.yaml kubectl apply -f product-db.yaml kubectl apply -f order-db.yaml - - name: Deploy Backend Microservices (Product, Order) + - name: Deploy product & order services + working-directory: k8s run: | - echo "Deploying backend microservices..." - cd k8s/ kubectl apply -f product-service.yaml kubectl apply -f order-service.yaml - - - name: Wait for Backend LoadBalancer IPs - run: | - echo "Waiting for Product, Order LoadBalancer IPs to be assigned (up to 5 minutes)..." - PRODUCT_IP="" - ORDER_IP="" - - for i in $(seq 1 60); do - echo "Attempt $i/60 to get IPs..." - PRODUCT_IP=$(kubectl get service product-service-w08e1 -o jsonpath='{.status.loadBalancer.ingress[0].ip}') - ORDER_IP=$(kubectl get service order-service-w08e1 -o jsonpath='{.status.loadBalancer.ingress[0].ip}') - if [[ -n "$PRODUCT_IP" && -n "$ORDER_IP" ]]; then - echo "All backend LoadBalancer IPs assigned!" - echo "Product Service IP: $PRODUCT_IP" - echo "Order Service IP: $ORDER_IP" - break + - name: Wait for LoadBalancer IPs (≤5 min) + shell: bash + run: | + set -e + for i in {1..60}; do + PROD_IP=$(kubectl get svc product-service-w08e1 -o jsonpath='{.status.loadBalancer.ingress[0].ip}') + ORD_IP=$(kubectl get svc order-service-w08e1 -o jsonpath='{.status.loadBalancer.ingress[0].ip}') + echo "Attempt $i: product=$PROD_IP order=$ORD_IP" + if [[ -n "$PROD_IP" && -n "$ORD_IP" ]]; then + echo "PRODUCT_IP=$PROD_IP" >> $GITHUB_ENV + echo "ORDER_IP=$ORD_IP" >> $GITHUB_ENV + exit 0 fi - sleep 5 # Wait 5 seconds before next attempt + sleep 5 done - - if [[ -z "$PRODUCT_IP" || -z "$ORDER_IP" ]]; then - echo "Error: One or more LoadBalancer IPs not assigned after timeout." - exit 1 # Fail the job if IPs are not obtained - fi - - # These are environment variables for subsequent steps in the *same job* - # And used to set the job outputs - echo "PRODUCT_IP=$PRODUCT_IP" >> $GITHUB_ENV - echo "ORDER_IP=$ORDER_IP" >> $GITHUB_ENV + echo "Timed out waiting for external IPs"; exit 1 - - name: Capture Product Service IP for Workflow Output - id: get_product_ip + - id: out_prod_ip run: echo "external_ip=${{ env.PRODUCT_IP }}" >> $GITHUB_OUTPUT - - - name: Capture Order Service IP for Workflow Output - id: get_order_ip + + - id: out_order_ip run: echo "external_ip=${{ env.ORDER_IP }}" >> $GITHUB_OUTPUT - - name: Logout from Azure + - name: Logout Azure + if: always() run: az logout From 69a2cd7366a28b438c4fef201829bd1bd1c98cae Mon Sep 17 00:00:00 2001 From: chaitanyakotagiri27 Date: Tue, 16 Sep 2025 20:23:01 +1000 Subject: [PATCH 09/33] Update frontend-cd.yml --- .github/workflows/frontend-cd.yml | 108 +++++++++++++----------------- 1 file changed, 45 insertions(+), 63 deletions(-) diff --git a/.github/workflows/frontend-cd.yml b/.github/workflows/frontend-cd.yml index 61d3ecae..0c45af88 100644 --- a/.github/workflows/frontend-cd.yml +++ b/.github/workflows/frontend-cd.yml @@ -1,93 +1,75 @@ -# week08/.github/workflows/frontend-cd.yml +name: CD — Deploy Frontend to AKS -name: CD - Deploy Frontend to AKS - -# This workflow can be called by other workflows and takes inputs. -# Or it can be run manually if you provide the IPs. on: workflow_dispatch: inputs: - product_api_ip: - description: 'External IP of Product Service' - required: true - default: 'http://:8000' - order_api_ip: - description: 'External IP of Order Service (e.g., http://Y.Y.Y.Y:8001)' - required: true - default: 'http://:8001' aks_cluster_name: - description: 'Name of the AKS Cluster to deploy to' + description: "AKS cluster name" required: true - default: '' + default: "sit722-w08-aks" aks_resource_group: - description: 'Resource Group of the AKS Cluster' + description: "AKS resource group" required: true - default: '<' - - workflow_call: - inputs: - product_api_ip: + default: "sit722-w08-rg" + aks_acr_name: + description: "ACR registry NAME (no .azurecr.io)" required: true - type: string - order_api_ip: - required: true - type: string - aks_cluster_name: - required: true - type: string - aks_resource_group: - required: true - type: string + default: "sit722w08acr27234" jobs: deploy_frontend: runs-on: ubuntu-latest environment: Production + outputs: + FRONTEND_IP: ${{ steps.out_fe_ip.outputs.external_ip }} + steps: - - name: Checkout repository - uses: actions/checkout@v4 + - uses: actions/checkout@v4 - # Azure login using a Service Principal secret - name: Azure Login uses: azure/login@v2 with: creds: ${{ secrets.AZURE_CREDENTIALS }} - # Login to Azure Container Registry (ACR) - - name: Login to Azure Container Registry - run: az acr login --name ${{ secrets.AZURE_CONTAINER_REGISTRY }} - - - name: Inject Backend IPs into Frontend main.js + - name: Get AKS credentials run: | - echo "Injecting IPs into frontend/static/js/main.js" - # Ensure frontend/main.js is directly in the path for sed - sed -i "s|_PRODUCT_API_URL_|${{ inputs.product_api_ip }}|g" frontend/main.js - sed -i "s|_ORDER_API_URL_|${{ inputs.order_api_ip }}|g" frontend/main.js - - # Display the modified file content for debugging - echo "--- Modified main.js content ---" - cat frontend/main.js - echo "---------------------------------" + az aks get-credentials \ + --resource-group "${{ github.event.inputs.aks_resource_group }}" \ + --name "${{ github.event.inputs.aks_cluster_name }}" \ + --overwrite-existing - # Build and Push Docker image for Frontend - - name: Build and Push Frontend Image + - name: Attach ACR (safe if already attached) run: | - docker build -t ${{ secrets.AZURE_CONTAINER_REGISTRY }}/frontend:latest ./frontend/ - docker push ${{ secrets.AZURE_CONTAINER_REGISTRY }}/frontend:latest - - - name: Set Kubernetes context (get AKS credentials) - uses: azure/aks-set-context@v3 - with: - resource-group: ${{ inputs.aks_resource_group }} - cluster-name: ${{ inputs.aks_cluster_name }} + az aks update \ + --name "${{ github.event.inputs.aks_cluster_name }}" \ + --resource-group "${{ github.event.inputs.aks_resource_group }}" \ + --attach-acr "${{ github.event.inputs.aks_acr_name }}" - - name: Deploy Frontend to AKS + - name: Apply frontend manifest + working-directory: k8s run: | - echo "Deploying frontend with latest tag to AKS cluster: ${{ inputs.aks_cluster_name }}" - cd k8s/ - # Ensure frontend-service.yaml is configured with your ACR kubectl apply -f frontend.yaml + kubectl rollout status deploy/frontend -n default --timeout=180s || true + + - name: Wait for frontend external IP (≤5 min) + shell: bash + run: | + set -e + for i in {1..60}; do + FE_IP=$(kubectl get svc frontend-w08e1 -o jsonpath='{.status.loadBalancer.ingress[0].ip}') + echo "Attempt $i: frontend=$FE_IP" + if [[ -n "$FE_IP" ]]; then + echo "FRONTEND_IP=$FE_IP" >> $GITHUB_ENV + exit 0 + fi + sleep 5 + done + echo "Timed out waiting for frontend external IP"; exit 1 + + - id: out_fe_ip + run: echo "external_ip=${{ env.FRONTEND_IP }}" >> $GITHUB_OUTPUT - - name: Logout from Azure (AKS deployment) + - name: Logout Azure + if: always() run: az logout From a6f4c80587090d48fd86180bcd4b99a59a34eb0a Mon Sep 17 00:00:00 2001 From: chaitanyakotagiri27 Date: Tue, 16 Sep 2025 20:47:37 +1000 Subject: [PATCH 10/33] Trigger CI to push SHA tags From 5bc7db4e0714eac375a795a24bfb0b40a6a45b90 Mon Sep 17 00:00:00 2001 From: chaitanyakotagiri27 Date: Tue, 16 Sep 2025 21:04:01 +1000 Subject: [PATCH 11/33] Update frontend_ci.yml --- .github/workflows/frontend_ci.yml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/frontend_ci.yml b/.github/workflows/frontend_ci.yml index de446f52..acdf6adc 100644 --- a/.github/workflows/frontend_ci.yml +++ b/.github/workflows/frontend_ci.yml @@ -28,10 +28,14 @@ jobs: - name: ACR login run: az acr login -n "${{ env.ACR_NAME }}" - - name: Build & push frontend (latest) + - name: Build & push frontend (SHA + latest) run: | - docker build -t $REGISTRY_SERVER/frontend:latest ./frontend - docker push $REGISTRY_SERVER/frontend:latest + # REGISTRY_SERVER is set earlier to ".azurecr.io" + docker build -t $REGISTRY_SERVER/frontend:${GITHUB_SHA} ./frontend + docker tag $REGISTRY_SERVER/frontend:${GITHUB_SHA} $REGISTRY_SERVER/frontend:latest + docker push $REGISTRY_SERVER/frontend:${GITHUB_SHA} + docker push $REGISTRY_SERVER/frontend:latest + - name: Logout Azure if: always() From ff48566d5627b6efc2e26f404ca5199a2635ba75 Mon Sep 17 00:00:00 2001 From: chaitanyakotagiri27 Date: Tue, 16 Sep 2025 21:09:55 +1000 Subject: [PATCH 12/33] Update frontend_ci.yml --- .github/workflows/frontend_ci.yml | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/.github/workflows/frontend_ci.yml b/.github/workflows/frontend_ci.yml index acdf6adc..386cf8dc 100644 --- a/.github/workflows/frontend_ci.yml +++ b/.github/workflows/frontend_ci.yml @@ -1,15 +1,17 @@ -name: Frontend CI — build & push (ACR) +# .github/workflows/frontend_ci.yml +name: Frontend CI - build & push (ACR) on: workflow_dispatch: push: branches: [ main, task/9.2c ] paths: - - "frontend/**" - - ".github/workflows/frontend_ci.yml" + - frontend/** + - .github/workflows/frontend_ci.yml env: - ACR_NAME: ${{ secrets.ACR_NAME }} # <— ACR registry NAME + # Repository secret holding the plain ACR NAME (e.g., sit722w08acr27234) + ACR_NAME: ${{ secrets.ACR_NAME }} jobs: build_frontend: @@ -18,7 +20,7 @@ jobs: - uses: actions/checkout@v4 - name: Set REGISTRY_SERVER env - run: echo "REGISTRY_SERVER=${{ env.ACR_NAME }}.azurecr.io" >> $GITHUB_ENV + run: echo "REGISTRY_SERVER=${{ env.ACR_NAME }}.azurecr.io" >> "$GITHUB_ENV" - name: Azure Login uses: azure/login@v2 @@ -28,15 +30,14 @@ jobs: - name: ACR login run: az acr login -n "${{ env.ACR_NAME }}" - - name: Build & push frontend (SHA + latest) + - name: Build & push frontend (SHA + latest) run: | - # REGISTRY_SERVER is set earlier to ".azurecr.io" - docker build -t $REGISTRY_SERVER/frontend:${GITHUB_SHA} ./frontend - docker tag $REGISTRY_SERVER/frontend:${GITHUB_SHA} $REGISTRY_SERVER/frontend:latest - docker push $REGISTRY_SERVER/frontend:${GITHUB_SHA} - docker push $REGISTRY_SERVER/frontend:latest - + set -e + docker build -t "$REGISTRY_SERVER/frontend:${GITHUB_SHA}" ./frontend + docker tag "$REGISTRY_SERVER/frontend:${GITHUB_SHA}" "$REGISTRY_SERVER/frontend:latest" + docker push "$REGISTRY_SERVER/frontend:${GITHUB_SHA}" + docker push "$REGISTRY_SERVER/frontend:latest" - name: Logout Azure if: always() - run: az logout + run: az logout || true From 13221c214685c9aa1c8b1d23d415d920b2e31db4 Mon Sep 17 00:00:00 2001 From: chaitanyakotagiri27 Date: Wed, 17 Sep 2025 17:20:14 +1000 Subject: [PATCH 13/33] fix(cd): use repo vars + namespace; idempotent ACR attach --- .github/workflows/backend-cd.yml | 63 +++++++++++++------------------- 1 file changed, 26 insertions(+), 37 deletions(-) diff --git a/.github/workflows/backend-cd.yml b/.github/workflows/backend-cd.yml index ffb9a0a7..ead03235 100644 --- a/.github/workflows/backend-cd.yml +++ b/.github/workflows/backend-cd.yml @@ -1,20 +1,15 @@ name: CD — Deploy Backend Services to AKS on: - workflow_dispatch: - inputs: - aks_cluster_name: - description: "AKS cluster name" - required: true - default: "sit722-w08-aks" - aks_resource_group: - description: "AKS resource group" - required: true - default: "sit722-w08-rg" - aks_acr_name: - description: "ACR registry NAME" - required: true - default: "sit722w08acr27234" + workflow_dispatch: {} + +env: + RG: ${{ vars.AKS_RESOURCE_GROUP }} + AKS: ${{ vars.AKS_CLUSTER_NAME }} + NS: ${{ vars.AKS_NAMESPACE }} + ACR_NAME: ${{ vars.ACR_NAME }} + PRODUCT_SVC: product-service # change if your k8s Service has a suffix + ORDER_SVC: order-service # change if your k8s Service has a suffix jobs: deploy_backend: @@ -32,44 +27,38 @@ jobs: uses: azure/login@v2 with: creds: ${{ secrets.AZURE_CREDENTIALS }} - enable-AzPSSession: true - name: Get AKS credentials - run: | - az aks get-credentials \ - --resource-group "${{ github.event.inputs.aks_resource_group }}" \ - --name "${{ github.event.inputs.aks_cluster_name }}" \ - --overwrite-existing + run: az aks get-credentials --resource-group "$RG" --name "$AKS" --overwrite-existing - - name: Attach ACR (safe if already attached) - run: | - az aks update \ - --name "${{ github.event.inputs.aks_cluster_name }}" \ - --resource-group "${{ github.event.inputs.aks_resource_group }}" \ - --attach-acr "${{ github.event.inputs.aks_acr_name }}" + - name: Ensure namespace exists + run: kubectl get ns "$NS" || kubectl create ns "$NS" + + - name: Attach ACR (idempotent) + run: az aks update --name "$AKS" --resource-group "$RG" --attach-acr "$ACR_NAME" - - name: Apply infra (config, secrets, DBs) + - name: Apply infra (ConfigMaps, Secrets, DBs) working-directory: k8s run: | - kubectl apply -f configmaps.yaml - kubectl apply -f secrets.yaml - kubectl apply -f product-db.yaml - kubectl apply -f order-db.yaml + kubectl -n "$NS" apply -f configmaps.yaml + kubectl -n "$NS" apply -f secrets.yaml + kubectl -n "$NS" apply -f product-db.yaml + kubectl -n "$NS" apply -f order-db.yaml - name: Deploy product & order services working-directory: k8s run: | - kubectl apply -f product-service.yaml - kubectl apply -f order-service.yaml + kubectl -n "$NS" apply -f product-service.yaml + kubectl -n "$NS" apply -f order-service.yaml - name: Wait for LoadBalancer IPs (≤5 min) shell: bash run: | set -e for i in {1..60}; do - PROD_IP=$(kubectl get svc product-service-w08e1 -o jsonpath='{.status.loadBalancer.ingress[0].ip}') - ORD_IP=$(kubectl get svc order-service-w08e1 -o jsonpath='{.status.loadBalancer.ingress[0].ip}') - echo "Attempt $i: product=$PROD_IP order=$ORD_IP" + PROD_IP=$(kubectl -n "$NS" get svc "$PRODUCT_SVC" -o jsonpath='{.status.loadBalancer.ingress[0].ip}') + ORD_IP=$(kubectl -n "$NS" get svc "$ORDER_SVC" -o jsonpath='{.status.loadBalancer.ingress[0].ip}') + echo "Attempt $i: product=${PROD_IP:-} order=${ORD_IP:-}" if [[ -n "$PROD_IP" && -n "$ORD_IP" ]]; then echo "PRODUCT_IP=$PROD_IP" >> $GITHUB_ENV echo "ORDER_IP=$ORD_IP" >> $GITHUB_ENV @@ -85,6 +74,6 @@ jobs: - id: out_order_ip run: echo "external_ip=${{ env.ORDER_IP }}" >> $GITHUB_OUTPUT - - name: Logout Azure + - name: Azure Logout if: always() run: az logout From 888c8f08248dba7cd4e938a8f2eae9d6e7e4a866 Mon Sep 17 00:00:00 2001 From: chaitanyakotagiri27 Date: Wed, 17 Sep 2025 17:20:15 +1000 Subject: [PATCH 14/33] ci: trigger Backend CI via push From 5a8319a6806770564af44aaabd3a819bcdf99ae2 Mon Sep 17 00:00:00 2001 From: chaitanyakotagiri27 Date: Wed, 17 Sep 2025 17:26:31 +1000 Subject: [PATCH 15/33] chore: k8s updates --- k8s/frontend.yaml | 2 +- k8s/order-service.yaml | 2 +- k8s/product-service.yaml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/k8s/frontend.yaml b/k8s/frontend.yaml index f0c3228d..0b52ab16 100644 --- a/k8s/frontend.yaml +++ b/k8s/frontend.yaml @@ -18,7 +18,7 @@ spec: spec: containers: - name: frontend-container - image: sit722w08acr5104.azurecr.io/frontend:latest + image: sit722w08acr27234.azurecr.io/frontend:latest imagePullPolicy: Always ports: - containerPort: 80 diff --git a/k8s/order-service.yaml b/k8s/order-service.yaml index aa5fb556..7a4a9fbe 100644 --- a/k8s/order-service.yaml +++ b/k8s/order-service.yaml @@ -18,7 +18,7 @@ spec: spec: containers: - name: order-service-container - image: sit722w08acr5104.azurecr.io/order_service:latest + image: sit722w08acr27234.azurecr.io/order_service:latest imagePullPolicy: Always ports: - containerPort: 8000 diff --git a/k8s/product-service.yaml b/k8s/product-service.yaml index a5be132c..f868a90e 100644 --- a/k8s/product-service.yaml +++ b/k8s/product-service.yaml @@ -18,7 +18,7 @@ spec: spec: containers: - name: product-service-container - image: sit722w08acr5104.azurecr.io/product_service:latest + image: sit722w08acr27234.azurecr.io/product_service:latest imagePullPolicy: Always ports: - containerPort: 8000 From d1366c1b09999dfc4e5ed47475e2731a925fea36 Mon Sep 17 00:00:00 2001 From: chaitanyakotagiri27 Date: Wed, 17 Sep 2025 17:27:22 +1000 Subject: [PATCH 16/33] ci: trigger backend build & push --- backend/ci-trigger.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 backend/ci-trigger.txt diff --git a/backend/ci-trigger.txt b/backend/ci-trigger.txt new file mode 100644 index 00000000..bf7a85ac --- /dev/null +++ b/backend/ci-trigger.txt @@ -0,0 +1 @@ +// trigger 17-09-2025 17:27:21.87 From f84c508b24431ac830630a87eff966fc04787902 Mon Sep 17 00:00:00 2001 From: chaitanyakotagiri27 Date: Wed, 17 Sep 2025 18:03:42 +1000 Subject: [PATCH 17/33] cd: ignore attach-acr RBAC; kubelet already has AcrPull --- .github/workflows/backend-cd.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/backend-cd.yml b/.github/workflows/backend-cd.yml index ead03235..a9046e8f 100644 --- a/.github/workflows/backend-cd.yml +++ b/.github/workflows/backend-cd.yml @@ -34,7 +34,8 @@ jobs: - name: Ensure namespace exists run: kubectl get ns "$NS" || kubectl create ns "$NS" - - name: Attach ACR (idempotent) + - name: Attach ACR (idempotent; ignore if no rights) + continue-on-error: true run: az aks update --name "$AKS" --resource-group "$RG" --attach-acr "$ACR_NAME" - name: Apply infra (ConfigMaps, Secrets, DBs) From 46d34093af8cfc46b16f2df4059ff5aaeb2ee905 Mon Sep 17 00:00:00 2001 From: chaitanyakotagiri27 Date: Wed, 17 Sep 2025 18:12:53 +1000 Subject: [PATCH 18/33] cd: tolerate attach-acr; auto-detect service names; wait for IPs --- .github/workflows/backend-cd.yml | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/.github/workflows/backend-cd.yml b/.github/workflows/backend-cd.yml index a9046e8f..f0d6a1a3 100644 --- a/.github/workflows/backend-cd.yml +++ b/.github/workflows/backend-cd.yml @@ -1,3 +1,4 @@ +powershell -NoP -C "@' name: CD — Deploy Backend Services to AKS on: @@ -8,8 +9,8 @@ env: AKS: ${{ vars.AKS_CLUSTER_NAME }} NS: ${{ vars.AKS_NAMESPACE }} ACR_NAME: ${{ vars.ACR_NAME }} - PRODUCT_SVC: product-service # change if your k8s Service has a suffix - ORDER_SVC: order-service # change if your k8s Service has a suffix + PRODUCT_SVC: "" # leave blank to auto-detect + ORDER_SVC: "" # leave blank to auto-detect jobs: deploy_backend: @@ -52,13 +53,25 @@ jobs: kubectl -n "$NS" apply -f product-service.yaml kubectl -n "$NS" apply -f order-service.yaml + - name: Detect service names (product/order) + shell: bash + run: | + set -e + PROD_NAME="${PRODUCT_SVC:-}" + ORD_NAME="${ORDER_SVC:-}" + [[ -z "$PROD_NAME" ]] && PROD_NAME=$(kubectl -n "$NS" get svc -o jsonpath='{range .items[*]}{.metadata.name}{"\n"}{end}' | grep -E '^product' | head -1 || true) + [[ -z "$ORD_NAME" ]] && ORD_NAME=$(kubectl -n "$NS" get svc -o jsonpath='{range .items[*]}{.metadata.name}{"\n"}{end}' | grep -E '^order' | head -1 || true) + echo "Detected: product=${PROD_NAME:-} order=${ORD_NAME:-}" + echo PRODUCT_SVC=$PROD_NAME >> $GITHUB_ENV + echo ORDER_SVC=$ORD_NAME >> $GITHUB_ENV + - name: Wait for LoadBalancer IPs (≤5 min) shell: bash run: | set -e for i in {1..60}; do - PROD_IP=$(kubectl -n "$NS" get svc "$PRODUCT_SVC" -o jsonpath='{.status.loadBalancer.ingress[0].ip}') - ORD_IP=$(kubectl -n "$NS" get svc "$ORDER_SVC" -o jsonpath='{.status.loadBalancer.ingress[0].ip}') + PROD_IP=$(kubectl -n "$NS" get svc "$PRODUCT_SVC" -o jsonpath='{.status.loadBalancer.ingress[0].ip}' 2>/dev/null || true) + ORD_IP=$(kubectl -n "$NS" get svc "$ORDER_SVC" -o jsonpath='{.status.loadBalancer.ingress[0].ip}' 2>/dev/null || true) echo "Attempt $i: product=${PROD_IP:-} order=${ORD_IP:-}" if [[ -n "$PROD_IP" && -n "$ORD_IP" ]]; then echo "PRODUCT_IP=$PROD_IP" >> $GITHUB_ENV @@ -67,7 +80,7 @@ jobs: fi sleep 5 done - echo "Timed out waiting for external IPs"; exit 1 + echo 'Timed out waiting for external IPs'; exit 1 - id: out_prod_ip run: echo "external_ip=${{ env.PRODUCT_IP }}" >> $GITHUB_OUTPUT @@ -78,3 +91,4 @@ jobs: - name: Azure Logout if: always() run: az logout +'@ | Set-Content -Encoding UTF8 .github/workflows/backend-cd.yml" From 8e6fc2b55e9b9d27508d67be8f04c2674ac566c1 Mon Sep 17 00:00:00 2001 From: chaitanyakotagiri27 Date: Wed, 17 Sep 2025 18:17:39 +1000 Subject: [PATCH 19/33] cd: remove environment gate; tolerate attach-acr; auto-detect svc names; wait for IPs --- .github/workflows/backend-cd.yml | 49 ++++++++++++++++---------------- 1 file changed, 24 insertions(+), 25 deletions(-) diff --git a/.github/workflows/backend-cd.yml b/.github/workflows/backend-cd.yml index f0d6a1a3..ed574d4f 100644 --- a/.github/workflows/backend-cd.yml +++ b/.github/workflows/backend-cd.yml @@ -9,13 +9,10 @@ env: AKS: ${{ vars.AKS_CLUSTER_NAME }} NS: ${{ vars.AKS_NAMESPACE }} ACR_NAME: ${{ vars.ACR_NAME }} - PRODUCT_SVC: "" # leave blank to auto-detect - ORDER_SVC: "" # leave blank to auto-detect jobs: deploy_backend: runs-on: ubuntu-latest - environment: Production outputs: PRODUCT_API_IP: ${{ steps.out_prod_ip.outputs.external_ip }} @@ -30,38 +27,36 @@ jobs: creds: ${{ secrets.AZURE_CREDENTIALS }} - name: Get AKS credentials - run: az aks get-credentials --resource-group "$RG" --name "$AKS" --overwrite-existing + run: az aks get-credentials --resource-group \"$RG\" --name \"$AKS\" --overwrite-existing - name: Ensure namespace exists - run: kubectl get ns "$NS" || kubectl create ns "$NS" + run: kubectl get ns \"$NS\" || kubectl create ns \"$NS\" - name: Attach ACR (idempotent; ignore if no rights) continue-on-error: true - run: az aks update --name "$AKS" --resource-group "$RG" --attach-acr "$ACR_NAME" + run: az aks update --name \"$AKS\" --resource-group \"$RG\" --attach-acr \"$ACR_NAME\" - name: Apply infra (ConfigMaps, Secrets, DBs) working-directory: k8s run: | - kubectl -n "$NS" apply -f configmaps.yaml - kubectl -n "$NS" apply -f secrets.yaml - kubectl -n "$NS" apply -f product-db.yaml - kubectl -n "$NS" apply -f order-db.yaml + kubectl -n \"$NS\" apply -f configmaps.yaml + kubectl -n \"$NS\" apply -f secrets.yaml + kubectl -n \"$NS\" apply -f product-db.yaml + kubectl -n \"$NS\" apply -f order-db.yaml - name: Deploy product & order services working-directory: k8s run: | - kubectl -n "$NS" apply -f product-service.yaml - kubectl -n "$NS" apply -f order-service.yaml + kubectl -n \"$NS\" apply -f product-service.yaml + kubectl -n \"$NS\" apply -f order-service.yaml - name: Detect service names (product/order) shell: bash run: | set -e - PROD_NAME="${PRODUCT_SVC:-}" - ORD_NAME="${ORDER_SVC:-}" - [[ -z "$PROD_NAME" ]] && PROD_NAME=$(kubectl -n "$NS" get svc -o jsonpath='{range .items[*]}{.metadata.name}{"\n"}{end}' | grep -E '^product' | head -1 || true) - [[ -z "$ORD_NAME" ]] && ORD_NAME=$(kubectl -n "$NS" get svc -o jsonpath='{range .items[*]}{.metadata.name}{"\n"}{end}' | grep -E '^order' | head -1 || true) - echo "Detected: product=${PROD_NAME:-} order=${ORD_NAME:-}" + PROD_NAME=$(kubectl -n \"$NS\" get svc -o jsonpath='{range .items[*]}{.metadata.name}{"\n"}{end}' | grep -E '^product' | head -1 || true) + ORD_NAME=$(kubectl -n \"$NS\" get svc -o jsonpath='{range .items[*]}{.metadata.name}{"\n"}{end}' | grep -E '^order' | head -1 || true) + echo \"Detected: product=${PROD_NAME:-} order=${ORD_NAME:-}\" echo PRODUCT_SVC=$PROD_NAME >> $GITHUB_ENV echo ORDER_SVC=$ORD_NAME >> $GITHUB_ENV @@ -70,12 +65,12 @@ jobs: run: | set -e for i in {1..60}; do - PROD_IP=$(kubectl -n "$NS" get svc "$PRODUCT_SVC" -o jsonpath='{.status.loadBalancer.ingress[0].ip}' 2>/dev/null || true) - ORD_IP=$(kubectl -n "$NS" get svc "$ORDER_SVC" -o jsonpath='{.status.loadBalancer.ingress[0].ip}' 2>/dev/null || true) - echo "Attempt $i: product=${PROD_IP:-} order=${ORD_IP:-}" - if [[ -n "$PROD_IP" && -n "$ORD_IP" ]]; then - echo "PRODUCT_IP=$PROD_IP" >> $GITHUB_ENV - echo "ORDER_IP=$ORD_IP" >> $GITHUB_ENV + PROD_IP=$(kubectl -n \"$NS\" get svc \"$PRODUCT_SVC\" -o jsonpath='{.status.loadBalancer.ingress[0].ip}' 2>/dev/null || true) + ORD_IP=$(kubectl -n \"$NS\" get svc \"$ORDER_SVC\" -o jsonpath='{.status.loadBalancer.ingress[0].ip}' 2>/dev/null || true) + echo \"Attempt $i: product=${PROD_IP:-} order=${ORD_IP:-}\" + if [[ -n \"$PROD_IP\" && -n \"$ORD_IP\" ]]; then + echo \"PRODUCT_IP=$PROD_IP\" >> $GITHUB_ENV + echo \"ORDER_IP=$ORD_IP\" >> $GITHUB_ENV exit 0 fi sleep 5 @@ -83,12 +78,16 @@ jobs: echo 'Timed out waiting for external IPs'; exit 1 - id: out_prod_ip - run: echo "external_ip=${{ env.PRODUCT_IP }}" >> $GITHUB_OUTPUT + run: echo \"external_ip=${{ env.PRODUCT_IP }}\" >> $GITHUB_OUTPUT - id: out_order_ip - run: echo "external_ip=${{ env.ORDER_IP }}" >> $GITHUB_OUTPUT + run: echo \"external_ip=${{ env.ORDER_IP }}\" >> $GITHUB_OUTPUT - name: Azure Logout if: always() run: az logout '@ | Set-Content -Encoding UTF8 .github/workflows/backend-cd.yml" + +git add .github\workflows\backend-cd.yml +git commit -m "cd: remove environment gate; tolerate attach-acr; auto-detect svc names; wait for IPs" +git push From 45aa535c753e1a4738083b13bcc16a7b035a9f03 Mon Sep 17 00:00:00 2001 From: chaitanyakotagiri27 Date: Wed, 17 Sep 2025 18:55:02 +1000 Subject: [PATCH 20/33] cd: auto-detect service names + tolerant ACR attach --- .github/workflows/backend-cd.yml | 55 +++++++++++++++----------------- 1 file changed, 26 insertions(+), 29 deletions(-) diff --git a/.github/workflows/backend-cd.yml b/.github/workflows/backend-cd.yml index ed574d4f..9a160a82 100644 --- a/.github/workflows/backend-cd.yml +++ b/.github/workflows/backend-cd.yml @@ -1,5 +1,4 @@ -powershell -NoP -C "@' -name: CD — Deploy Backend Services to AKS +name: CD - Deploy Backend Services to AKS on: workflow_dispatch: {} @@ -13,6 +12,7 @@ env: jobs: deploy_backend: runs-on: ubuntu-latest + environment: Production outputs: PRODUCT_API_IP: ${{ steps.out_prod_ip.outputs.external_ip }} @@ -27,67 +27,64 @@ jobs: creds: ${{ secrets.AZURE_CREDENTIALS }} - name: Get AKS credentials - run: az aks get-credentials --resource-group \"$RG\" --name \"$AKS\" --overwrite-existing + run: az aks get-credentials --resource-group "$RG" --name "$AKS" --overwrite-existing - name: Ensure namespace exists - run: kubectl get ns \"$NS\" || kubectl create ns \"$NS\" + run: kubectl get ns "$NS" || kubectl create ns "$NS" + # You might not be Owner; allow failure and continue. - name: Attach ACR (idempotent; ignore if no rights) continue-on-error: true - run: az aks update --name \"$AKS\" --resource-group \"$RG\" --attach-acr \"$ACR_NAME\" + run: az aks update --name "$AKS" --resource-group "$RG" --attach-acr "$ACR_NAME" - name: Apply infra (ConfigMaps, Secrets, DBs) working-directory: k8s run: | - kubectl -n \"$NS\" apply -f configmaps.yaml - kubectl -n \"$NS\" apply -f secrets.yaml - kubectl -n \"$NS\" apply -f product-db.yaml - kubectl -n \"$NS\" apply -f order-db.yaml + kubectl -n "$NS" apply -f configmaps.yaml + kubectl -n "$NS" apply -f secrets.yaml + kubectl -n "$NS" apply -f product-db.yaml + kubectl -n "$NS" apply -f order-db.yaml - name: Deploy product & order services working-directory: k8s run: | - kubectl -n \"$NS\" apply -f product-service.yaml - kubectl -n \"$NS\" apply -f order-service.yaml + kubectl -n "$NS" apply -f product-service.yaml + kubectl -n "$NS" apply -f order-service.yaml + kubectl -n "$NS" get svc -o wide - name: Detect service names (product/order) shell: bash run: | set -e - PROD_NAME=$(kubectl -n \"$NS\" get svc -o jsonpath='{range .items[*]}{.metadata.name}{"\n"}{end}' | grep -E '^product' | head -1 || true) - ORD_NAME=$(kubectl -n \"$NS\" get svc -o jsonpath='{range .items[*]}{.metadata.name}{"\n"}{end}' | grep -E '^order' | head -1 || true) - echo \"Detected: product=${PROD_NAME:-} order=${ORD_NAME:-}\" + PROD_NAME=$(kubectl -n "$NS" get svc -o jsonpath='{range .items[*]}{.metadata.name}{"\n"}{end}' | grep -E '^product' | head -1 || true) + ORD_NAME=$(kubectl -n "$NS" get svc -o jsonpath='{range .items[*]}{.metadata.name}{"\n"}{end}' | grep -E '^order' | head -1 || true) + echo "Detected: product=${PROD_NAME:-} order=${ORD_NAME:-}" echo PRODUCT_SVC=$PROD_NAME >> $GITHUB_ENV echo ORDER_SVC=$ORD_NAME >> $GITHUB_ENV - - name: Wait for LoadBalancer IPs (≤5 min) + - name: Wait for LoadBalancer IPs (<=5 min) shell: bash run: | set -e for i in {1..60}; do - PROD_IP=$(kubectl -n \"$NS\" get svc \"$PRODUCT_SVC\" -o jsonpath='{.status.loadBalancer.ingress[0].ip}' 2>/dev/null || true) - ORD_IP=$(kubectl -n \"$NS\" get svc \"$ORDER_SVC\" -o jsonpath='{.status.loadBalancer.ingress[0].ip}' 2>/dev/null || true) - echo \"Attempt $i: product=${PROD_IP:-} order=${ORD_IP:-}\" - if [[ -n \"$PROD_IP\" && -n \"$ORD_IP\" ]]; then - echo \"PRODUCT_IP=$PROD_IP\" >> $GITHUB_ENV - echo \"ORDER_IP=$ORD_IP\" >> $GITHUB_ENV + PROD_IP=$(kubectl -n "$NS" get svc "$PRODUCT_SVC" -o jsonpath='{.status.loadBalancer.ingress[0].ip}' 2>/dev/null || true) + ORD_IP=$(kubectl -n "$NS" get svc "$ORDER_SVC" -o jsonpath='{.status.loadBalancer.ingress[0].ip}' 2>/dev/null || true) + echo "Attempt $i: product=${PROD_IP:-} order=${ORD_IP:-}" + if [[ -n "$PROD_IP" && -n "$ORD_IP" ]]; then + echo "PRODUCT_IP=$PROD_IP" >> $GITHUB_ENV + echo "ORDER_IP=$ORD_IP" >> $GITHUB_ENV exit 0 fi sleep 5 done - echo 'Timed out waiting for external IPs'; exit 1 + echo "Timed out waiting for external IPs"; exit 1 - id: out_prod_ip - run: echo \"external_ip=${{ env.PRODUCT_IP }}\" >> $GITHUB_OUTPUT + run: echo "external_ip=${{ env.PRODUCT_IP }}" >> $GITHUB_OUTPUT - id: out_order_ip - run: echo \"external_ip=${{ env.ORDER_IP }}\" >> $GITHUB_OUTPUT + run: echo "external_ip=${{ env.ORDER_IP }}" >> $GITHUB_OUTPUT - name: Azure Logout if: always() run: az logout -'@ | Set-Content -Encoding UTF8 .github/workflows/backend-cd.yml" - -git add .github\workflows\backend-cd.yml -git commit -m "cd: remove environment gate; tolerate attach-acr; auto-detect svc names; wait for IPs" -git push From 5e5bb6e808eb3816d4b27a9e6e765d8a4f854a01 Mon Sep 17 00:00:00 2001 From: chaitanyakotagiri27 Date: Wed, 17 Sep 2025 19:04:10 +1000 Subject: [PATCH 21/33] cd: robust ACR attach + svc detect + longer LB wait --- .github/workflows/backend-cd.yml | 40 +++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 14 deletions(-) diff --git a/.github/workflows/backend-cd.yml b/.github/workflows/backend-cd.yml index 9a160a82..75f59473 100644 --- a/.github/workflows/backend-cd.yml +++ b/.github/workflows/backend-cd.yml @@ -4,10 +4,10 @@ on: workflow_dispatch: {} env: - RG: ${{ vars.AKS_RESOURCE_GROUP }} - AKS: ${{ vars.AKS_CLUSTER_NAME }} - NS: ${{ vars.AKS_NAMESPACE }} - ACR_NAME: ${{ vars.ACR_NAME }} + RG: ${{ vars.AKS_RESOURCE_GROUP }} + AKS: ${{ vars.AKS_CLUSTER_NAME }} + NS: ${{ vars.AKS_NAMESPACE }} + ACR_NAME: ${{ vars.ACR_NAME }} jobs: deploy_backend: @@ -32,10 +32,17 @@ jobs: - name: Ensure namespace exists run: kubectl get ns "$NS" || kubectl create ns "$NS" - # You might not be Owner; allow failure and continue. + # This step NEVER fails the job; it logs and continues if you don't have Owner rights. - name: Attach ACR (idempotent; ignore if no rights) - continue-on-error: true - run: az aks update --name "$AKS" --resource-group "$RG" --attach-acr "$ACR_NAME" + shell: bash + run: | + set +e + az aks update --name "$AKS" --resource-group "$RG" --attach-acr "$ACR_NAME" + rc=$? + if [ $rc -ne 0 ]; then + echo "No Owner rights to attach ACR; skipping (nodes already have AcrPull)." + fi + exit 0 - name: Apply infra (ConfigMaps, Secrets, DBs) working-directory: k8s @@ -50,23 +57,28 @@ jobs: run: | kubectl -n "$NS" apply -f product-service.yaml kubectl -n "$NS" apply -f order-service.yaml + echo "--- Services after deploy ---" kubectl -n "$NS" get svc -o wide + # Auto-detect service names (falls back to product-service / order-service if needed) - name: Detect service names (product/order) + id: detect_svcs shell: bash run: | set -e PROD_NAME=$(kubectl -n "$NS" get svc -o jsonpath='{range .items[*]}{.metadata.name}{"\n"}{end}' | grep -E '^product' | head -1 || true) - ORD_NAME=$(kubectl -n "$NS" get svc -o jsonpath='{range .items[*]}{.metadata.name}{"\n"}{end}' | grep -E '^order' | head -1 || true) - echo "Detected: product=${PROD_NAME:-} order=${ORD_NAME:-}" - echo PRODUCT_SVC=$PROD_NAME >> $GITHUB_ENV - echo ORDER_SVC=$ORD_NAME >> $GITHUB_ENV - - - name: Wait for LoadBalancer IPs (<=5 min) + ORD_NAME=$(kubectl -n "$NS" get svc -o jsonpath='{range .items[*]}{.metadata.name}{"\n"}{end}' | grep -E '^order' | head -1 || true) + if [ -z "$PROD_NAME" ]; then PROD_NAME="product-service"; echo "Fallback PRODUCT_SVC=$PROD_NAME"; fi + if [ -z "$ORD_NAME" ]; then ORD_NAME="order-service"; echo "Fallback ORDER_SVC=$ORD_NAME"; fi + echo "Detected: product=${PROD_NAME} order=${ORD_NAME}" + echo "PRODUCT_SVC=$PROD_NAME" >> $GITHUB_ENV + echo "ORDER_SVC=$ORD_NAME" >> $GITHUB_ENV + + - name: Wait for LoadBalancer IPs (<=10 min) shell: bash run: | set -e - for i in {1..60}; do + for i in {1..120}; do PROD_IP=$(kubectl -n "$NS" get svc "$PRODUCT_SVC" -o jsonpath='{.status.loadBalancer.ingress[0].ip}' 2>/dev/null || true) ORD_IP=$(kubectl -n "$NS" get svc "$ORDER_SVC" -o jsonpath='{.status.loadBalancer.ingress[0].ip}' 2>/dev/null || true) echo "Attempt $i: product=${PROD_IP:-} order=${ORD_IP:-}" From d2a3fcf316973d18fef5d2a8af2288ce14472e73 Mon Sep 17 00:00:00 2001 From: chaitanyakotagiri27 Date: Wed, 17 Sep 2025 19:07:00 +1000 Subject: [PATCH 22/33] cd: force LoadBalancer type + longer wait + debug --- .github/workflows/backend-cd.yml | 40 +++++++++++++++++++++++--------- 1 file changed, 29 insertions(+), 11 deletions(-) diff --git a/.github/workflows/backend-cd.yml b/.github/workflows/backend-cd.yml index 75f59473..a7e040a4 100644 --- a/.github/workflows/backend-cd.yml +++ b/.github/workflows/backend-cd.yml @@ -32,16 +32,13 @@ jobs: - name: Ensure namespace exists run: kubectl get ns "$NS" || kubectl create ns "$NS" - # This step NEVER fails the job; it logs and continues if you don't have Owner rights. + # Never fail on ACR attach; skip if you don't have Owner. - name: Attach ACR (idempotent; ignore if no rights) shell: bash run: | set +e az aks update --name "$AKS" --resource-group "$RG" --attach-acr "$ACR_NAME" - rc=$? - if [ $rc -ne 0 ]; then - echo "No Owner rights to attach ACR; skipping (nodes already have AcrPull)." - fi + [ $? -ne 0 ] && echo "Skipping ACR attach (no Owner rights)" || true exit 0 - name: Apply infra (ConfigMaps, Secrets, DBs) @@ -57,10 +54,9 @@ jobs: run: | kubectl -n "$NS" apply -f product-service.yaml kubectl -n "$NS" apply -f order-service.yaml - echo "--- Services after deploy ---" + echo "--- services after apply ---" kubectl -n "$NS" get svc -o wide - # Auto-detect service names (falls back to product-service / order-service if needed) - name: Detect service names (product/order) id: detect_svcs shell: bash @@ -68,11 +64,27 @@ jobs: set -e PROD_NAME=$(kubectl -n "$NS" get svc -o jsonpath='{range .items[*]}{.metadata.name}{"\n"}{end}' | grep -E '^product' | head -1 || true) ORD_NAME=$(kubectl -n "$NS" get svc -o jsonpath='{range .items[*]}{.metadata.name}{"\n"}{end}' | grep -E '^order' | head -1 || true) - if [ -z "$PROD_NAME" ]; then PROD_NAME="product-service"; echo "Fallback PRODUCT_SVC=$PROD_NAME"; fi - if [ -z "$ORD_NAME" ]; then ORD_NAME="order-service"; echo "Fallback ORDER_SVC=$ORD_NAME"; fi - echo "Detected: product=${PROD_NAME} order=${ORD_NAME}" + [ -z "$PROD_NAME" ] && PROD_NAME="product-service" + [ -z "$ORD_NAME" ] && ORD_NAME="order-service" echo "PRODUCT_SVC=$PROD_NAME" >> $GITHUB_ENV echo "ORDER_SVC=$ORD_NAME" >> $GITHUB_ENV + echo "Detected PRODUCT_SVC=$PROD_NAME ORDER_SVC=$ORD_NAME" + + # 🔧 Force both services to LoadBalancer so they can get public IPs + - name: Ensure services are type LoadBalancer + shell: bash + run: | + for SVC in "$PRODUCT_SVC" "$ORDER_SVC"; do + TYPE=$(kubectl -n "$NS" get svc "$SVC" -o jsonpath='{.spec.type}' 2>/dev/null || echo "") + if [ "$TYPE" != "LoadBalancer" ]; then + echo "Patching $SVC to type LoadBalancer (was '$TYPE')" + kubectl -n "$NS" patch svc "$SVC" --type merge -p '{"spec":{"type":"LoadBalancer"}}' + else + echo "$SVC already LoadBalancer" + fi + done + echo "--- services after patch ---" + kubectl -n "$NS" get svc -o wide - name: Wait for LoadBalancer IPs (<=10 min) shell: bash @@ -89,7 +101,13 @@ jobs: fi sleep 5 done - echo "Timed out waiting for external IPs"; exit 1 + echo 'Timed out waiting for external IPs' + echo '--- describe services ---' + kubectl -n "$NS" describe svc "$PRODUCT_SVC" || true + kubectl -n "$NS" describe svc "$ORDER_SVC" || true + echo '--- recent events ---' + kubectl -n "$NS" get events --sort-by=.lastTimestamp | tail -n 100 || true + exit 1 - id: out_prod_ip run: echo "external_ip=${{ env.PRODUCT_IP }}" >> $GITHUB_OUTPUT From b6aefff00c22bf864648eb5feb3358d9bb181292 Mon Sep 17 00:00:00 2001 From: chaitanyakotagiri27 Date: Wed, 17 Sep 2025 20:03:29 +1000 Subject: [PATCH 23/33] fix(product svc): external port 80 (targetPort 8000) --- k8s/product-service.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/k8s/product-service.yaml b/k8s/product-service.yaml index f868a90e..3883810f 100644 --- a/k8s/product-service.yaml +++ b/k8s/product-service.yaml @@ -1,4 +1,4 @@ -# week08/k8s/product-service.yaml +# week08/k8s/product-service.yaml apiVersion: apps/v1 kind: Deployment From e2ea78c4e41ff523196c7db42defd9a0955fe511 Mon Sep 17 00:00:00 2001 From: chaitanyakotagiri27 Date: Wed, 17 Sep 2025 20:17:03 +1000 Subject: [PATCH 24/33] fix(product): correct ACR image and service port/name; order svc port name --- k8s/product-service.yaml | 101 +++++++++++++++++++-------------------- 1 file changed, 50 insertions(+), 51 deletions(-) diff --git a/k8s/product-service.yaml b/k8s/product-service.yaml index 3883810f..bdeac193 100644 --- a/k8s/product-service.yaml +++ b/k8s/product-service.yaml @@ -1,6 +1,4 @@ -# week08/k8s/product-service.yaml - -apiVersion: apps/v1 +apiVersion: apps/v1 kind: Deployment metadata: name: product-service-w08e1 @@ -17,50 +15,50 @@ spec: app: product-service spec: containers: - - name: product-service-container - image: sit722w08acr27234.azurecr.io/product_service:latest - imagePullPolicy: Always - ports: - - containerPort: 8000 - env: - # Database connection details - - name: POSTGRES_HOST - value: product-db-service-w08e1 - - name: POSTGRES_DB - valueFrom: - configMapKeyRef: - name: ecomm-config-w08e1 - key: PRODUCTS_DB_NAME - - name: POSTGRES_USER - valueFrom: - secretKeyRef: - name: ecomm-secrets-w08e1 # Secret name matches - key: POSTGRES_USER - - name: POSTGRES_PASSWORD - valueFrom: - secretKeyRef: - name: ecomm-secrets-w08e1 # Secret name matches - key: POSTGRES_PASSWORD - - name: AZURE_STORAGE_ACCOUNT_NAME - valueFrom: - secretKeyRef: - name: ecomm-secrets-w08e1 # Secret name matches - key: AZURE_STORAGE_ACCOUNT_NAME - - name: AZURE_STORAGE_ACCOUNT_KEY - valueFrom: - secretKeyRef: - name: ecomm-secrets-w08e1 # Secret name matches - key: AZURE_STORAGE_ACCOUNT_KEY - - name: AZURE_STORAGE_CONTAINER_NAME - valueFrom: - configMapKeyRef: - name: ecomm-config-w08e1 # ConfigMap name matches - key: AZURE_STORAGE_CONTAINER_NAME - - name: AZURE_SAS_TOKEN_EXPIRY_HOURS - valueFrom: - configMapKeyRef: - name: ecomm-config-w08e1 # ConfigMap name matches - key: AZURE_SAS_TOKEN_EXPIRY_HOURS + - name: product-service-container + image: sit722w08acr304694959.azurecr.io/product_service:latest + imagePullPolicy: Always + ports: + - containerPort: 8000 + env: + # Database connection details + - name: POSTGRES_HOST + value: product-db-service-w08e1 + - name: POSTGRES_DB + valueFrom: + configMapKeyRef: + name: ecomm-config-w08e1 + key: PRODUCTS_DB_NAME + - name: POSTGRES_USER + valueFrom: + secretKeyRef: + name: ecomm-secrets-w08e1 + key: POSTGRES_USER + - name: POSTGRES_PASSWORD + valueFrom: + secretKeyRef: + name: ecomm-secrets-w08e1 + key: POSTGRES_PASSWORD + - name: AZURE_STORAGE_ACCOUNT_NAME + valueFrom: + secretKeyRef: + name: ecomm-secrets-w08e1 + key: AZURE_STORAGE_ACCOUNT_NAME + - name: AZURE_STORAGE_ACCOUNT_KEY + valueFrom: + secretKeyRef: + name: ecomm-secrets-w08e1 + key: AZURE_STORAGE_ACCOUNT_KEY + - name: AZURE_STORAGE_CONTAINER_NAME + valueFrom: + configMapKeyRef: + name: ecomm-config-w08e1 + key: AZURE_STORAGE_CONTAINER_NAME + - name: AZURE_SAS_TOKEN_EXPIRY_HOURS + valueFrom: + configMapKeyRef: + name: ecomm-config-w08e1 + key: AZURE_SAS_TOKEN_EXPIRY_HOURS --- apiVersion: v1 kind: Service @@ -69,10 +67,11 @@ metadata: labels: app: product-service spec: + type: LoadBalancer selector: app: product-service ports: - - protocol: TCP - port: 8000 - targetPort: 8000 - type: LoadBalancer + - name: http + port: 80 # external LB port + targetPort: 8000 # container port in the pod + protocol: TCP From 33e4873f4bebee35f7844569fc5c46798d368968 Mon Sep 17 00:00:00 2001 From: chaitanyakotagiri27 Date: Wed, 17 Sep 2025 20:31:14 +1000 Subject: [PATCH 25/33] fix(product): use correct ACR and expose service on port 80 --- k8s/product-service.yaml | 96 ++++++++++++++++++++-------------------- 1 file changed, 48 insertions(+), 48 deletions(-) diff --git a/k8s/product-service.yaml b/k8s/product-service.yaml index bdeac193..bf6f756e 100644 --- a/k8s/product-service.yaml +++ b/k8s/product-service.yaml @@ -1,4 +1,5 @@ -apiVersion: apps/v1 +# k8s/product-service.yaml +apiVersion: apps/v1 kind: Deployment metadata: name: product-service-w08e1 @@ -15,50 +16,49 @@ spec: app: product-service spec: containers: - - name: product-service-container - image: sit722w08acr304694959.azurecr.io/product_service:latest - imagePullPolicy: Always - ports: - - containerPort: 8000 - env: - # Database connection details - - name: POSTGRES_HOST - value: product-db-service-w08e1 - - name: POSTGRES_DB - valueFrom: - configMapKeyRef: - name: ecomm-config-w08e1 - key: PRODUCTS_DB_NAME - - name: POSTGRES_USER - valueFrom: - secretKeyRef: - name: ecomm-secrets-w08e1 - key: POSTGRES_USER - - name: POSTGRES_PASSWORD - valueFrom: - secretKeyRef: - name: ecomm-secrets-w08e1 - key: POSTGRES_PASSWORD - - name: AZURE_STORAGE_ACCOUNT_NAME - valueFrom: - secretKeyRef: - name: ecomm-secrets-w08e1 - key: AZURE_STORAGE_ACCOUNT_NAME - - name: AZURE_STORAGE_ACCOUNT_KEY - valueFrom: - secretKeyRef: - name: ecomm-secrets-w08e1 - key: AZURE_STORAGE_ACCOUNT_KEY - - name: AZURE_STORAGE_CONTAINER_NAME - valueFrom: - configMapKeyRef: - name: ecomm-config-w08e1 - key: AZURE_STORAGE_CONTAINER_NAME - - name: AZURE_SAS_TOKEN_EXPIRY_HOURS - valueFrom: - configMapKeyRef: - name: ecomm-config-w08e1 - key: AZURE_SAS_TOKEN_EXPIRY_HOURS + - name: product-service-container + image: sit722w08acr304694959.azurecr.io/product_service:latest + imagePullPolicy: Always + ports: + - containerPort: 8000 + env: + - name: POSTGRES_HOST + value: product-db-service-w08e1 + - name: POSTGRES_DB + valueFrom: + configMapKeyRef: + name: ecomm-config-w08e1 + key: PRODUCTS_DB_NAME + - name: POSTGRES_USER + valueFrom: + secretKeyRef: + name: ecomm-secrets-w08e1 + key: POSTGRES_USER + - name: POSTGRES_PASSWORD + valueFrom: + secretKeyRef: + name: ecomm-secrets-w08e1 + key: POSTGRES_PASSWORD + - name: AZURE_STORAGE_ACCOUNT_NAME + valueFrom: + secretKeyRef: + name: ecomm-secrets-w08e1 + key: AZURE_STORAGE_ACCOUNT_NAME + - name: AZURE_STORAGE_ACCOUNT_KEY + valueFrom: + secretKeyRef: + name: ecomm-secrets-w08e1 + key: AZURE_STORAGE_ACCOUNT_KEY + - name: AZURE_STORAGE_CONTAINER_NAME + valueFrom: + configMapKeyRef: + name: ecomm-config-w08e1 + key: AZURE_STORAGE_CONTAINER_NAME + - name: AZURE_SAS_TOKEN_EXPIRY_HOURS + valueFrom: + configMapKeyRef: + name: ecomm-config-w08e1 + key: AZURE_SAS_TOKEN_EXPIRY_HOURS --- apiVersion: v1 kind: Service @@ -67,11 +67,11 @@ metadata: labels: app: product-service spec: - type: LoadBalancer selector: app: product-service ports: - name: http - port: 80 # external LB port - targetPort: 8000 # container port in the pod protocol: TCP + port: 80 # expose on 80 publicly + targetPort: 8000 # app listens on 8000 + type: LoadBalancer From 4cc925b13128e3f8b03337fd96097ebbf3f0d790 Mon Sep 17 00:00:00 2001 From: chaitanyakotagiri27 Date: Wed, 17 Sep 2025 21:01:34 +1000 Subject: [PATCH 26/33] config: PRODUCT_SERVICE_URL -> service DNS (port 80); keep ORDER on :8001 --- k8s/configmaps.yaml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/k8s/configmaps.yaml b/k8s/configmaps.yaml index 0df0ac6a..ab456484 100644 --- a/k8s/configmaps.yaml +++ b/k8s/configmaps.yaml @@ -1,5 +1,3 @@ -# week08/k8s/configmaps.yaml - apiVersion: v1 kind: ConfigMap metadata: @@ -8,8 +6,9 @@ data: # Database Names PRODUCTS_DB_NAME: products ORDERS_DB_NAME: orders + AZURE_STORAGE_CONTAINER_NAME: product-images AZURE_SAS_TOKEN_EXPIRY_HOURS: "24" - PRODUCT_SERVICE_URL: http://product-service-w08e1:8000 - ORDER_SERVICE_URL: http://order-service-w08e1:8001 + PRODUCT_SERVICE_URL: "http://product-service-w08e1" + ORDER_SERVICE_URL: "http://order-service-w08e1:8001" From a1b505aa8bad2ccdb455a426090a1ea03abb3fbe Mon Sep 17 00:00:00 2001 From: chaitanyakotagiri27 Date: Wed, 17 Sep 2025 22:28:52 +1000 Subject: [PATCH 27/33] frontend: point to AKS product/order services --- frontend/main.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/main.js b/frontend/main.js index 0acca093..a931e14d 100644 --- a/frontend/main.js +++ b/frontend/main.js @@ -4,8 +4,8 @@ document.addEventListener('DOMContentLoaded', () => { // API endpoints for the Product and Order services. // These ports (30000 for Product, 30001 for Order) are mapped // from the Docker containers to the host machine in docker-compose.yml for Example 2. - const PRODUCT_API_BASE_URL = 'http://4.237.230.232:8000'; - const ORDER_API_BASE_URL = 'http://104.209.84.9:8001'; + const PRODUCT_API_BASE_URL = 'http://20.227.92.200'; + const ORDER_API_BASE_URL = 'http://4.237.241.51:8001'; // Product Service is named 'product-service-w04e2' and exposes port 8000 internally. //const PRODUCT_API_BASE_URL = 'http://product-service-w04e2:8000'; From 496b411691e9e1737005bfc694b4e1f9a7186559 Mon Sep 17 00:00:00 2001 From: chaitanyakotagiri27 Date: Wed, 17 Sep 2025 22:40:53 +1000 Subject: [PATCH 28/33] fix(frontend): ACR image + LB service on port 80 --- k8s/frontend.yaml | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/k8s/frontend.yaml b/k8s/frontend.yaml index 0b52ab16..7e7164c1 100644 --- a/k8s/frontend.yaml +++ b/k8s/frontend.yaml @@ -1,9 +1,7 @@ -# week08/k8s/frontend.yaml - apiVersion: apps/v1 kind: Deployment metadata: - name: frontend + name: frontend-w08e1 labels: app: frontend spec: @@ -17,23 +15,23 @@ spec: app: frontend spec: containers: - - name: frontend-container - image: sit722w08acr27234.azurecr.io/frontend:latest - imagePullPolicy: Always - ports: - - containerPort: 80 + - name: frontend + image: sit722w08acr304694959.azurecr.io/frontend:latest + imagePullPolicy: Always + ports: + - containerPort: 80 --- apiVersion: v1 kind: Service metadata: - name: frontend-w08e1 # Service name matches + name: frontend-w08e1 labels: app: frontend spec: selector: app: frontend + type: LoadBalancer ports: - - protocol: TCP - port: 80 # The port the service listens on inside the cluster - targetPort: 80 # The port on the Pod (containerPort where Nginx runs) - type: LoadBalancer # Exposes the service on a port on each Node's IP + - name: http + port: 80 + targetPort: 80 From 35f4075162f36935fadd797de44b80e9f0a9360f Mon Sep 17 00:00:00 2001 From: chaitanyakotagiri27 Date: Wed, 17 Sep 2025 22:54:11 +1000 Subject: [PATCH 29/33] cd(frontend): update workflow + labels; deploy to week08 --- .github/workflows/frontend-cd.yml | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/.github/workflows/frontend-cd.yml b/.github/workflows/frontend-cd.yml index 0c45af88..43d8446d 100644 --- a/.github/workflows/frontend-cd.yml +++ b/.github/workflows/frontend-cd.yml @@ -11,10 +11,14 @@ on: description: "AKS resource group" required: true default: "sit722-w08-rg" + aks_namespace: + description: "Kubernetes namespace" + required: true + default: "week08" aks_acr_name: - description: "ACR registry NAME (no .azurecr.io)" + description: "ACR NAME (no .azurecr.io)" required: true - default: "sit722w08acr27234" + default: "sit722w08acr304694959" jobs: deploy_frontend: @@ -39,25 +43,38 @@ jobs: --name "${{ github.event.inputs.aks_cluster_name }}" \ --overwrite-existing - - name: Attach ACR (safe if already attached) + - name: Attach ACR (safe if already attached / no Owner) + shell: bash run: | + set +e az aks update \ --name "${{ github.event.inputs.aks_cluster_name }}" \ --resource-group "${{ github.event.inputs.aks_resource_group }}" \ --attach-acr "${{ github.event.inputs.aks_acr_name }}" + rc=$? + if [ $rc -ne 0 ]; then + echo "Skipping ACR attach (likely already attached or insufficient rights)." + fi + exit 0 - name: Apply frontend manifest working-directory: k8s run: | kubectl apply -f frontend.yaml - kubectl rollout status deploy/frontend -n default --timeout=180s || true + NS="${{ github.event.inputs.aks_namespace }}" + DEPLOY=$(kubectl -n "$NS" get deploy -l app=frontend -o jsonpath='{.items[0].metadata.name}') + echo "Detected deployment: $DEPLOY" + kubectl -n "$NS" rollout status "deploy/$DEPLOY" --timeout=180s || true - name: Wait for frontend external IP (≤5 min) shell: bash run: | set -e + NS="${{ github.event.inputs.aks_namespace }}" + SVC=$(kubectl -n "$NS" get svc -l app=frontend -o jsonpath='{.items[0].metadata.name}') + echo "Detected service: $SVC" for i in {1..60}; do - FE_IP=$(kubectl get svc frontend-w08e1 -o jsonpath='{.status.loadBalancer.ingress[0].ip}') + FE_IP=$(kubectl -n "$NS" get svc "$SVC" -o jsonpath='{.status.loadBalancer.ingress[0].ip}') echo "Attempt $i: frontend=$FE_IP" if [[ -n "$FE_IP" ]]; then echo "FRONTEND_IP=$FE_IP" >> $GITHUB_ENV From 4d8cf5d73d323f3fd09367ea35197d6de5b0a2dc Mon Sep 17 00:00:00 2001 From: chaitanyakotagiri27 Date: Wed, 17 Sep 2025 23:01:25 +1000 Subject: [PATCH 30/33] cd(frontend): target week08 namespace; direct name lookups; correct ACR default --- .github/workflows/frontend-cd.yml | 64 +++++++++++++++---------------- 1 file changed, 30 insertions(+), 34 deletions(-) diff --git a/.github/workflows/frontend-cd.yml b/.github/workflows/frontend-cd.yml index 43d8446d..660ee171 100644 --- a/.github/workflows/frontend-cd.yml +++ b/.github/workflows/frontend-cd.yml @@ -4,27 +4,34 @@ on: workflow_dispatch: inputs: aks_cluster_name: - description: "AKS cluster name" + description: AKS cluster name required: true - default: "sit722-w08-aks" + default: sit722-w08-aks aks_resource_group: - description: "AKS resource group" + description: AKS resource group required: true - default: "sit722-w08-rg" - aks_namespace: - description: "Kubernetes namespace" - required: true - default: "week08" + default: sit722-w08-rg aks_acr_name: - description: "ACR NAME (no .azurecr.io)" + description: ACR NAME (no .azurecr.io) + required: true + default: sit722w08acr304694959 # <-- use YOUR ACR + namespace: + description: K8s namespace + required: true + default: week08 + deploy_name: + description: Frontend Deployment name + required: true + default: frontend-w08e1 + service_name: + description: Frontend Service name required: true - default: "sit722w08acr304694959" + default: frontend-w08e1 jobs: deploy_frontend: runs-on: ubuntu-latest environment: Production - outputs: FRONTEND_IP: ${{ steps.out_fe_ip.outputs.external_ip }} @@ -43,50 +50,39 @@ jobs: --name "${{ github.event.inputs.aks_cluster_name }}" \ --overwrite-existing - - name: Attach ACR (safe if already attached / no Owner) - shell: bash + - name: Attach ACR (safe if already attached) run: | - set +e az aks update \ --name "${{ github.event.inputs.aks_cluster_name }}" \ --resource-group "${{ github.event.inputs.aks_resource_group }}" \ - --attach-acr "${{ github.event.inputs.aks_acr_name }}" - rc=$? - if [ $rc -ne 0 ]; then - echo "Skipping ACR attach (likely already attached or insufficient rights)." - fi - exit 0 + --attach-acr "${{ github.event.inputs.aks_acr_name }}" || true - name: Apply frontend manifest - working-directory: k8s run: | - kubectl apply -f frontend.yaml - NS="${{ github.event.inputs.aks_namespace }}" - DEPLOY=$(kubectl -n "$NS" get deploy -l app=frontend -o jsonpath='{.items[0].metadata.name}') - echo "Detected deployment: $DEPLOY" - kubectl -n "$NS" rollout status "deploy/$DEPLOY" --timeout=180s || true + kubectl -n "${{ github.event.inputs.namespace }}" apply -f k8s/frontend.yaml + kubectl -n "${{ github.event.inputs.namespace }}" rollout status \ + deploy/${{ github.event.inputs.deploy_name }} --timeout=180s || true - name: Wait for frontend external IP (≤5 min) + id: out_fe_ip shell: bash run: | set -e - NS="${{ github.event.inputs.aks_namespace }}" - SVC=$(kubectl -n "$NS" get svc -l app=frontend -o jsonpath='{.items[0].metadata.name}') - echo "Detected service: $SVC" for i in {1..60}; do - FE_IP=$(kubectl -n "$NS" get svc "$SVC" -o jsonpath='{.status.loadBalancer.ingress[0].ip}') + FE_IP=$(kubectl -n "${{ github.event.inputs.namespace }}" \ + get svc "${{ github.event.inputs.service_name }}" \ + -o jsonpath='{.status.loadBalancer.ingress[0].ip}') echo "Attempt $i: frontend=$FE_IP" if [[ -n "$FE_IP" ]]; then - echo "FRONTEND_IP=$FE_IP" >> $GITHUB_ENV + echo "external_ip=$FE_IP" >> "$GITHUB_OUTPUT" + echo "FRONTEND_IP=$FE_IP" >> "$GITHUB_ENV" exit 0 fi sleep 5 done echo "Timed out waiting for frontend external IP"; exit 1 - - id: out_fe_ip - run: echo "external_ip=${{ env.FRONTEND_IP }}" >> $GITHUB_OUTPUT - - name: Logout Azure if: always() run: az logout + From 9c48c893366408d60ebdc647c4303a0202f9b3c9 Mon Sep 17 00:00:00 2001 From: chaitanyakotagiri27 Date: Wed, 17 Sep 2025 23:55:57 +1000 Subject: [PATCH 31/33] frontend: point to AKS Product 20.53.102.217 (80) and Order 20.53.103.38 (8001) --- frontend/main.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/frontend/main.js b/frontend/main.js index a931e14d..c0376daf 100644 --- a/frontend/main.js +++ b/frontend/main.js @@ -1,16 +1,16 @@ -// week08/frontend/main.js +// week08/frontend/main.js document.addEventListener('DOMContentLoaded', () => { // API endpoints for the Product and Order services. // These ports (30000 for Product, 30001 for Order) are mapped // from the Docker containers to the host machine in docker-compose.yml for Example 2. - const PRODUCT_API_BASE_URL = 'http://20.227.92.200'; - const ORDER_API_BASE_URL = 'http://4.237.241.51:8001'; + const PRODUCT_API_BASE_URL = 'http://20.53.102.217'; + const ORDER_API_BASE_URL = 'http://20.53.103.38:8001'; // Product Service is named 'product-service-w04e2' and exposes port 8000 internally. - //const PRODUCT_API_BASE_URL = 'http://product-service-w04e2:8000'; + //const PRODUCT_API_BASE_URL = 'http://20.53.102.217'; // Order Service is named 'order-service-w04e2' and exposes port 8001 internally. - //const ORDER_API_BASE_URL = 'http://order-service-w04e2:8001'; + //const ORDER_API_BASE_URL = 'http://20.53.103.38:8001'; // DOM Elements const messageBox = document.getElementById('message-box'); @@ -426,3 +426,4 @@ document.addEventListener('DOMContentLoaded', () => { fetchProducts(); fetchOrders(); }); + From caaa3c435744368199b850deaa28d3ec09922a5d Mon Sep 17 00:00:00 2001 From: chaitanyakotagiri27 Date: Thu, 18 Sep 2025 00:02:37 +1000 Subject: [PATCH 32/33] frontend: Order on port 80 (no :8001) --- frontend/main.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/frontend/main.js b/frontend/main.js index c0376daf..7cf02fb2 100644 --- a/frontend/main.js +++ b/frontend/main.js @@ -5,12 +5,12 @@ document.addEventListener('DOMContentLoaded', () => { // These ports (30000 for Product, 30001 for Order) are mapped // from the Docker containers to the host machine in docker-compose.yml for Example 2. const PRODUCT_API_BASE_URL = 'http://20.53.102.217'; - const ORDER_API_BASE_URL = 'http://20.53.103.38:8001'; + const ORDER_API_BASE_URL = 'http://20.53.103.38'; // Product Service is named 'product-service-w04e2' and exposes port 8000 internally. //const PRODUCT_API_BASE_URL = 'http://20.53.102.217'; // Order Service is named 'order-service-w04e2' and exposes port 8001 internally. - //const ORDER_API_BASE_URL = 'http://20.53.103.38:8001'; + //const ORDER_API_BASE_URL = 'http://20.53.103.38'; // DOM Elements const messageBox = document.getElementById('message-box'); @@ -427,3 +427,4 @@ document.addEventListener('DOMContentLoaded', () => { fetchOrders(); }); + From 0802b5cad9399a7a2da2f41f15465c509f8f5ddd Mon Sep 17 00:00:00 2001 From: chaitanyakotagiri27 Date: Thu, 18 Sep 2025 00:23:48 +1000 Subject: [PATCH 33/33] frontend: point to AKS product (80) and order (8001) --- frontend/main.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/main.js b/frontend/main.js index 7cf02fb2..ca1f45f5 100644 --- a/frontend/main.js +++ b/frontend/main.js @@ -5,12 +5,12 @@ document.addEventListener('DOMContentLoaded', () => { // These ports (30000 for Product, 30001 for Order) are mapped // from the Docker containers to the host machine in docker-compose.yml for Example 2. const PRODUCT_API_BASE_URL = 'http://20.53.102.217'; - const ORDER_API_BASE_URL = 'http://20.53.103.38'; + const ORDER_API_BASE_URL = 'http://20.53.103.38:8001'; // Product Service is named 'product-service-w04e2' and exposes port 8000 internally. //const PRODUCT_API_BASE_URL = 'http://20.53.102.217'; // Order Service is named 'order-service-w04e2' and exposes port 8001 internally. - //const ORDER_API_BASE_URL = 'http://20.53.103.38'; + //const ORDER_API_BASE_URL = 'http://20.53.103.38:8001'; // DOM Elements const messageBox = document.getElementById('message-box');