Merge pull request #1 from BalighMehrez/aks-devhub-vqgja
Add workflow to deploy to AKS
This commit is contained in:
commit
ee9a287d0f
4
.dockerignore
Normal file
4
.dockerignore
Normal file
@ -0,0 +1,4 @@
|
||||
Dockerfile
|
||||
charts/
|
||||
bin/
|
||||
obj/
|
65
.github/workflows/TheArchitectsVault-WF.yaml
vendored
Normal file
65
.github/workflows/TheArchitectsVault-WF.yaml
vendored
Normal file
@ -0,0 +1,65 @@
|
||||
name: TheArchitectsVault-WF
|
||||
"on":
|
||||
push:
|
||||
branches:
|
||||
- dev
|
||||
workflow_dispatch: {}
|
||||
env:
|
||||
ACR_RESOURCE_GROUP: TheArchitectsVault_group
|
||||
AZURE_CONTAINER_REGISTRY: acrworkflow1686232508452
|
||||
CLUSTER_NAME: TheArchitectsVault
|
||||
CLUSTER_RESOURCE_GROUP: TheArchitectsVault_group
|
||||
CONTAINER_NAME: image-workflow-1686232508452
|
||||
DEPLOYMENT_MANIFEST_PATH: |
|
||||
manifests/deployment.yaml
|
||||
manifests/service.yaml
|
||||
jobs:
|
||||
buildImage:
|
||||
permissions:
|
||||
contents: read
|
||||
id-token: write
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: azure/login@92a5484dfaf04ca78a94597f4f19fea633851fa2
|
||||
name: Azure login
|
||||
with:
|
||||
client-id: ${{ secrets.AZURE_CLIENT_ID }}
|
||||
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
|
||||
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
|
||||
- name: Build and push image to ACR
|
||||
run: az acr build --image ${{ env.CONTAINER_NAME }}:${{ github.sha }} --registry ${{ env.AZURE_CONTAINER_REGISTRY }} -g ${{ env.ACR_RESOURCE_GROUP }} -f Dockerfile ./
|
||||
deploy:
|
||||
permissions:
|
||||
actions: read
|
||||
contents: read
|
||||
id-token: write
|
||||
runs-on: ubuntu-latest
|
||||
needs:
|
||||
- buildImage
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: azure/login@92a5484dfaf04ca78a94597f4f19fea633851fa2
|
||||
name: Azure login
|
||||
with:
|
||||
client-id: ${{ secrets.AZURE_CLIENT_ID }}
|
||||
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
|
||||
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
|
||||
- uses: azure/use-kubelogin@v1
|
||||
name: Set up kubelogin for non-interactive login
|
||||
with:
|
||||
kubelogin-version: v0.0.25
|
||||
- uses: azure/aks-set-context@v3
|
||||
name: Get K8s context
|
||||
with:
|
||||
admin: "false"
|
||||
cluster-name: ${{ env.CLUSTER_NAME }}
|
||||
resource-group: ${{ env.CLUSTER_RESOURCE_GROUP }}
|
||||
use-kubelogin: "true"
|
||||
- uses: Azure/k8s-deploy@v4
|
||||
name: Deploys application
|
||||
with:
|
||||
action: deploy
|
||||
images: ${{ env.AZURE_CONTAINER_REGISTRY }}.azurecr.io/${{ env.CONTAINER_NAME }}:${{ github.sha }}
|
||||
manifests: ${{ env.DEPLOYMENT_MANIFEST_PATH }}
|
||||
namespace: namespace-workflow-1686232508452
|
21
Dockerfile
Normal file
21
Dockerfile
Normal file
@ -0,0 +1,21 @@
|
||||
FROM mcr.microsoft.com/dotnet/sdk:7.0 AS builder
|
||||
WORKDIR /app
|
||||
|
||||
# caches restore result by copying csproj file separately
|
||||
COPY *.csproj .
|
||||
RUN dotnet restore
|
||||
|
||||
COPY . .
|
||||
RUN dotnet publish --output /app/ --configuration Release --no-restore
|
||||
RUN sed -n 's:.*<AssemblyName>\(.*\)</AssemblyName>.*:\1:p' *.csproj > __assemblyname
|
||||
RUN if [ ! -s __assemblyname ]; then filename=$(ls *.csproj); echo ${filename%.*} > __assemblyname; fi
|
||||
|
||||
# Stage 2
|
||||
FROM mcr.microsoft.com/dotnet/aspnet:7.0
|
||||
WORKDIR /app
|
||||
COPY --from=builder /app .
|
||||
|
||||
ENV PORT 5000
|
||||
EXPOSE 5000
|
||||
|
||||
ENTRYPOINT dotnet $(cat /app/__assemblyname).dll --urls "http://*:5000"
|
22
manifests/deployment.yaml
Normal file
22
manifests/deployment.yaml
Normal file
@ -0,0 +1,22 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: TheArchitectsVault-WF
|
||||
labels:
|
||||
app: TheArchitectsVault-WF
|
||||
namespace: namespace-workflow-1686232508452
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: TheArchitectsVault-WF
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: TheArchitectsVault-WF
|
||||
spec:
|
||||
containers:
|
||||
- name: TheArchitectsVault-WF
|
||||
image: acrworkflow1686232508452.azurecr.io/image-workflow-1686232508452:latest
|
||||
ports:
|
||||
- containerPort: 5000
|
13
manifests/service.yaml
Normal file
13
manifests/service.yaml
Normal file
@ -0,0 +1,13 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: TheArchitectsVault-WF
|
||||
namespace: namespace-workflow-1686232508452
|
||||
spec:
|
||||
type: LoadBalancer
|
||||
selector:
|
||||
app: TheArchitectsVault-WF
|
||||
ports:
|
||||
- protocol: TCP
|
||||
port: 5000
|
||||
targetPort: 5000
|
Loading…
x
Reference in New Issue
Block a user