-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
311a7a0
commit b682b3d
Showing
20 changed files
with
356 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
name: car-demo-common-service | ||
|
||
on: | ||
push: | ||
branches: [ feature/azure-deployment ] | ||
env: | ||
# add env variables | ||
|
||
jobs: | ||
setup-build-publish-deploy: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
packages: write | ||
id-token: 'write' | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up JDK 19 | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: '19' | ||
distribution: 'temurin' | ||
cache: maven | ||
- name: Configure Kubernetes environment | ||
uses: azure/aks-set-context@v1 | ||
with: | ||
creds: ${{ secrets.AZURE_CREDENTIALS }} | ||
|
||
- name: Install Docker | ||
run: | | ||
curl -fsSL https://get.docker.com -o get-docker.sh | ||
sudo sh get-docker.sh | ||
- name: Build, Publish, and Deploy | ||
env: | ||
GITHUB_TOKEN: ${{ github.token }} | ||
run: | | ||
. apps-deployment-azure-script.sh "us-east1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: adminservice | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: adminservice | ||
template: | ||
metadata: | ||
labels: | ||
app: adminservice | ||
spec: | ||
containers: | ||
- name: adminservice | ||
image: your-acr-name.azurecr.io/your-image-name | ||
|
||
ports: | ||
- containerPort: 9091 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: adminservice | ||
spec: | ||
type: LoadBalancer | ||
selector: | ||
app: adminservice | ||
ports: | ||
- protocol: TCP | ||
port: 9091 | ||
targetPort: 9091 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
#!/bin/bash | ||
|
||
# AKS Cluster Configuration | ||
AKS_CLUSTER="cluster" | ||
AKS_RESOURCE_GROUP="group" | ||
AKS_NAMESPACE="default" | ||
ACR_NAME="youracrname" | ||
|
||
# Function to build and deploy service to AKS | ||
build_and_deploy_service() { | ||
SERVICE_NAME="$1" | ||
DEPLOYMENT_NAME="$2" | ||
|
||
# Checkout code | ||
git clone https://github.com/your/repository.git "$SERVICE_NAME" | ||
cd "$SERVICE_NAME" || exit | ||
|
||
|
||
# # Create Azure Container Registry | ||
# az acr create --resource-group $AKS_RESOURCE_GROUP \ | ||
# --name $ACR_NAME \ | ||
# --sku Standard \ | ||
# --location $AKS_REGION | ||
# | ||
# # Providing required permission for downloading Docker image from ACR into AKS Cluster | ||
# az aks update -n $AKS_CLUSTER \ | ||
# -g $AKS_RESOURCE_GROUP \ | ||
# --attach-acr $ACR_NAME | ||
|
||
# Build and push Docker image to ACR | ||
az acr login --name "$ACR_NAME" | ||
docker build -t "$ACR_NAME.azurecr.io/${SERVICE_NAME}:${GITHUB_SHA}" . | ||
docker push "$ACR_NAME.azurecr.io/${SERVICE_NAME}:${GITHUB_SHA}" | ||
|
||
# Configure Kubernetes environment | ||
az aks get-credentials --resource-group "$AKS_RESOURCE_GROUP" --name "$AKS_CLUSTER_NAME" | ||
|
||
# Set the image for kustomize | ||
kustomize edit set image "$ACR_NAME.azurecr.io/${SERVICE_NAME}:${GITHUB_SHA}" | ||
|
||
# Deploy through kubectl | ||
kustomize build . | kubectl apply -f - | ||
kubectl rollout status deployment/"$DEPLOYMENT_NAME" -n "$AKS_NAMESPACE" | ||
kubectl get services -o wide -n "$AKS_NAMESPACE" | ||
|
||
echo "-------------$SERVICE_NAME deployed on $AKS_CLUSTER_NAME----------" | ||
} | ||
|
||
for project in $(cat projects-changes-deploy.txt) | ||
do | ||
: | ||
case $project in | ||
# case 1 build and deploy package common | ||
"common") | ||
cd common || exit | ||
mvn -B clean deploy --file pom.xml | ||
cd ..;; | ||
|
||
# case 2 build and deploy order-service | ||
"order-service") | ||
build_and_deploy_service order-service $AKS_CLUSTER orderservice | ||
cd ..;; | ||
|
||
# case 3 build and deploy inventory-service | ||
"inventory-service") | ||
build_and_deploy_service inventory-service $AKS_CLUSTER inventoryservice | ||
cd ..;; | ||
|
||
# case 4 build and deploy payment-service | ||
"payment-service") | ||
build_and_deploy_service payment-service $AKS_CLUSTER paymentservice | ||
cd ..;; | ||
|
||
# case 5 build and deploy order-service | ||
"shipment-service") | ||
build_and_deploy_service shipment-service $AKS_CLUSTER shipmentservice | ||
cd ..;; | ||
|
||
|
||
# case 6 build and deploy admin-service | ||
"admin-service") | ||
build_and_deploy_service admin-service $AKS_CLUSTER adminservice | ||
cd ..;; | ||
|
||
# case 7 build and deploy cart-service | ||
"cart-service") | ||
build_and_deploy_service cart-service $AKS_CLUSTER cartservice | ||
cd ..;; | ||
esac | ||
|
||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: cartservice | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: cartservice | ||
template: | ||
metadata: | ||
labels: | ||
app: cartservice | ||
spec: | ||
containers: | ||
- name: cartservice | ||
image: your-acr-name.azurecr.io/your-image-name | ||
|
||
ports: | ||
- containerPort: 9091 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: cartservice | ||
spec: | ||
type: LoadBalancer | ||
selector: | ||
app: cartservice | ||
ports: | ||
- protocol: TCP | ||
port: 9091 | ||
targetPort: 9091 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: inventoryservice | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: inventoryservice | ||
template: | ||
metadata: | ||
labels: | ||
app: inventoryservice | ||
spec: | ||
containers: | ||
- name: inventoryservice | ||
image: your-acr-name.azurecr.io/your-image-name | ||
|
||
ports: | ||
- containerPort: 9091 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: inventoryservice | ||
spec: | ||
type: LoadBalancer | ||
selector: | ||
app: inventoryservice | ||
ports: | ||
- protocol: TCP | ||
port: 9091 | ||
targetPort: 9091 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: orderservice | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: orderservice | ||
template: | ||
metadata: | ||
labels: | ||
app: orderservice | ||
spec: | ||
containers: | ||
- name: orderservice | ||
image: your-acr-name.azurecr.io/your-image-name | ||
|
||
ports: | ||
- containerPort: 9090 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: orderservice | ||
spec: | ||
type: LoadBalancer | ||
selector: | ||
app: orderservice | ||
ports: | ||
- protocol: TCP | ||
port: 9090 | ||
targetPort: 9090 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: paymentservice | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: paymentservice | ||
template: | ||
metadata: | ||
labels: | ||
app: paymentservice | ||
spec: | ||
containers: | ||
- name: paymentservice | ||
image: your-acr-name.azurecr.io/your-image-name | ||
|
||
ports: | ||
- containerPort: 9092 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: paymentservice | ||
spec: | ||
type: LoadBalancer | ||
selector: | ||
app: paymentservice | ||
ports: | ||
- protocol: TCP | ||
port: 9092 | ||
targetPort: 9092 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: shipmentservice | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: shipmentservice | ||
template: | ||
metadata: | ||
labels: | ||
app: shipmentservice | ||
spec: | ||
containers: | ||
- name: shipmentservice | ||
image: your-acr-name.azurecr.io/your-image-name | ||
|
||
ports: | ||
- containerPort: 9093 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: shipmentservice | ||
spec: | ||
type: LoadBalancer | ||
selector: | ||
app: shipmentservice | ||
ports: | ||
- protocol: TCP | ||
port: 9093 | ||
targetPort: 9093 |
Oops, something went wrong.