Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit bfacc54

Browse files
Merge pull request #1 from Sadasidral/aks-devhub-ujybv
Add workflow to deploy to AKS
2 parents 29cc920 + b8d24a6 commit bfacc54

File tree

5 files changed

+117
-0
lines changed

5 files changed

+117
-0
lines changed

‎.dockerignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Dockerfile
2+
charts/
3+
target/
4+
work/
5+
.git/

‎.github/workflows/mydotnetapp.yaml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: mydotnetapp
2+
"on":
3+
push:
4+
branches:
5+
- master
6+
workflow_dispatch: {}
7+
env:
8+
ACR_RESOURCE_GROUP: mycyient-rg
9+
AZURE_CONTAINER_REGISTRY: acrworkflow1697130820079
10+
CLUSTER_NAME: Thefirstcluster
11+
CLUSTER_RESOURCE_GROUP: mycyient-rg
12+
CONTAINER_NAME: image-workflow-1697130820079
13+
DEPLOYMENT_MANIFEST_PATH: |
14+
manifests/deployment.yaml
15+
manifests/service.yaml
16+
jobs:
17+
buildImage:
18+
permissions:
19+
contents: read
20+
id-token: write
21+
runs-on: ubuntu-latest
22+
steps:
23+
- uses: actions/checkout@v3
24+
- uses: azure/login@92a5484dfaf04ca78a94597f4f19fea633851fa2
25+
name: Azure login
26+
with:
27+
client-id: ${{ secrets.AZURE_CLIENT_ID }}
28+
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
29+
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
30+
- name: Build and push image to ACR
31+
run: az acr build --image ${{ env.CONTAINER_NAME }}:${{ github.sha }} --registry ${{ env.AZURE_CONTAINER_REGISTRY }} -g ${{ env.ACR_RESOURCE_GROUP }} -f Dockerfile ./
32+
deploy:
33+
permissions:
34+
actions: read
35+
contents: read
36+
id-token: write
37+
runs-on: ubuntu-latest
38+
needs:
39+
- buildImage
40+
steps:
41+
- uses: actions/checkout@v3
42+
- uses: azure/login@92a5484dfaf04ca78a94597f4f19fea633851fa2
43+
name: Azure login
44+
with:
45+
client-id: ${{ secrets.AZURE_CLIENT_ID }}
46+
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
47+
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
48+
- uses: azure/use-kubelogin@v1
49+
name: Set up kubelogin for non-interactive login
50+
with:
51+
kubelogin-version: v0.0.25
52+
- uses: azure/aks-set-context@v3
53+
name: Get K8s context
54+
with:
55+
admin: "false"
56+
cluster-name: ${{ env.CLUSTER_NAME }}
57+
resource-group: ${{ env.CLUSTER_RESOURCE_GROUP }}
58+
use-kubelogin: "true"
59+
- uses: Azure/k8s-deploy@v4
60+
name: Deploys application
61+
with:
62+
action: deploy
63+
images: ${{ env.AZURE_CONTAINER_REGISTRY }}.azurecr.io/${{ env.CONTAINER_NAME }}:${{ github.sha }}
64+
manifests: ${{ env.DEPLOYMENT_MANIFEST_PATH }}
65+
namespace: namespace-workflow-1697130820079

‎Dockerfile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
FROM maven:3-eclipse-temurin-8 as BUILD
2+
3+
COPY . /usr/src/app
4+
RUN mvn --batch-mode -f /usr/src/app/pom.xml clean package
5+
6+
FROM eclipse-temurin:8-jre
7+
ENV PORT 8080
8+
EXPOSE 8080
9+
COPY --from=BUILD /usr/src/app/target /opt/target
10+
WORKDIR /opt/target
11+
12+
CMD ["/bin/bash", "-c", "find -type f -name '*-SNAPSHOT.jar' | xargs java -jar"]

‎manifests/deployment.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: mydotnetapp
5+
labels:
6+
app: mydotnetapp
7+
namespace: namespace-workflow-1697130820079
8+
spec:
9+
replicas: 1
10+
selector:
11+
matchLabels:
12+
app: mydotnetapp
13+
template:
14+
metadata:
15+
labels:
16+
app: mydotnetapp
17+
spec:
18+
containers:
19+
- name: mydotnetapp
20+
image: acrworkflow1697130820079.azurecr.io/image-workflow-1697130820079:latest
21+
ports:
22+
- containerPort: 8080

‎manifests/service.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: mydotnetapp
5+
namespace: namespace-workflow-1697130820079
6+
spec:
7+
type: LoadBalancer
8+
selector:
9+
app: mydotnetapp
10+
ports:
11+
- protocol: TCP
12+
port: 8080
13+
targetPort: 8080

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /