Skip to content
Open

test #13

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
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Dockerfile
charts/
65 changes: 65 additions & 0 deletions .github/workflows/Demo.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Demo
"on":
push:
branches:
- main
workflow_dispatch: {}
env:
ACR_RESOURCE_GROUP: my-resource-group
AZURE_CONTAINER_REGISTRY: acrworkflow1685610716580
CLUSTER_NAME: my-aks-cluster
CLUSTER_RESOURCE_GROUP: my-resource-group
CONTAINER_NAME: image-workflow-1685610716580
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@v1.4.3
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@v1.4.3
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-1685610716580
65 changes: 65 additions & 0 deletions .github/workflows/demo-app.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: demo-app
"on":
push:
branches:
- main
workflow_dispatch: {}
env:
ACR_RESOURCE_GROUP: my-resource-group
AZURE_CONTAINER_REGISTRY: acrworkflow1685611537556
CLUSTER_NAME: my-aks-cluster
CLUSTER_RESOURCE_GROUP: my-resource-group
CONTAINER_NAME: image-workflow-1685611537556
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@v1.4.3
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 ./src
deploy:
permissions:
actions: read
contents: read
id-token: write
runs-on: ubuntu-latest
needs:
- buildImage
steps:
- uses: actions/checkout@v3
- uses: azure/login@v1.4.3
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-1685611537556
65 changes: 65 additions & 0 deletions .github/workflows/github.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: github
"on":
push:
branches:
- main
workflow_dispatch: {}
env:
ACR_RESOURCE_GROUP: exampleaks1registry_group
AZURE_CONTAINER_REGISTRY: exampleaks1registry
CLUSTER_NAME: example-aks1
CLUSTER_RESOURCE_GROUP: example-resources
CONTAINER_NAME: image-workflow-1685511374382
DEPLOYMENT_MANIFEST_PATH: |
./manifests/deployment-1.yml
./manifests/deployment.yml
jobs:
buildImage:
permissions:
contents: read
id-token: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: azure/login@v1.4.3
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@v1.4.3
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-1685511374382
31 changes: 31 additions & 0 deletions .github/workflows/sync_codeowners_to_devops.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Sync CODEOWNERS to DevOps Repo

on:
push:
paths:
- CODEOWNERS

jobs:
sync-codeowners:
runs-on: ubuntu-latest

steps:
- name: Checkout Source Repository
uses: actions/checkout@v2

- name: Sync CODEOWNERS to DevOps Repo
env:
GITHUB_TOKEN: ${{ secrets.TARGET_REPOS_PAT }}
run: |
# Clone the devops repo
git clone https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/edwinkullu/Terraform.git

# Copy CODEOWNERS to the devops repo
cp CODEOWNERS Terraform/.github/CODEOWNERS

cd devops-repo
git add .github/CODEOWNERS
git commit -m "Update CODEOWNERS from repo2"
git push
cd ..
rm -rf devops-repo
1 change: 1 addition & 0 deletions CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

20 changes: 6 additions & 14 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,19 +1,11 @@
FROM node:8
FROM node:19
ENV PORT 3000
EXPOSE 3000

# Create app directory
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app

# Install app dependencies
# A wildcard is used to ensure both package.json AND package-lock.json are copied
# where available (npm@5+)
COPY package*.json ./

COPY package.json .
RUN npm install
# If you are building your code for production
# RUN npm install --only=production

# Bundle app source
COPY . .

EXPOSE 8080
CMD [ "npm", "start" ]
CMD ["npm", "start"]
22 changes: 22 additions & 0 deletions manifests/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: demo-app
labels:
app: demo-app
namespace: namespace-workflow-1685611537556
spec:
replicas: 1
selector:
matchLabels:
app: demo-app
template:
metadata:
labels:
app: demo-app
spec:
containers:
- name: demo-app
image: acrworkflow1685611537556.azurecr.io/image-workflow-1685611537556:latest
ports:
- containerPort: 3000
13 changes: 13 additions & 0 deletions manifests/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: v1
kind: Service
metadata:
name: demo-app
namespace: namespace-workflow-1685611537556
spec:
type: LoadBalancer
selector:
app: demo-app
ports:
- protocol: TCP
port: 3000
targetPort: 3000