Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
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
122 changes: 61 additions & 61 deletions .github/workflows/azuresetup.yml
Original file line number Diff line number Diff line change
@@ -1,61 +1,61 @@
name: Azure Infrastructure Setup

on:
push:
branches:
- master

permissions:
id-token: write
contents: read

env:
TF_VAR_azure_region: 'australiaeast'
TF_VAR_resource_group_name: 'microservices-demo-rg'
TF_VAR_acr_name: 'shaheergooglepracticeregistry'

jobs:
setup_infrastructure:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Install Azure CLI
run: |
curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash

- name: Azure login
uses: azure/login@v1.4.7
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}

- name: Install Terraform
run: |
sudo apt-get update && sudo apt-get install -y gnupg software-properties-common
curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo apt-key add -
sudo apt-add-repository "deb https://apt.releases.hashicorp.com $(lsb_release -cs) main"
sudo apt-get update && sudo apt-get install terraform

- name: Check if Terraform directory exists
run: |
if [ ! -d "deployment/terraform/aks" ]; then
echo "Directory deployment/terraform/aks does not exist."
exit 1
fi

- name: Initialize Terraform
run: |
cd deployment/terraform/aks
terraform init

- name: Import Existing Resource Group
run: |
terraform import azurerm_resource_group.rg /subscriptions/${{ secrets.AZURE_SUBSCRIPTION_ID }}/resourceGroups/microservices-demo-rg || true
working-directory: deployment/terraform/aks

- name: Apply Terraform Configuration
run: |
cd deployment/terraform/aks
terraform apply -auto-approve
# name: Azure Infrastructure Setup

# on:
# push:
# branches:
# - dev

# permissions:
# id-token: write
# contents: read

# env:
# TF_VAR_azure_region: 'australiaeast'
# TF_VAR_resource_group_name: 'microservices-demo-rg'
# TF_VAR_acr_name: 'shaheergooglepracticeregistry'

# jobs:
# setup_infrastructure:
# runs-on: ubuntu-latest

# steps:
# - name: Checkout code
# uses: actions/checkout@v3

# - name: Install Azure CLI
# run: |
# curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash

# - name: Azure login
# uses: azure/login@v1.4.7
# with:
# creds: ${{ secrets.AZURE_CREDENTIALS }}

# - name: Install Terraform
# run: |
# sudo apt-get update && sudo apt-get install -y gnupg software-properties-common
# curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo apt-key add -
# sudo apt-add-repository "deb https://apt.releases.hashicorp.com $(lsb_release -cs) main"
# sudo apt-get update && sudo apt-get install terraform

# - name: Check if Terraform directory exists
# run: |
# if [ ! -d "deployment/terraform/aks" ]; then
# echo "Directory deployment/terraform/aks does not exist."
# exit 1
# fi

# - name: Initialize Terraform
# run: |
# cd deployment/terraform/aks
# terraform init

# - name: Import Existing Resource Group
# run: |
# terraform import azurerm_resource_group.rg /subscriptions/${{ secrets.AZURE_SUBSCRIPTION_ID }}/resourceGroups/microservices-demo-rg || true
# working-directory: deployment/terraform/aks

# - name: Apply Terraform Configuration
# run: |
# cd deployment/terraform/aks
# terraform apply -auto-approve
115 changes: 115 additions & 0 deletions .github/workflows/build_push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
name: Pull Docker Images from DockerHub and Deploy to AKS

on:
push:
branches:
- dev

permissions:
id-token: write
contents: read

env:
DOCKERHUB_USERNAME: shaheer4636
AZURE_REGION: 'australiaeast'
RESOURCE_GROUP: 'microservices-demo-rg'
AKS_CLUSTER_NAME: 'microservices-demo-aks'
ACR_NAME: 'shaheergooglepracticeregistry'
IMAGE_TAG: latest

jobs:
pull_and_deploy:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Login to DockerHub
run: |
echo "${{ secrets.DOCKERHUB_PASSWORD }}" | docker login --username ${{ env.DOCKERHUB_USERNAME }} --password-stdin

- name: Login to Azure
uses: azure/login@v1.4.7
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}

- name: Login to ACR
run: |
az acr login --name ${{ env.ACR_NAME }}

- name: Set up AKS Credentials
run: |
az aks get-credentials --resource-group ${{ env.RESOURCE_GROUP }} --name ${{ env.AKS_CLUSTER_NAME }}

# - name: Pull and Push adservice image
# run: |
# docker pull ${{ env.DOCKERHUB_USERNAME }}/adservice:${{ env.IMAGE_TAG }}
# docker tag ${{ env.DOCKERHUB_USERNAME }}/adservice:${{ env.IMAGE_TAG }} ${{ env.ACR_NAME }}.azurecr.io/adservice:${{ env.IMAGE_TAG }}
# docker push ${{ env.ACR_NAME }}.azurecr.io/adservice:${{ env.IMAGE_TAG }}

- name: Pull and Push checkout image
run: |
docker pull ${{ env.DOCKERHUB_USERNAME }}/checkoutservice:${{ env.IMAGE_TAG }}
docker tag ${{ env.DOCKERHUB_USERNAME }}/checkoutservice:${{ env.IMAGE_TAG }} ${{ env.ACR_NAME }}.azurecr.io/checkoutservice:${{ env.IMAGE_TAG }}
docker push ${{ env.ACR_NAME }}.azurecr.io/checkoutservice:${{ env.IMAGE_TAG }}

# - name: Pull and Push cartservice image
# run: |
# docker pull ${{ env.DOCKERHUB_USERNAME }}/cartservice:${{ env.IMAGE_TAG }}
# docker tag ${{ env.DOCKERHUB_USERNAME }}/cartservice:${{ env.IMAGE_TAG }} ${{ env.ACR_NAME }}.azurecr.io/cartservice:${{ env.IMAGE_TAG }}
# docker push ${{ env.ACR_NAME }}.azurecr.io/cartservice:${{ env.IMAGE_TAG }}

# - name: Pull and Push currencyservice image
# run: |
# docker pull ${{ env.DOCKERHUB_USERNAME }}/currencyservice:${{ env.IMAGE_TAG }}
# docker tag ${{ env.DOCKERHUB_USERNAME }}/currencyservice:${{ env.IMAGE_TAG }} ${{ env.ACR_NAME }}.azurecr.io/currencyservice:${{ env.IMAGE_TAG }}
# docker push ${{ env.ACR_NAME }}.azurecr.io/currencyservice:${{ env.IMAGE_TAG }}

# - name: Pull and Push emailservice image
# run: |
# docker pull ${{ env.DOCKERHUB_USERNAME }}/emailservice:${{ env.IMAGE_TAG }}
# docker tag ${{ env.DOCKERHUB_USERNAME }}/emailservice:${{ env.IMAGE_TAG }} ${{ env.ACR_NAME }}.azurecr.io/emailservice:${{ env.IMAGE_TAG }}
# docker push ${{ env.ACR_NAME }}.azurecr.io/emailservice:${{ env.IMAGE_TAG }}

# - name: Pull and Push frontend image
# run: |
# docker pull ${{ env.DOCKERHUB_USERNAME }}/frontend:${{ env.IMAGE_TAG }}
# docker tag ${{ env.DOCKERHUB_USERNAME }}/frontend:${{ env.IMAGE_TAG }} ${{ env.ACR_NAME }}.azurecr.io/frontend:${{ env.IMAGE_TAG }}
# docker push ${{ env.ACR_NAME }}.azurecr.io/frontend:${{ env.IMAGE_TAG }}

# - name: Pull and Push loadgenerator image
# run: |
# docker pull ${{ env.DOCKERHUB_USERNAME }}/loadgenerator:${{ env.IMAGE_TAG }}
# docker tag ${{ env.DOCKERHUB_USERNAME }}/loadgenerator:${{ env.IMAGE_TAG }} ${{ env.ACR_NAME }}.azurecr.io/loadgenerator:${{ env.IMAGE_TAG }}
# docker push ${{ env.ACR_NAME }}.azurecr.io/loadgenerator:${{ env.IMAGE_TAG }}

# - name: Pull and Push paymentservice image
# run: |
# docker pull ${{ env.DOCKERHUB_USERNAME }}/paymentservice:${{ env.IMAGE_TAG }}
# docker tag ${{ env.DOCKERHUB_USERNAME }}/paymentservice:${{ env.IMAGE_TAG }} ${{ env.ACR_NAME }}.azurecr.io/paymentservice:${{ env.IMAGE_TAG }}
# docker push ${{ env.ACR_NAME }}.azurecr.io/paymentservice:${{ env.IMAGE_TAG }}

# - name: Pull and Push productcatalogservice image
# run: |
# docker pull ${{ env.DOCKERHUB_USERNAME }}/productcatalog:${{ env.IMAGE_TAG }}
# docker tag ${{ env.DOCKERHUB_USERNAME }}/productcatalog:${{ env.IMAGE_TAG }} ${{ env.ACR_NAME }}.azurecr.io/productcatalogservice:${{ env.IMAGE_TAG }}
# docker push ${{ env.ACR_NAME }}.azurecr.io/productcatalogservice:${{ env.IMAGE_TAG }}

# - name: Pull and Push recommendationservice image
# run: |
# docker pull ${{ env.DOCKERHUB_USERNAME }}/recommendationservice:${{ env.IMAGE_TAG }}
# docker tag ${{ env.DOCKERHUB_USERNAME }}/recommendationservice:${{ env.IMAGE_TAG }} ${{ env.ACR_NAME }}.azurecr.io/recommendationservice:${{ env.IMAGE_TAG }}
# docker push ${{ env.ACR_NAME }}.azurecr.io/recommendationservice:${{ env.IMAGE_TAG }}

# - name: Pull and Push shippingservice image
# run: |
# docker pull ${{ env.DOCKERHUB_USERNAME }}/shippingservice:${{ env.IMAGE_TAG }}
# docker tag ${{ env.DOCKERHUB_USERNAME }}/shippingservice:${{ env.IMAGE_TAG }} ${{ env.ACR_NAME }}.azurecr.io/shippingservice:${{ env.IMAGE_TAG }}
# docker push ${{ env.ACR_NAME }}.azurecr.io/shippingservice:${{ env.IMAGE_TAG }}

# - name: Pull and Push shoppingassistants image
# run: |
# docker pull ${{ env.DOCKERHUB_USERNAME }}/shoppingassistants:${{ env.IMAGE_TAG }}
# docker tag ${{ env.DOCKERHUB_USERNAME }}/shoppingassistants:${{ env.IMAGE_TAG }} ${{ env.ACR_NAME }}.azurecr.io/shoppingassistants:${{ env.IMAGE_TAG }}
# docker push ${{ env.ACR_NAME }}.azurecr.io/shoppingassistants:${{ env.IMAGE_TAG }}
38 changes: 38 additions & 0 deletions .github/workflows/deployments_to_aks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Deploy to AKS on Push to Dev

on:
push:
branches:
- dev # Triggers on push to 'dev' branch

jobs:
deploy:
runs-on: ubuntu-latest

steps:
- name: Log in to Azure
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }} # Use your Azure service principal secret

- name: Set up AKS context
uses: azure/aks-set-context@v2
with:
resource-group: 'microservices-demo-rg' # Replace with your resource group name
cluster-name: 'microservices-demo-aks' # Replace with your AKS cluster name

- name: Apply Kubernetes Manifests
run: |
# Apply all manifest files directly from the URLs
kubectl apply -f https://raw.githubusercontent.com/Shaheer4636/google-microservices-poc/dev/microservices-demo-main/kubernetes-manifests/adservice.yaml
kubectl apply -f https://raw.githubusercontent.com/Shaheer4636/google-microservices-poc/dev/microservices-demo-main/kubernetes-manifests/cartservice.yaml
kubectl apply -f https://raw.githubusercontent.com/Shaheer4636/google-microservices-poc/dev/microservices-demo-main/kubernetes-manifests/checkoutservice.yaml
kubectl apply -f https://raw.githubusercontent.com/Shaheer4636/google-microservices-poc/dev/microservices-demo-main/kubernetes-manifests/currencyservice.yaml
kubectl apply -f https://raw.githubusercontent.com/Shaheer4636/google-microservices-poc/dev/microservices-demo-main/kubernetes-manifests/emailservice.yaml
kubectl apply -f https://raw.githubusercontent.com/Shaheer4636/google-microservices-poc/dev/microservices-demo-main/kubernetes-manifests/frontend.yaml
kubectl apply -f https://raw.githubusercontent.com/Shaheer4636/google-microservices-poc/dev/microservices-demo-main/kubernetes-manifests/kustomization.yaml
kubectl apply -f https://raw.githubusercontent.com/Shaheer4636/google-microservices-poc/dev/microservices-demo-main/kubernetes-manifests/loadgenerator.yaml
kubectl apply -f https://raw.githubusercontent.com/Shaheer4636/google-microservices-poc/dev/microservices-demo-main/kubernetes-manifests/paymentservice.yaml
kubectl apply -f https://raw.githubusercontent.com/Shaheer4636/google-microservices-poc/dev/microservices-demo-main/kubernetes-manifests/productcatalogservice.yaml
kubectl apply -f https://raw.githubusercontent.com/Shaheer4636/google-microservices-poc/dev/microservices-demo-main/kubernetes-manifests/recommendationservice.yaml
kubectl apply -f https://raw.githubusercontent.com/Shaheer4636/google-microservices-poc/dev/microservices-demo-main/kubernetes-manifests/shippingservice.yaml
6 changes: 3 additions & 3 deletions microservices-demo-main/kubernetes-manifests/adservice.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,16 @@ spec:
- ALL
privileged: false
readOnlyRootFilesystem: true
image: adservice
image: shaheergooglepracticeregistry.azurecr.io/adservice:latest
ports:
- containerPort: 9555
env:
- name: PORT
value: "9555"
resources:
requests:
cpu: 200m
memory: 180Mi
cpu: 100m
memory: 100Mi
limits:
cpu: 300m
memory: 300Mi
Expand Down
6 changes: 3 additions & 3 deletions microservices-demo-main/kubernetes-manifests/cartservice.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,16 @@ spec:
- ALL
privileged: false
readOnlyRootFilesystem: true
image: cartservice
image: shaheergooglepracticeregistry.azurecr.io/cartservice:latest
ports:
- containerPort: 7070
env:
- name: REDIS_ADDR
value: "redis-cart:6379"
resources:
requests:
cpu: 200m
memory: 64Mi
cpu: 100m
memory: 100Mi
limits:
cpu: 300m
memory: 128Mi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ spec:
- ALL
privileged: false
readOnlyRootFilesystem: true
image: checkoutservice
image: shaheergooglepracticeregistry.azurecr.io/checkoutservice:latest
ports:
- containerPort: 5050
readinessProbe:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ spec:
- ALL
privileged: false
readOnlyRootFilesystem: true
image: currencyservice
image: shaheergooglepracticeregistry.azurecr.io/currencyservice:latest
ports:
- name: grpc
containerPort: 7000
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ spec:
- ALL
privileged: false
readOnlyRootFilesystem: true
image: emailservice
image: shaheergooglepracticeregistry.azurecr.io/emailservice:latest
ports:
- containerPort: 8080
env:
Expand Down
2 changes: 1 addition & 1 deletion microservices-demo-main/kubernetes-manifests/frontend.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ spec:
- ALL
privileged: false
readOnlyRootFilesystem: true
image: frontend
image: shaheergooglepracticeregistry.azurecr.io/frontend:latest
ports:
- containerPort: 8080
readinessProbe:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ spec:
cpu: 300m
memory: 256Mi
limits:
cpu: 500m
memory: 512Mi
cpu: 200m
memory: 200Mi
---
apiVersion: v1
kind: ServiceAccount
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ spec:
- ALL
privileged: false
readOnlyRootFilesystem: true
image: paymentservice
image: shaheergooglepracticeregistry.azurecr.io/paymentservice:latest
ports:
- containerPort: 50051
env:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ spec:
- ALL
privileged: false
readOnlyRootFilesystem: true
image: productcatalogservice
image: shaheergooglepracticeregistry.azurecr.io/productcatalogservice:latest
ports:
- containerPort: 3550
env:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ spec:
- ALL
privileged: false
readOnlyRootFilesystem: true
image: recommendationservice
image: shaheergooglepracticeregistry.azurecr.io/recommendationservice:latest
ports:
- containerPort: 8080
readinessProbe:
Expand Down
Loading