Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 36 additions & 12 deletions .github/workflows/backend-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ on:
aks_cluster_name:
description: 'Name of the AKS Cluster to deploy to'
required: true
default: '<aks_cluster_name>'
default: 'sit722-aks'
aks_resource_group:
description: 'Resource Group of the AKS Cluster'
required: true
default: '<resource_group_name>'
default: 'SIT722-RG'
aks_acr_name:
description: 'Name of ACR'
description: 'Azure Container Registry name (not FQDN)'
required: true
default: '<acr_name>'
default: '223313284acr'

jobs:
deploy_backend:
Expand All @@ -30,18 +30,36 @@ 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

- name: Set Kubernetes context (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

- name: Setup kubectl
uses: azure/setup-kubectl@v4

- name: Ensure namespace exists
run: |
kubectl create namespace sit722 --dry-run=client -o yaml | kubectl apply -f -

- name: Attach ACR
- name: Create/refresh imagePullSecret (acr-auth)
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 }}
kubectl delete secret acr-auth -n sit722 --ignore-not-found
kubectl create secret docker-registry acr-auth \
--namespace sit722 \
--docker-server=${{ secrets.AZURE_CONTAINER_REGISTRY }} \
--docker-username=${{ secrets.AZURE_CONTAINER_REGISTRY_NAME }} \
--docker-password='${{ secrets.ACR_PASSWORD }}' \
--docker-email="devnull@example.local"
kubectl get secret acr-auth -n sit722

# - name: Attach ACR
# 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: Deploy Backend Infrastructure (Namespace, ConfigMaps, Secrets, Databases)
run: |
Expand All @@ -59,16 +77,19 @@ jobs:
kubectl apply -f product-service.yaml
kubectl apply -f order-service.yaml

- name: Wait for Backend LoadBalancer IPs
- name: Wait for Backend LoadBalancer IPs
run: |
echo "Sanity check: services across namespaces"
kubectl get svc -A

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}')
PRODUCT_IP=$(kubectl get service product-service-w08e1 -n sit722 -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
ORDER_IP=$(kubectl get service order-service-w08e1 -n sit722 -o jsonpath='{.status.loadBalancer.ingress[0].ip}')

if [[ -n "$PRODUCT_IP" && -n "$ORDER_IP" ]]; then
echo "All backend LoadBalancer IPs assigned!"
Expand All @@ -80,10 +101,13 @@ jobs:
done

if [[ -z "$PRODUCT_IP" || -z "$ORDER_IP" ]]; then
echo "DEBUG: describe services in sit722"
kubectl describe svc product-service-w08e1 -n sit722 || true
kubectl describe svc order-service-w08e1 -n sit722 || true
echo "Error: One or more LoadBalancer IPs not assigned after timeout."
exit 1 # Fail the job if IPs are not obtained
exit 1
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
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/frontend-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@ on:
product_api_ip:
description: 'External IP of Product Service'
required: true
default: 'http://<ip_address>:8000'
default: 'http://172.188.196.47:8000'
order_api_ip:
description: 'External IP of Order Service (e.g., http://Y.Y.Y.Y:8001)'
required: true
default: 'http://<ip_address>:8001'
default: 'http://4.144.233.236:8001'
aks_cluster_name:
description: 'Name of the AKS Cluster to deploy to'
description: 'AKS cluster name'
required: true
default: '<aks_name>'
default: 'sit722-aks'
aks_resource_group:
description: 'Resource Group of the AKS Cluster'
description: 'AKS resource group'
required: true
default: '<<resource_group_name>'
default: 'SIT722-RG'

workflow_call:
inputs:
Expand Down
Binary file modified .gitignore
Binary file not shown.
5 changes: 3 additions & 2 deletions frontend/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ 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://172.188.196.47:8000';
const ORDER_API_BASE_URL = 'http://4.144.233.236:8001';


// Product Service is named 'product-service-w04e2' and exposes port 8000 internally.
//const PRODUCT_API_BASE_URL = 'http://product-service-w04e2:8000';
Expand Down
2 changes: 1 addition & 1 deletion k8s/frontend.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ spec:
spec:
containers:
- name: frontend-container
image: durgeshsamariya.azurecr.io/frontend:latest
image: 223313284acr.azurecr.io/frontend:latest
imagePullPolicy: Always
ports:
- containerPort: 80
Expand Down
4 changes: 3 additions & 1 deletion k8s/order-service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@ spec:
labels:
app: order-service
spec:
imagePullSecrets:
- name: acr-auth
containers:
- name: order-service-container
image: durgeshsamariya.azurecr.io/order_service:latest
image: 223313284acr.azurecr.io/order_service:latest
imagePullPolicy: Always
ports:
- containerPort: 8000
Expand Down
4 changes: 3 additions & 1 deletion k8s/product-service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@ spec:
labels:
app: product-service
spec:
imagePullSecrets:
- name: acr-auth
containers:
- name: product-service-container
image: durgeshsamariya.azurecr.io/product_service:latest
image: 223313284acr.azurecr.io/product_service:latest
imagePullPolicy: Always
ports:
- containerPort: 8000
Expand Down