From f9010c0d8b85bd0007a1095dcaea65fdaac66e3c Mon Sep 17 00:00:00 2001 From: saidinkar <60877278+saidinkar@users.noreply.github.com> Date: Mon, 21 Aug 2023 16:59:21 +0530 Subject: [PATCH 01/94] Create main.yml --- .github/workflows/main.yml | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..ac225a9 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,38 @@ +name: Python application + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +permissions: + contents: read + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Set up Python 3.10 + uses: actions/setup-python@v3 + with: + python-version: "3.10" + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install flake8 pytest + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + - name: Lint with flake8 + run: | + # stop the build if there are Python syntax errors or undefined names + flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics + # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide + flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + - name: Test with pytest + run: | + pip install pytest + export PYTHONPATH=src + pytest From f6f862598d3b65c43d017e7eb0ecbc9857a6fc76 Mon Sep 17 00:00:00 2001 From: saidinkar <60877278+saidinkar@users.noreply.github.com> Date: Mon, 21 Aug 2023 17:01:17 +0530 Subject: [PATCH 02/94] Delete python-app.yml --- .github/workflows/python-app.yml | 38 -------------------------------- 1 file changed, 38 deletions(-) delete mode 100644 .github/workflows/python-app.yml diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml deleted file mode 100644 index ac225a9..0000000 --- a/.github/workflows/python-app.yml +++ /dev/null @@ -1,38 +0,0 @@ -name: Python application - -on: - push: - branches: [ "main" ] - pull_request: - branches: [ "main" ] - -permissions: - contents: read - -jobs: - build: - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - - name: Set up Python 3.10 - uses: actions/setup-python@v3 - with: - python-version: "3.10" - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install flake8 pytest - if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - - name: Lint with flake8 - run: | - # stop the build if there are Python syntax errors or undefined names - flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics - # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide - flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics - - name: Test with pytest - run: | - pip install pytest - export PYTHONPATH=src - pytest From c6f2117e41c4879be1b59afda6d323d5adcdeaf0 Mon Sep 17 00:00:00 2001 From: saidinkar <60877278+saidinkar@users.noreply.github.com> Date: Mon, 21 Aug 2023 17:09:01 +0530 Subject: [PATCH 03/94] Updated trigger --- .github/workflows/main.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ac225a9..0033222 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,10 +1,6 @@ name: Python application -on: - push: - branches: [ "main" ] - pull_request: - branches: [ "main" ] +on: workflow_call permissions: contents: read From d44a0436672d970232cc46eaa738a1231f732b69 Mon Sep 17 00:00:00 2001 From: saidinkar <60877278+saidinkar@users.noreply.github.com> Date: Tue, 22 Aug 2023 05:50:04 +0530 Subject: [PATCH 04/94] Update app.py --- src/app.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/app.py b/src/app.py index e77ad22..9813006 100644 --- a/src/app.py +++ b/src/app.py @@ -1,10 +1,11 @@ -from flask import Flask +from flask import Flask, request app = Flask(__name__) -@app.route("/") -def index(): - return "Hello, world!" +@app.route("/first_script") +def hello_world(): + request_body = request.json + return f"

Hello, World! {request_body}

" if __name__ == "__main__": From 1f803112ff7aaacb91f140811be2c7009a6de378 Mon Sep 17 00:00:00 2001 From: saidinkar <60877278+saidinkar@users.noreply.github.com> Date: Tue, 22 Aug 2023 05:50:34 +0530 Subject: [PATCH 05/94] Update requirements.txt --- requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements.txt b/requirements.txt index 491b91e..f531384 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,4 @@ flask pytest gunicorn +requests From f99d71a958511283a3d3eb45c3984781f2305f91 Mon Sep 17 00:00:00 2001 From: saidinkar <60877278+saidinkar@users.noreply.github.com> Date: Tue, 22 Aug 2023 05:54:31 +0530 Subject: [PATCH 06/94] Create python-package-conda.yml --- .github/workflows/python-package-conda.yml | 34 ++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 .github/workflows/python-package-conda.yml diff --git a/.github/workflows/python-package-conda.yml b/.github/workflows/python-package-conda.yml new file mode 100644 index 0000000..384f9b7 --- /dev/null +++ b/.github/workflows/python-package-conda.yml @@ -0,0 +1,34 @@ +name: Python Package using Conda + +on: [push] + +jobs: + build-linux: + runs-on: ubuntu-latest + strategy: + max-parallel: 5 + + steps: + - uses: actions/checkout@v3 + - name: Set up Python 3.10 + uses: actions/setup-python@v3 + with: + python-version: '3.10' + - name: Add conda to system path + run: | + # $CONDA is an environment variable pointing to the root of the miniconda directory + echo $CONDA/bin >> $GITHUB_PATH + - name: Install dependencies + run: | + conda env update --file environment.yml --name base + - name: Lint with flake8 + run: | + conda install flake8 + # stop the build if there are Python syntax errors or undefined names + flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics + # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide + flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + - name: Test with pytest + run: | + conda install pytest + pytest From 2d9efecacfdf6631a63de9be673c592de304b463 Mon Sep 17 00:00:00 2001 From: saidinkar <60877278+saidinkar@users.noreply.github.com> Date: Tue, 22 Aug 2023 05:55:42 +0530 Subject: [PATCH 07/94] Delete python-package-conda.yml --- .github/workflows/python-package-conda.yml | 34 ---------------------- 1 file changed, 34 deletions(-) delete mode 100644 .github/workflows/python-package-conda.yml diff --git a/.github/workflows/python-package-conda.yml b/.github/workflows/python-package-conda.yml deleted file mode 100644 index 384f9b7..0000000 --- a/.github/workflows/python-package-conda.yml +++ /dev/null @@ -1,34 +0,0 @@ -name: Python Package using Conda - -on: [push] - -jobs: - build-linux: - runs-on: ubuntu-latest - strategy: - max-parallel: 5 - - steps: - - uses: actions/checkout@v3 - - name: Set up Python 3.10 - uses: actions/setup-python@v3 - with: - python-version: '3.10' - - name: Add conda to system path - run: | - # $CONDA is an environment variable pointing to the root of the miniconda directory - echo $CONDA/bin >> $GITHUB_PATH - - name: Install dependencies - run: | - conda env update --file environment.yml --name base - - name: Lint with flake8 - run: | - conda install flake8 - # stop the build if there are Python syntax errors or undefined names - flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics - # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide - flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics - - name: Test with pytest - run: | - conda install pytest - pytest From cc63392d345c6921d9f0de7d145d9eb7c489f9e5 Mon Sep 17 00:00:00 2001 From: Dinkar Gedela Date: Tue, 22 Aug 2023 11:06:46 +0530 Subject: [PATCH 08/94] added docker file --- Dockerfile | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..70007e9 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,6 @@ +FROM python:3-alpine3.15 +WORKDIR /app +COPY . /app +RUN pip install -r requirements.txt +EXPOSE 3000 +CMD [ "python" , "/src/app.py" ] \ No newline at end of file From 70d8eb2074c84afdda240569d7f150147570c1b1 Mon Sep 17 00:00:00 2001 From: saidinkar <60877278+saidinkar@users.noreply.github.com> Date: Tue, 22 Aug 2023 11:11:15 +0530 Subject: [PATCH 09/94] Create docker-image.yml --- .github/workflows/docker-image.yml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 .github/workflows/docker-image.yml diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml new file mode 100644 index 0000000..d657a63 --- /dev/null +++ b/.github/workflows/docker-image.yml @@ -0,0 +1,18 @@ +name: Docker Image CI + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Build the Docker image + run: docker build . --file Dockerfile --tag my-image-name:$(date +%s) From 6fa9536d9a71fda9773b7909980e0fe4f95ea861 Mon Sep 17 00:00:00 2001 From: Dinkar Gedela Date: Tue, 22 Aug 2023 11:27:16 +0530 Subject: [PATCH 10/94] added keys to GA --- .github/workflows/docker-build.yml | 0 .github/workflows/docker-image.yml | 6 +----- 2 files changed, 1 insertion(+), 5 deletions(-) create mode 100644 .github/workflows/docker-build.yml diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml new file mode 100644 index 0000000..e69de29 diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index d657a63..2eb7d8a 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -1,10 +1,6 @@ name: Docker Image CI -on: - push: - branches: [ "main" ] - pull_request: - branches: [ "main" ] +on: workflow_call jobs: From f22f90e2fb503cec4ff3f476f76f915a0fc2a37f Mon Sep 17 00:00:00 2001 From: Dinkar Gedela Date: Tue, 22 Aug 2023 11:28:56 +0530 Subject: [PATCH 11/94] added keys to GA --- .github/workflows/docker-build.yml | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index e69de29..3e5ce0e 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -0,0 +1,29 @@ +name: Docker Build + +on: [push] + +# Environment variables available to all jobs and steps in this workflow +env: + REGISTRY_NAME: gdinkar +# CLUSTER_NAME: my-cluster-name +# CLUSTER_RESOURCE_GROUP: my-cluster-resource-group +# NAMESPACE: default + +jobs: + build: + runs-on: ubuntu-latest + #environment: dev + steps: + - uses: actions/checkout@master + + # Connect to Azure Container registry (ACR) + - uses: azure/docker-login@v1 + with: + login-server: ${{ env.REGISTRY_NAME }}.azurecr.io + username: ${{ secrets.REGISTRY_USERNAME }} + password: ${{ secrets.REGISTRY_PASSWORD }} + + # Container build and push to a Azure Container registry (ACR) + - run: | + docker build . -t ${{ env.REGISTRY_NAME }}.azurecr.io/mytestimage:${{ github.sha }} + docker push ${{ env.REGISTRY_NAME }}.azurecr.io/mytestimage:${{ github.sha }} \ No newline at end of file From bb57a54b8a301839a1c8c5ddaf7a1f06e772ad68 Mon Sep 17 00:00:00 2001 From: sai Date: Wed, 23 Aug 2023 18:57:29 +0530 Subject: [PATCH 12/94] modified the repos --- Dockerfile | 5 +++-- src/app.py | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 70007e9..3c1281b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,5 +2,6 @@ FROM python:3-alpine3.15 WORKDIR /app COPY . /app RUN pip install -r requirements.txt -EXPOSE 3000 -CMD [ "python" , "/src/app.py" ] \ No newline at end of file +EXPOSE 8080 +ENTRYPOINT [ "python" ] +CMD [ "/src/app.py" ] \ No newline at end of file diff --git a/src/app.py b/src/app.py index 9813006..f32d7b8 100644 --- a/src/app.py +++ b/src/app.py @@ -9,5 +9,5 @@ def hello_world(): if __name__ == "__main__": - app.run() + app.run(host='0.0.0.0' , port=8080) From af77be93633772e4bcca9607de490ca0e9abb541 Mon Sep 17 00:00:00 2001 From: sai Date: Mon, 28 Aug 2023 13:32:49 +0530 Subject: [PATCH 13/94] modified Dockerfile --- Dockerfile | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Dockerfile b/Dockerfile index 3c1281b..625d922 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,22 @@ +#This is the base image for this Dockerfile FROM python:3-alpine3.15 + +LABEL BuildBy="Dinkar Gedela" +LABEL BuilderEmail="dgedela@archinsurance.com" + +#Set the working directory in the container WORKDIR /app COPY . /app + +#Copy the requirements file into the container +COPY requirements.txt . + +#install the dependencies from requirements.txt RUN pip install -r requirements.txt + +#Open the port on which Flask app will run EXPOSE 8080 + +#commands to run the Flask app ENTRYPOINT [ "python" ] CMD [ "/src/app.py" ] \ No newline at end of file From 17593962c1ef6af446208be82eacc6e8211ae506 Mon Sep 17 00:00:00 2001 From: sai Date: Mon, 28 Aug 2023 13:40:40 +0530 Subject: [PATCH 14/94] renamed Dockerfile --- Dockerfile => Dockerfile.Dev | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Dockerfile => Dockerfile.Dev (100%) diff --git a/Dockerfile b/Dockerfile.Dev similarity index 100% rename from Dockerfile rename to Dockerfile.Dev From 8478ff325af8c51557ad71a0fef4fe7e165419b5 Mon Sep 17 00:00:00 2001 From: sai Date: Thu, 31 Aug 2023 11:38:49 +0530 Subject: [PATCH 15/94] checking on new workflow --- .github/workflows/docker-build.yml | 41 ++++++++++++++++++++--- .github/workflows/docker-image.yml | 43 ++++++++++++++++++++----- Dockerfile.Dev => Docker/Dockerfile.Dev | 0 3 files changed, 71 insertions(+), 13 deletions(-) rename Dockerfile.Dev => Docker/Dockerfile.Dev (100%) diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index 3e5ce0e..db2df8b 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -1,13 +1,13 @@ name: Docker Build -on: [push] +on: workflow_call # Environment variables available to all jobs and steps in this workflow env: REGISTRY_NAME: gdinkar -# CLUSTER_NAME: my-cluster-name -# CLUSTER_RESOURCE_GROUP: my-cluster-resource-group -# NAMESPACE: default + CLUSTER_NAME: myaks + CLUSTER_RESOURCE_GROUP: github_actions + NAMESPACE: default jobs: build: @@ -26,4 +26,35 @@ jobs: # Container build and push to a Azure Container registry (ACR) - run: | docker build . -t ${{ env.REGISTRY_NAME }}.azurecr.io/mytestimage:${{ github.sha }} - docker push ${{ env.REGISTRY_NAME }}.azurecr.io/mytestimage:${{ github.sha }} \ No newline at end of file + docker push ${{ env.REGISTRY_NAME }}.azurecr.io/mytestimage:${{ github.sha }} + # Set the target Azure Kubernetes Service (AKS) cluster. + - uses: azure/aks-set-context@v1 + with: + creds: '${{ secrets.AZURE_CREDENTIALS }}' + cluster-name: ${{ env.CLUSTER_NAME }} + resource-group: ${{ env.CLUSTER_RESOURCE_GROUP }} + + # Create namespace if doesn't exist + - run: | + kubectl create namespace ${{ env.NAMESPACE }} --dry-run -o json | kubectl apply -f - + + # Create imagepullsecret for Azure Container registry (ACR) + - uses: azure/k8s-create-secret@v1 + with: + container-registry-url: ${{ env.REGISTRY_NAME }}.azurecr.io + container-registry-username: ${{ secrets.REGISTRY_USERNAME }} + container-registry-password: ${{ secrets.REGISTRY_PASSWORD }} + secret-name: ${{ env.REGISTRY_NAME }}-registry-connection + namespace: ${{ env.NAMESPACE }} + + # Deploy app to AKS + - uses: azure/k8s-deploy@v1 + with: + manifests: | + manifests/deployment.yml + manifests/service.yml + images: | + ${{ env.REGISTRY_NAME }}.azurecr.io/myimage:${{ github.sha }} + imagepullsecrets: | + ${{ env.REGISTRY_NAME }}-registry-connection + namespace: ${{ env.NAMESPACE }} \ No newline at end of file diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 2eb7d8a..2f4a039 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -1,14 +1,41 @@ -name: Docker Image CI +#this pipeline is for python API on Azure Kubernetes Services -on: workflow_call +name: Build CI -jobs: +on: push - build: +# Below environment variables available to all jobs and steps in this workflow +env: + REGISTRY_NAME: sai9356 + # CLUSTER_NAME: cluster-name + # CLUSTER_RESOURCE_GROUP: cluster-resource-group + # NAMESPACE: default +jobs: + build: runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: Build the Docker image - run: docker build . --file Dockerfile --tag my-image-name:$(date +%s) + - name: Checkout code + - uses: actions/checkout@master + + # Connecting to Azure Container registry (ACR) + - name: ACR Login + - uses: azure/docker-login@v1 + with: + login-server: ${{ env.REGISTRY_NAME }}.azurecr.io + username: ${{ secrets.REGISTRY_USERNAME }} + password: ${{ secrets.REGISTRY_PASSWORD }} + + # Docker container build + - name: Docker Build + - run: | + echo '<-----------------------Docker build started----------------------->' + docker build . -t ${{ env.REGISTRY_NAME }}.azurecr.io/mytestimage:${{ github.sha }} + echo '<------------------------Docker build Ended------------------------>' + + # Docker Container Push to ACR + - name: Docker Push + - run: | + echo '<-----------------------Docker Publish started----------------------->' + docker push ${{ env.REGISTRY_NAME }}.azurecr.io/mytestimage:${{ github.sha }} + echo '<------------------------Docker Publish Ended------------------------>' \ No newline at end of file diff --git a/Dockerfile.Dev b/Docker/Dockerfile.Dev similarity index 100% rename from Dockerfile.Dev rename to Docker/Dockerfile.Dev From 100b2f56e245021a2020362979f60610aedb2cd1 Mon Sep 17 00:00:00 2001 From: sai Date: Thu, 31 Aug 2023 11:45:31 +0530 Subject: [PATCH 16/94] edited workflow --- .github/workflows/docker-image.yml | 36 +++++++++++++++--------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 2f4a039..f17a92e 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -15,27 +15,27 @@ jobs: build: runs-on: ubuntu-latest steps: - - name: Checkout code - - uses: actions/checkout@master + - name: Checkout code + - uses: actions/checkout@master # Connecting to Azure Container registry (ACR) - - name: ACR Login - - uses: azure/docker-login@v1 - with: - login-server: ${{ env.REGISTRY_NAME }}.azurecr.io - username: ${{ secrets.REGISTRY_USERNAME }} - password: ${{ secrets.REGISTRY_PASSWORD }} + - name: ACR Login + - uses: azure/docker-login@v1 + with: + login-server: ${{ env.REGISTRY_NAME }}.azurecr.io + username: ${{ secrets.REGISTRY_USERNAME }} + password: ${{ secrets.REGISTRY_PASSWORD }} # Docker container build - - name: Docker Build - - run: | - echo '<-----------------------Docker build started----------------------->' - docker build . -t ${{ env.REGISTRY_NAME }}.azurecr.io/mytestimage:${{ github.sha }} - echo '<------------------------Docker build Ended------------------------>' + - name: Docker Build + - run: | + echo '<-----------------------Docker build started----------------------->' + docker build . -t ${{ env.REGISTRY_NAME }}.azurecr.io/mytestimage:${{ github.sha }} + echo '<------------------------Docker build Ended------------------------>' # Docker Container Push to ACR - - name: Docker Push - - run: | - echo '<-----------------------Docker Publish started----------------------->' - docker push ${{ env.REGISTRY_NAME }}.azurecr.io/mytestimage:${{ github.sha }} - echo '<------------------------Docker Publish Ended------------------------>' \ No newline at end of file + - name: Docker Push + - run: | + echo '<-----------------------Docker Publish started----------------------->' + docker push ${{ env.REGISTRY_NAME }}.azurecr.io/mytestimage:${{ github.sha }} + echo '<------------------------Docker Publish Ended------------------------>' \ No newline at end of file From 2b6a5f93f5af5b91a03ffc24034e7811361fa1f7 Mon Sep 17 00:00:00 2001 From: sai Date: Thu, 31 Aug 2023 11:49:19 +0530 Subject: [PATCH 17/94] edited workflow --- .github/workflows/docker-image.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index f17a92e..8695a42 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -16,11 +16,11 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout code - - uses: actions/checkout@master + uses: actions/checkout@master # Connecting to Azure Container registry (ACR) - name: ACR Login - - uses: azure/docker-login@v1 + uses: azure/docker-login@v1 with: login-server: ${{ env.REGISTRY_NAME }}.azurecr.io username: ${{ secrets.REGISTRY_USERNAME }} @@ -28,14 +28,14 @@ jobs: # Docker container build - name: Docker Build - - run: | + run: | echo '<-----------------------Docker build started----------------------->' docker build . -t ${{ env.REGISTRY_NAME }}.azurecr.io/mytestimage:${{ github.sha }} echo '<------------------------Docker build Ended------------------------>' # Docker Container Push to ACR - name: Docker Push - - run: | + run: | echo '<-----------------------Docker Publish started----------------------->' docker push ${{ env.REGISTRY_NAME }}.azurecr.io/mytestimage:${{ github.sha }} echo '<------------------------Docker Publish Ended------------------------>' \ No newline at end of file From 2fcc567f35c7179f53055e07f38e5044a84e07f8 Mon Sep 17 00:00:00 2001 From: sai Date: Thu, 31 Aug 2023 11:53:38 +0530 Subject: [PATCH 18/94] changed dockerfile path --- .github/workflows/docker-image.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 8695a42..865dc6f 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -30,7 +30,7 @@ jobs: - name: Docker Build run: | echo '<-----------------------Docker build started----------------------->' - docker build . -t ${{ env.REGISTRY_NAME }}.azurecr.io/mytestimage:${{ github.sha }} + docker build /Docker/Dcokerfile.Dev -t ${{ env.REGISTRY_NAME }}.azurecr.io/mytestimage:${{ github.sha }} echo '<------------------------Docker build Ended------------------------>' # Docker Container Push to ACR From aee00496d8b79a1f864a761901317293ca96f4d4 Mon Sep 17 00:00:00 2001 From: sai Date: Thu, 31 Aug 2023 12:12:27 +0530 Subject: [PATCH 19/94] changed dockerfile path to Docker --- .github/workflows/docker-image.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 865dc6f..e9c4c3b 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -30,7 +30,7 @@ jobs: - name: Docker Build run: | echo '<-----------------------Docker build started----------------------->' - docker build /Docker/Dcokerfile.Dev -t ${{ env.REGISTRY_NAME }}.azurecr.io/mytestimage:${{ github.sha }} + docker build /Docker -t ${{ env.REGISTRY_NAME }}.azurecr.io/mytestimage:${{ github.sha }} echo '<------------------------Docker build Ended------------------------>' # Docker Container Push to ACR From e18dc31a1be972fd8115fc53c564d528770690c3 Mon Sep 17 00:00:00 2001 From: sai Date: Thu, 31 Aug 2023 12:14:26 +0530 Subject: [PATCH 20/94] added docker dir --- .github/workflows/docker-image.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index e9c4c3b..878a60e 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -29,8 +29,9 @@ jobs: # Docker container build - name: Docker Build run: | - echo '<-----------------------Docker build started----------------------->' - docker build /Docker -t ${{ env.REGISTRY_NAME }}.azurecr.io/mytestimage:${{ github.sha }} + echo '<-----------------------Docker build started----------------------->' + cd /Docker + docker build . -t ${{ env.REGISTRY_NAME }}.azurecr.io/mytestimage:${{ github.sha }} echo '<------------------------Docker build Ended------------------------>' # Docker Container Push to ACR From 03af80a7b95c4d92b74a5464a6c8393d419e6879 Mon Sep 17 00:00:00 2001 From: sai Date: Thu, 31 Aug 2023 12:16:35 +0530 Subject: [PATCH 21/94] added dockerfile new --- Dockerfile | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..625d922 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,22 @@ +#This is the base image for this Dockerfile +FROM python:3-alpine3.15 + +LABEL BuildBy="Dinkar Gedela" +LABEL BuilderEmail="dgedela@archinsurance.com" + +#Set the working directory in the container +WORKDIR /app +COPY . /app + +#Copy the requirements file into the container +COPY requirements.txt . + +#install the dependencies from requirements.txt +RUN pip install -r requirements.txt + +#Open the port on which Flask app will run +EXPOSE 8080 + +#commands to run the Flask app +ENTRYPOINT [ "python" ] +CMD [ "/src/app.py" ] \ No newline at end of file From b53d95c6a6c9fc149aa975b02a64cef05d105181 Mon Sep 17 00:00:00 2001 From: sai Date: Thu, 31 Aug 2023 12:18:43 +0530 Subject: [PATCH 22/94] added dockerfile new --- .github/workflows/docker-image.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 878a60e..0452ab9 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -30,7 +30,6 @@ jobs: - name: Docker Build run: | echo '<-----------------------Docker build started----------------------->' - cd /Docker docker build . -t ${{ env.REGISTRY_NAME }}.azurecr.io/mytestimage:${{ github.sha }} echo '<------------------------Docker build Ended------------------------>' From f37e5e8194b0221bcb44b6d5f0c5ded52125f00d Mon Sep 17 00:00:00 2001 From: sai Date: Thu, 31 Aug 2023 12:26:11 +0530 Subject: [PATCH 23/94] added dockerfile path --- .github/workflows/docker-image.yml | 2 +- Dockerfile | 22 ---------------------- 2 files changed, 1 insertion(+), 23 deletions(-) delete mode 100644 Dockerfile diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 0452ab9..4139430 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -30,7 +30,7 @@ jobs: - name: Docker Build run: | echo '<-----------------------Docker build started----------------------->' - docker build . -t ${{ env.REGISTRY_NAME }}.azurecr.io/mytestimage:${{ github.sha }} + docker build . -t ${{ env.REGISTRY_NAME }}.azurecr.io/mytestimage:${{ github.sha }} -f /Docker/Dockerfile.Dev . echo '<------------------------Docker build Ended------------------------>' # Docker Container Push to ACR diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 625d922..0000000 --- a/Dockerfile +++ /dev/null @@ -1,22 +0,0 @@ -#This is the base image for this Dockerfile -FROM python:3-alpine3.15 - -LABEL BuildBy="Dinkar Gedela" -LABEL BuilderEmail="dgedela@archinsurance.com" - -#Set the working directory in the container -WORKDIR /app -COPY . /app - -#Copy the requirements file into the container -COPY requirements.txt . - -#install the dependencies from requirements.txt -RUN pip install -r requirements.txt - -#Open the port on which Flask app will run -EXPOSE 8080 - -#commands to run the Flask app -ENTRYPOINT [ "python" ] -CMD [ "/src/app.py" ] \ No newline at end of file From 2c4971804d0fc6ab8b3c78a95ee1b9341fcc056f Mon Sep 17 00:00:00 2001 From: sai Date: Thu, 31 Aug 2023 12:45:50 +0530 Subject: [PATCH 24/94] added dockerfile path --- .github/workflows/docker-image.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 4139430..b5bec8b 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -30,7 +30,7 @@ jobs: - name: Docker Build run: | echo '<-----------------------Docker build started----------------------->' - docker build . -t ${{ env.REGISTRY_NAME }}.azurecr.io/mytestimage:${{ github.sha }} -f /Docker/Dockerfile.Dev . + docker build . -t ${{ env.REGISTRY_NAME }}.azurecr.io/mytestimage:${{ github.sha }} -f /Docker/Dockerfile.Dev echo '<------------------------Docker build Ended------------------------>' # Docker Container Push to ACR From b4854cc5630bcf005a3b4b8b47fc188f2dcc7ed8 Mon Sep 17 00:00:00 2001 From: sai Date: Thu, 31 Aug 2023 12:48:15 +0530 Subject: [PATCH 25/94] added dockerfile path --- .github/workflows/docker-image.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index b5bec8b..161be1a 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -30,7 +30,7 @@ jobs: - name: Docker Build run: | echo '<-----------------------Docker build started----------------------->' - docker build . -t ${{ env.REGISTRY_NAME }}.azurecr.io/mytestimage:${{ github.sha }} -f /Docker/Dockerfile.Dev + docker build . -t ${{ env.REGISTRY_NAME }}.azurecr.io/mytestimage:${{ github.sha }} -f /docker/Dockerfile.Dev echo '<------------------------Docker build Ended------------------------>' # Docker Container Push to ACR From 41d608c47faac7ea972f2d5fe942f54ca18293ba Mon Sep 17 00:00:00 2001 From: sai Date: Thu, 31 Aug 2023 12:56:00 +0530 Subject: [PATCH 26/94] adding Dev --- {.github => Dev/.github}/workflows/docker-build.yml | 0 {.github => Dev/.github}/workflows/docker-image.yml | 0 {.github => Dev/.github}/workflows/main.yml | 0 .gitignore => Dev/.gitignore | 0 README.md => Dev/README.md | 0 {Docker => Dev/docker}/Dockerfile.Dev | 0 requirements.txt => Dev/requirements.txt | 0 {src => Dev/src}/app.py | 0 {tests => Dev/tests}/test_app.py | 0 9 files changed, 0 insertions(+), 0 deletions(-) rename {.github => Dev/.github}/workflows/docker-build.yml (100%) rename {.github => Dev/.github}/workflows/docker-image.yml (100%) rename {.github => Dev/.github}/workflows/main.yml (100%) rename .gitignore => Dev/.gitignore (100%) rename README.md => Dev/README.md (100%) rename {Docker => Dev/docker}/Dockerfile.Dev (100%) rename requirements.txt => Dev/requirements.txt (100%) rename {src => Dev/src}/app.py (100%) rename {tests => Dev/tests}/test_app.py (100%) diff --git a/.github/workflows/docker-build.yml b/Dev/.github/workflows/docker-build.yml similarity index 100% rename from .github/workflows/docker-build.yml rename to Dev/.github/workflows/docker-build.yml diff --git a/.github/workflows/docker-image.yml b/Dev/.github/workflows/docker-image.yml similarity index 100% rename from .github/workflows/docker-image.yml rename to Dev/.github/workflows/docker-image.yml diff --git a/.github/workflows/main.yml b/Dev/.github/workflows/main.yml similarity index 100% rename from .github/workflows/main.yml rename to Dev/.github/workflows/main.yml diff --git a/.gitignore b/Dev/.gitignore similarity index 100% rename from .gitignore rename to Dev/.gitignore diff --git a/README.md b/Dev/README.md similarity index 100% rename from README.md rename to Dev/README.md diff --git a/Docker/Dockerfile.Dev b/Dev/docker/Dockerfile.Dev similarity index 100% rename from Docker/Dockerfile.Dev rename to Dev/docker/Dockerfile.Dev diff --git a/requirements.txt b/Dev/requirements.txt similarity index 100% rename from requirements.txt rename to Dev/requirements.txt diff --git a/src/app.py b/Dev/src/app.py similarity index 100% rename from src/app.py rename to Dev/src/app.py diff --git a/tests/test_app.py b/Dev/tests/test_app.py similarity index 100% rename from tests/test_app.py rename to Dev/tests/test_app.py From cdcb2792edeff4d8b4a7409ee3f79a2f40602789 Mon Sep 17 00:00:00 2001 From: sai Date: Thu, 31 Aug 2023 13:22:35 +0530 Subject: [PATCH 27/94] chnaged pattern dir --- .../workflows/docker-build.yml | 0 .../workflows/docker-image.yml | 0 {Dev/.github => .github}/workflows/main.yml | 0 Dev/.gitignore => .gitignore | 0 Dev/docker/Dockerfile.Dev => Dockerfile | 0 Dev/README.md => README.md | 0 docker/Dockerfile.Dev | 22 +++++++++++++++++++ Dev/requirements.txt => requirements.txt | 0 {Dev/src => src}/app.py | 0 {Dev/tests => tests}/test_app.py | 0 10 files changed, 22 insertions(+) rename {Dev/.github => .github}/workflows/docker-build.yml (100%) rename {Dev/.github => .github}/workflows/docker-image.yml (100%) rename {Dev/.github => .github}/workflows/main.yml (100%) rename Dev/.gitignore => .gitignore (100%) rename Dev/docker/Dockerfile.Dev => Dockerfile (100%) rename Dev/README.md => README.md (100%) create mode 100644 docker/Dockerfile.Dev rename Dev/requirements.txt => requirements.txt (100%) rename {Dev/src => src}/app.py (100%) rename {Dev/tests => tests}/test_app.py (100%) diff --git a/Dev/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml similarity index 100% rename from Dev/.github/workflows/docker-build.yml rename to .github/workflows/docker-build.yml diff --git a/Dev/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml similarity index 100% rename from Dev/.github/workflows/docker-image.yml rename to .github/workflows/docker-image.yml diff --git a/Dev/.github/workflows/main.yml b/.github/workflows/main.yml similarity index 100% rename from Dev/.github/workflows/main.yml rename to .github/workflows/main.yml diff --git a/Dev/.gitignore b/.gitignore similarity index 100% rename from Dev/.gitignore rename to .gitignore diff --git a/Dev/docker/Dockerfile.Dev b/Dockerfile similarity index 100% rename from Dev/docker/Dockerfile.Dev rename to Dockerfile diff --git a/Dev/README.md b/README.md similarity index 100% rename from Dev/README.md rename to README.md diff --git a/docker/Dockerfile.Dev b/docker/Dockerfile.Dev new file mode 100644 index 0000000..625d922 --- /dev/null +++ b/docker/Dockerfile.Dev @@ -0,0 +1,22 @@ +#This is the base image for this Dockerfile +FROM python:3-alpine3.15 + +LABEL BuildBy="Dinkar Gedela" +LABEL BuilderEmail="dgedela@archinsurance.com" + +#Set the working directory in the container +WORKDIR /app +COPY . /app + +#Copy the requirements file into the container +COPY requirements.txt . + +#install the dependencies from requirements.txt +RUN pip install -r requirements.txt + +#Open the port on which Flask app will run +EXPOSE 8080 + +#commands to run the Flask app +ENTRYPOINT [ "python" ] +CMD [ "/src/app.py" ] \ No newline at end of file diff --git a/Dev/requirements.txt b/requirements.txt similarity index 100% rename from Dev/requirements.txt rename to requirements.txt diff --git a/Dev/src/app.py b/src/app.py similarity index 100% rename from Dev/src/app.py rename to src/app.py diff --git a/Dev/tests/test_app.py b/tests/test_app.py similarity index 100% rename from Dev/tests/test_app.py rename to tests/test_app.py From 387be9a67e25811ef192a6a3a9f5cfe8094bc1d9 Mon Sep 17 00:00:00 2001 From: sai Date: Thu, 31 Aug 2023 13:27:57 +0530 Subject: [PATCH 28/94] docker testing --- .github/workflows/docker-image.yml | 2 +- Dockerfile | 22 ---------------------- aa | 22 ++++++++++++++++++++++ 3 files changed, 23 insertions(+), 23 deletions(-) delete mode 100644 Dockerfile create mode 100644 aa diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 161be1a..41999ff 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -30,7 +30,7 @@ jobs: - name: Docker Build run: | echo '<-----------------------Docker build started----------------------->' - docker build . -t ${{ env.REGISTRY_NAME }}.azurecr.io/mytestimage:${{ github.sha }} -f /docker/Dockerfile.Dev + docker build -t ${{ env.REGISTRY_NAME }}.azurecr.io/mytestimage:${{ github.sha }} -f /docker/Dockerfile.Dev . echo '<------------------------Docker build Ended------------------------>' # Docker Container Push to ACR diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 625d922..0000000 --- a/Dockerfile +++ /dev/null @@ -1,22 +0,0 @@ -#This is the base image for this Dockerfile -FROM python:3-alpine3.15 - -LABEL BuildBy="Dinkar Gedela" -LABEL BuilderEmail="dgedela@archinsurance.com" - -#Set the working directory in the container -WORKDIR /app -COPY . /app - -#Copy the requirements file into the container -COPY requirements.txt . - -#install the dependencies from requirements.txt -RUN pip install -r requirements.txt - -#Open the port on which Flask app will run -EXPOSE 8080 - -#commands to run the Flask app -ENTRYPOINT [ "python" ] -CMD [ "/src/app.py" ] \ No newline at end of file diff --git a/aa b/aa new file mode 100644 index 0000000..1950e68 --- /dev/null +++ b/aa @@ -0,0 +1,22 @@ +# #This is the base image for this Dockerfile +# FROM python:3-alpine3.15 + +# LABEL BuildBy="Dinkar Gedela" +# LABEL BuilderEmail="dgedela@archinsurance.com" + +# #Set the working directory in the container +# WORKDIR /app +# COPY . /app + +# #Copy the requirements file into the container +# COPY requirements.txt . + +# #install the dependencies from requirements.txt +# RUN pip install -r requirements.txt + +# #Open the port on which Flask app will run +# EXPOSE 8080 + +# #commands to run the Flask app +# ENTRYPOINT [ "python" ] +# CMD [ "/src/app.py" ] \ No newline at end of file From 729a5155309f53fbbeb587ffc8d52a273f7870ae Mon Sep 17 00:00:00 2001 From: sai Date: Thu, 31 Aug 2023 13:50:49 +0530 Subject: [PATCH 29/94] docker build --- .github/workflows/docker-image.yml | 2 +- aa | 22 ---------------------- 2 files changed, 1 insertion(+), 23 deletions(-) delete mode 100644 aa diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 41999ff..0452ab9 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -30,7 +30,7 @@ jobs: - name: Docker Build run: | echo '<-----------------------Docker build started----------------------->' - docker build -t ${{ env.REGISTRY_NAME }}.azurecr.io/mytestimage:${{ github.sha }} -f /docker/Dockerfile.Dev . + docker build . -t ${{ env.REGISTRY_NAME }}.azurecr.io/mytestimage:${{ github.sha }} echo '<------------------------Docker build Ended------------------------>' # Docker Container Push to ACR diff --git a/aa b/aa deleted file mode 100644 index 1950e68..0000000 --- a/aa +++ /dev/null @@ -1,22 +0,0 @@ -# #This is the base image for this Dockerfile -# FROM python:3-alpine3.15 - -# LABEL BuildBy="Dinkar Gedela" -# LABEL BuilderEmail="dgedela@archinsurance.com" - -# #Set the working directory in the container -# WORKDIR /app -# COPY . /app - -# #Copy the requirements file into the container -# COPY requirements.txt . - -# #install the dependencies from requirements.txt -# RUN pip install -r requirements.txt - -# #Open the port on which Flask app will run -# EXPOSE 8080 - -# #commands to run the Flask app -# ENTRYPOINT [ "python" ] -# CMD [ "/src/app.py" ] \ No newline at end of file From 22341a8c06d13f7ad776f0880523fc76a5622c41 Mon Sep 17 00:00:00 2001 From: sai Date: Thu, 31 Aug 2023 13:51:58 +0530 Subject: [PATCH 30/94] docker build --- Dockerfile | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..625d922 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,22 @@ +#This is the base image for this Dockerfile +FROM python:3-alpine3.15 + +LABEL BuildBy="Dinkar Gedela" +LABEL BuilderEmail="dgedela@archinsurance.com" + +#Set the working directory in the container +WORKDIR /app +COPY . /app + +#Copy the requirements file into the container +COPY requirements.txt . + +#install the dependencies from requirements.txt +RUN pip install -r requirements.txt + +#Open the port on which Flask app will run +EXPOSE 8080 + +#commands to run the Flask app +ENTRYPOINT [ "python" ] +CMD [ "/src/app.py" ] \ No newline at end of file From 8c9e802bac94a77def8c467be13119498b09bde1 Mon Sep 17 00:00:00 2001 From: sai Date: Thu, 31 Aug 2023 15:35:11 +0530 Subject: [PATCH 31/94] deploying on AKS --- .github/workflows/docker-image.yml | 45 +++++++++++++++++++++++++++--- Kubernetes/deploy.yml | 24 ++++++++++++++++ Kubernetes/ingress.yml | 18 ++++++++++++ Kubernetes/service.yml | 11 ++++++++ 4 files changed, 94 insertions(+), 4 deletions(-) create mode 100644 Kubernetes/deploy.yml create mode 100644 Kubernetes/ingress.yml create mode 100644 Kubernetes/service.yml diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 0452ab9..692950f 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -7,9 +7,9 @@ on: push # Below environment variables available to all jobs and steps in this workflow env: REGISTRY_NAME: sai9356 - # CLUSTER_NAME: cluster-name - # CLUSTER_RESOURCE_GROUP: cluster-resource-group - # NAMESPACE: default + CLUSTER_NAME: my-aks-cluster + CLUSTER_RESOURCE_GROUP: dinkar-rg + NAMESPACE: default jobs: build: @@ -38,4 +38,41 @@ jobs: run: | echo '<-----------------------Docker Publish started----------------------->' docker push ${{ env.REGISTRY_NAME }}.azurecr.io/mytestimage:${{ github.sha }} - echo '<------------------------Docker Publish Ended------------------------>' \ No newline at end of file + echo '<------------------------Docker Publish Ended------------------------>' + + + # Set the target Azure Kubernetes Service (AKS) cluster. + - name: Setting AKS target + uses: azure/aks-set-context@v1 + with: + creds: '${{ secrets.AZURE_CREDENTIALS }}' + cluster-name: ${{ env.CLUSTER_NAME }} + resource-group: ${{ env.CLUSTER_RESOURCE_GROUP }} + + # Create namespace if doesn't exist + - name: AKS namespace creating + run: | + kubectl create namespace ${{ env.NAMESPACE }} --dry-run -o json | kubectl apply -f - + + # Create imagepullsecret for Azure Container registry (ACR) + - name: Imagepullsecret for ACR + uses: azure/k8s-create-secret@v1 + with: + container-registry-url: ${{ env.REGISTRY_NAME }}.azurecr.io + container-registry-username: ${{ secrets.REGISTRY_USERNAME }} + container-registry-password: ${{ secrets.REGISTRY_PASSWORD }} + secret-name: ${{ env.REGISTRY_NAME }}-registry-connection + namespace: ${{ env.NAMESPACE }} + + # Deploy app to AKS + - name: Deploying on AKS + uses: azure/k8s-deploy@v1 + with: + manifests: | + kubernetes/deploy.yml + Kubernetes/service.yml + images: | + ${{ env.REGISTRY_NAME }}.azurecr.io/myimage:${{ github.sha }} + imagepullsecrets: | + ${{ env.REGISTRY_NAME }}-registry-connection + namespace: ${{ env.NAMESPACE }} diff --git a/Kubernetes/deploy.yml b/Kubernetes/deploy.yml new file mode 100644 index 0000000..38d72aa --- /dev/null +++ b/Kubernetes/deploy.yml @@ -0,0 +1,24 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: python-app-deployment +spec: + replicas: 1 + selector: + matchLabels: + app: python-app + template: + metadata: + labels: + app: python-app + spec: + containers: + - name: python-app + image: myacrimg.azurecr.io + imagePullPolicy: Always + resources: + limits: + memory: "128Mi" + cpu: "500m" + ports: + - containerPort: 80 \ No newline at end of file diff --git a/Kubernetes/ingress.yml b/Kubernetes/ingress.yml new file mode 100644 index 0000000..1e44271 --- /dev/null +++ b/Kubernetes/ingress.yml @@ -0,0 +1,18 @@ +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: python-app + labels: + name: python-app +spec: + rules: + - host: + http: + paths: + - pathType: Prefix + path: "/" + backend: + service: + name: python-app + port: + number: 80 \ No newline at end of file diff --git a/Kubernetes/service.yml b/Kubernetes/service.yml new file mode 100644 index 0000000..f573455 --- /dev/null +++ b/Kubernetes/service.yml @@ -0,0 +1,11 @@ +apiVersion: v1 +kind: Service +metadata: + name: python-app-svc +spec: + selector: + app: python-app + type: NodePort + ports: + - port: 8080 + targetPort: 80 \ No newline at end of file From 8429164464c7eff8798a74a9bd76f85362485038 Mon Sep 17 00:00:00 2001 From: sai Date: Fri, 1 Sep 2023 16:54:24 +0530 Subject: [PATCH 32/94] added main.yml --- .github/workflows/main.yml | 71 ++++++++++++++++++++++++++------------ 1 file changed, 49 insertions(+), 22 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 0033222..91981de 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,9 +1,16 @@ -name: Python application +#this pipeline is for python API on Azure Kubernetes Services -on: workflow_call +name: Build CI -permissions: - contents: read +on: push + +# Below environment variables available to all jobs and steps in this workflow +env: + REGISTRY_NAME: sai9356 + CONTAINER_NAME: my-container + CLUSTER_NAME: my-aks-cluster + CLUSTER_RESOURCE_GROUP: dinkar-rg + NAMESPACE: default jobs: build: @@ -11,24 +18,44 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - name: Set up Python 3.10 - uses: actions/setup-python@v3 + - name: Checkout code + uses: actions/checkout@master + + # Connecting to Azure Container registry (ACR) + - name: ACR Login + uses: azure/docker-login@v1 with: - python-version: "3.10" - - name: Install dependencies + login-server: ${{ env.REGISTRY_NAME }}.azurecr.io + username: ${{ secrets.REGISTRY_USERNAME }} + password: ${{ secrets.REGISTRY_PASSWORD }} + + # Docker container build + - name: Docker Build run: | - python -m pip install --upgrade pip - pip install flake8 pytest - if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - - name: Lint with flake8 + echo '<-----------------------Docker build started----------------------->' + docker build . -t ${{ env.REGISTRY_NAME }}.azurecr.io/${{env.CONTAINER_NAME}}:${{ github.sha }} + echo '<------------------------Docker build Ended------------------------>' + + # Docker Container Push to ACR + - name: Docker Push run: | - # stop the build if there are Python syntax errors or undefined names - flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics - # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide - flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics - - name: Test with pytest - run: | - pip install pytest - export PYTHONPATH=src - pytest + echo '<-----------------------Docker Publish started----------------------->' + docker push ${{ env.REGISTRY_NAME }}.azurecr.io/${{env.CONTAINER_NAME}}:${{ github.sha }} + echo '<------------------------Docker Publish Ended------------------------>' + + Deploy: + + runs-on: ubuntu-latest + + needs: [build] + steps: + # Checks out the repository this file is in + - uses: actions/checkout@v3 + + # Logs in with your Azure credentials + - name: Azure login + uses: azure/login@v1.4.6 + with: + client-id: ${{ secrets.AZURE_CLIENT_ID }} + tenant-id: ${{ secrets.AZURE_TENANT_ID }} + subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} \ No newline at end of file From 33f958cc7aba90a439dd2733fe2d08a7ea489cf6 Mon Sep 17 00:00:00 2001 From: sai Date: Fri, 1 Sep 2023 18:10:47 +0530 Subject: [PATCH 33/94] added files --- .github/workflows/docker-build.yml | 60 ------------------------------ .github/workflows/docker-image.yml | 2 +- 2 files changed, 1 insertion(+), 61 deletions(-) delete mode 100644 .github/workflows/docker-build.yml diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml deleted file mode 100644 index db2df8b..0000000 --- a/.github/workflows/docker-build.yml +++ /dev/null @@ -1,60 +0,0 @@ -name: Docker Build - -on: workflow_call - -# Environment variables available to all jobs and steps in this workflow -env: - REGISTRY_NAME: gdinkar - CLUSTER_NAME: myaks - CLUSTER_RESOURCE_GROUP: github_actions - NAMESPACE: default - -jobs: - build: - runs-on: ubuntu-latest - #environment: dev - steps: - - uses: actions/checkout@master - - # Connect to Azure Container registry (ACR) - - uses: azure/docker-login@v1 - with: - login-server: ${{ env.REGISTRY_NAME }}.azurecr.io - username: ${{ secrets.REGISTRY_USERNAME }} - password: ${{ secrets.REGISTRY_PASSWORD }} - - # Container build and push to a Azure Container registry (ACR) - - run: | - docker build . -t ${{ env.REGISTRY_NAME }}.azurecr.io/mytestimage:${{ github.sha }} - docker push ${{ env.REGISTRY_NAME }}.azurecr.io/mytestimage:${{ github.sha }} - # Set the target Azure Kubernetes Service (AKS) cluster. - - uses: azure/aks-set-context@v1 - with: - creds: '${{ secrets.AZURE_CREDENTIALS }}' - cluster-name: ${{ env.CLUSTER_NAME }} - resource-group: ${{ env.CLUSTER_RESOURCE_GROUP }} - - # Create namespace if doesn't exist - - run: | - kubectl create namespace ${{ env.NAMESPACE }} --dry-run -o json | kubectl apply -f - - - # Create imagepullsecret for Azure Container registry (ACR) - - uses: azure/k8s-create-secret@v1 - with: - container-registry-url: ${{ env.REGISTRY_NAME }}.azurecr.io - container-registry-username: ${{ secrets.REGISTRY_USERNAME }} - container-registry-password: ${{ secrets.REGISTRY_PASSWORD }} - secret-name: ${{ env.REGISTRY_NAME }}-registry-connection - namespace: ${{ env.NAMESPACE }} - - # Deploy app to AKS - - uses: azure/k8s-deploy@v1 - with: - manifests: | - manifests/deployment.yml - manifests/service.yml - images: | - ${{ env.REGISTRY_NAME }}.azurecr.io/myimage:${{ github.sha }} - imagepullsecrets: | - ${{ env.REGISTRY_NAME }}-registry-connection - namespace: ${{ env.NAMESPACE }} \ No newline at end of file diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 692950f..f21cf4b 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -2,7 +2,7 @@ name: Build CI -on: push +on: workflow_dispatch # Below environment variables available to all jobs and steps in this workflow env: From a82220fef3315067a4e4bd111ea5b857631a4f9f Mon Sep 17 00:00:00 2001 From: sai Date: Sun, 3 Sep 2023 10:51:14 +0530 Subject: [PATCH 34/94] added AKS deploy --- .github/workflows/docker-image.yml | 49 ++++++------------------------ 1 file changed, 10 insertions(+), 39 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index f21cf4b..84cc1fc 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -7,6 +7,7 @@ on: workflow_dispatch # Below environment variables available to all jobs and steps in this workflow env: REGISTRY_NAME: sai9356 + CONTAINER_NAME: test-image CLUSTER_NAME: my-aks-cluster CLUSTER_RESOURCE_GROUP: dinkar-rg NAMESPACE: default @@ -30,49 +31,19 @@ jobs: - name: Docker Build run: | echo '<-----------------------Docker build started----------------------->' - docker build . -t ${{ env.REGISTRY_NAME }}.azurecr.io/mytestimage:${{ github.sha }} + docker build . -t ${{ env.REGISTRY_NAME }}.jfrog.io/${{env.CONTAINER_NAME}}:${{ github.sha }} echo '<------------------------Docker build Ended------------------------>' - + + - name: Docker Login + run: | + echo '<--------------- Docker Login --------------->' + docker login valaxy01.jfrog.io -u ${{ secrets.ARTIFACTORY_USERNAME }} -p ${{ secrets.ARTIFACTORY_PASSWORD }} + echo '<--------------- Docker Login Ended --------------->' + # Docker Container Push to ACR - name: Docker Push run: | echo '<-----------------------Docker Publish started----------------------->' - docker push ${{ env.REGISTRY_NAME }}.azurecr.io/mytestimage:${{ github.sha }} + docker push ${{ env.REGISTRY_NAME }}.jfrog.io/${{env.CONTAINER_NAME}}:${{ github.sha }} echo '<------------------------Docker Publish Ended------------------------>' - - - # Set the target Azure Kubernetes Service (AKS) cluster. - - name: Setting AKS target - uses: azure/aks-set-context@v1 - with: - creds: '${{ secrets.AZURE_CREDENTIALS }}' - cluster-name: ${{ env.CLUSTER_NAME }} - resource-group: ${{ env.CLUSTER_RESOURCE_GROUP }} - - # Create namespace if doesn't exist - - name: AKS namespace creating - run: | - kubectl create namespace ${{ env.NAMESPACE }} --dry-run -o json | kubectl apply -f - - - # Create imagepullsecret for Azure Container registry (ACR) - - name: Imagepullsecret for ACR - uses: azure/k8s-create-secret@v1 - with: - container-registry-url: ${{ env.REGISTRY_NAME }}.azurecr.io - container-registry-username: ${{ secrets.REGISTRY_USERNAME }} - container-registry-password: ${{ secrets.REGISTRY_PASSWORD }} - secret-name: ${{ env.REGISTRY_NAME }}-registry-connection - namespace: ${{ env.NAMESPACE }} - # Deploy app to AKS - - name: Deploying on AKS - uses: azure/k8s-deploy@v1 - with: - manifests: | - kubernetes/deploy.yml - Kubernetes/service.yml - images: | - ${{ env.REGISTRY_NAME }}.azurecr.io/myimage:${{ github.sha }} - imagepullsecrets: | - ${{ env.REGISTRY_NAME }}-registry-connection - namespace: ${{ env.NAMESPACE }} From 9d2018c0c866eff0e99ad8531c70cdfc67e401a2 Mon Sep 17 00:00:00 2001 From: sai Date: Sun, 3 Sep 2023 10:55:45 +0530 Subject: [PATCH 35/94] added env --- .github/workflows/main.yml | 51 +++++++++++++++++++++++++++++++++----- 1 file changed, 45 insertions(+), 6 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 91981de..20ec219 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,15 +1,23 @@ #this pipeline is for python API on Azure Kubernetes Services -name: Build CI +# Set the following environment variables (or replace the values below): +# - AZURE_CONTAINER_REGISTRY (name of your container registry / ACR) +# - RESOURCE_GROUP (where your cluster is deployed) +# - CLUSTER_NAME (name of your AKS cluster) +# - CONTAINER_NAME (name of the container image you would like to push up to your ACR) + + +name: Python Flask on Kubernetes on: push # Below environment variables available to all jobs and steps in this workflow env: - REGISTRY_NAME: sai9356 + REGISTRY_NAME: myacr108 CONTAINER_NAME: my-container - CLUSTER_NAME: my-aks-cluster - CLUSTER_RESOURCE_GROUP: dinkar-rg + RESOURCE_GROUP: sai-arch + CLUSTER_NAME: my-aks + CLUSTER_RESOURCE_GROUP: sai-arch NAMESPACE: default jobs: @@ -47,7 +55,9 @@ jobs: runs-on: ubuntu-latest - needs: [build] + # Delpoy job won't run until build job is completed + needs: [build] + steps: # Checks out the repository this file is in - uses: actions/checkout@v3 @@ -58,4 +68,33 @@ jobs: with: client-id: ${{ secrets.AZURE_CLIENT_ID }} tenant-id: ${{ secrets.AZURE_TENANT_ID }} - subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} \ No newline at end of file + subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} + + # Use kubelogin to configure your kubeconfig for Azure auth + - name: Set up kubelogin for non-interactive login + uses: azure/use-kubelogin@v1 + with: + kubelogin-version: 'v0.0.25' + + # Retrieves our Azure Kubernetes Service cluster's kubeconfig file + - name: Get K8s context + uses: azure/aks-set-context@v3 + with: + resource-group: ${{ env.RESOURCE_GROUP }} + cluster-name: ${{ env.CLUSTER_NAME }} + admin: 'false' + use-kubelogin: 'true' + + # Deploys application based on given manifest file + - name: Deploys application + uses: Azure/k8s-deploy@v4 + with: + action: deploy + # Path to the manifest files which will be used for deployment. + manifests: | + kubernetes/deploy.yml + Kubernetes/service.yml + # Name of a docker-registry secret that has already been set up within the cluster. Each of these secret names are added under imagePullSecrets field for the workloads found in the input manifest files + images: | + ${{ env.REGISTRY_NAME }}.azurecr.io/${{ env.CONTAINER_NAME }}:${{ github.sha }} + From 7d2d07f6443b858da3ee80b8d18f44a2347613f2 Mon Sep 17 00:00:00 2001 From: sai Date: Sun, 3 Sep 2023 11:02:41 +0530 Subject: [PATCH 36/94] added deploy permissions --- .github/workflows/main.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 20ec219..92d9253 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -52,6 +52,10 @@ jobs: echo '<------------------------Docker Publish Ended------------------------>' Deploy: + permissions: + actions: read + contents: read + id-token: write runs-on: ubuntu-latest From 69d10d8b4770c701673d2bee0547ed788bcb0ece Mon Sep 17 00:00:00 2001 From: sai Date: Sun, 3 Sep 2023 12:20:18 +0530 Subject: [PATCH 37/94] check aks yml --- .github/workflows/aks.yml | 65 ++++++++++++++++++++++++++++++++++++++ .github/workflows/main.yml | 2 +- 2 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/aks.yml diff --git a/.github/workflows/aks.yml b/.github/workflows/aks.yml new file mode 100644 index 0000000..0c7577e --- /dev/null +++ b/.github/workflows/aks.yml @@ -0,0 +1,65 @@ +name: main +"on": + push: + branches: + - feature + workflow_dispatch: {} +env: + ACR_RESOURCE_GROUP: sai-arch + AZURE_CONTAINER_REGISTRY: myacr108 + CLUSTER_NAME: my_aks + CLUSTER_RESOURCE_GROUP: sai-arch + CONTAINER_NAME: my-container + 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-1693722624174 \ No newline at end of file diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 92d9253..5ec85d7 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -9,7 +9,7 @@ name: Python Flask on Kubernetes -on: push +on: workflow_dispatch # Below environment variables available to all jobs and steps in this workflow env: From 5ddfe9fdb71201359d0a602a3f58a89a3ec4f523 Mon Sep 17 00:00:00 2001 From: sai Date: Sun, 3 Sep 2023 13:09:05 +0530 Subject: [PATCH 38/94] updated main yml --- .github/workflows/aks.yml | 6 +---- .github/workflows/main.yml | 55 +++++++++++++++++++++++++------------- 2 files changed, 37 insertions(+), 24 deletions(-) diff --git a/.github/workflows/aks.yml b/.github/workflows/aks.yml index 0c7577e..9dd5856 100644 --- a/.github/workflows/aks.yml +++ b/.github/workflows/aks.yml @@ -1,9 +1,5 @@ name: main -"on": - push: - branches: - - feature - workflow_dispatch: {} +on: workflow_dispatch env: ACR_RESOURCE_GROUP: sai-arch AZURE_CONTAINER_REGISTRY: myacr108 diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5ec85d7..2fa90f2 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -9,7 +9,7 @@ name: Python Flask on Kubernetes -on: workflow_dispatch +on: push # Below environment variables available to all jobs and steps in this workflow env: @@ -66,28 +66,45 @@ jobs: # Checks out the repository this file is in - uses: actions/checkout@v3 - # Logs in with your Azure credentials - - name: Azure login - uses: azure/login@v1.4.6 - with: - client-id: ${{ secrets.AZURE_CLIENT_ID }} - tenant-id: ${{ secrets.AZURE_TENANT_ID }} - subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} + # # Logs in with your Azure credentials + # - name: Azure login + # uses: azure/login@v1.4.6 + # with: + # client-id: ${{ secrets.AZURE_CLIENT_ID }} + # tenant-id: ${{ secrets.AZURE_TENANT_ID }} + # subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} - # Use kubelogin to configure your kubeconfig for Azure auth - - name: Set up kubelogin for non-interactive login - uses: azure/use-kubelogin@v1 - with: - kubelogin-version: 'v0.0.25' + # # Use kubelogin to configure your kubeconfig for Azure auth + # - name: Set up kubelogin for non-interactive login + # uses: azure/use-kubelogin@v1 + # with: + # kubelogin-version: 'v0.0.25' # Retrieves our Azure Kubernetes Service cluster's kubeconfig file - - name: Get K8s context - uses: azure/aks-set-context@v3 + - name: Azure Kubernetes set context + uses: Azure/aks-set-context@v1 + with: + # Azure credentials i.e. output of `az ad sp create-for-rbac --sdk-auth` + creds: '${{secrets.AZURE_CREDENTIALS}}' + # Resource Group Name + resource-group: sai-arch + # AKS Cluster Name + cluster-name: mk_aks + + # Create K8s secrets to pull images + - name: Create secret in Kubernetes cluster + uses: Azure/k8s-create-secret@v1.1 with: - resource-group: ${{ env.RESOURCE_GROUP }} - cluster-name: ${{ env.CLUSTER_NAME }} - admin: 'false' - use-kubelogin: 'true' + # Container registry url + container-registry-url: ${{ env.REGISTRY_NAME }}.azurecr.io + # Container registry username + container-registry-username: '${{secrets.REGISTRY_USERNAME}}' + # Container registry password + container-registry-password: '${{ secrets.REGISTRY_PASSWORD }}' + # Type of Kubernetes secret. For example, docker-registry or generic + secret-type: acr + # Name of the secret. You can use this secret name in the Kubernetes YAML configuration file. + secret-name: docker-image-pull-secret # Deploys application based on given manifest file - name: Deploys application From acf535cbe7fd0278cb86128399bf21458de11eec Mon Sep 17 00:00:00 2001 From: sai Date: Sun, 3 Sep 2023 13:14:57 +0530 Subject: [PATCH 39/94] updated main yml 1 --- .github/workflows/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 2fa90f2..f0ac988 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -87,9 +87,9 @@ jobs: # Azure credentials i.e. output of `az ad sp create-for-rbac --sdk-auth` creds: '${{secrets.AZURE_CREDENTIALS}}' # Resource Group Name - resource-group: sai-arch + resource-group: '${{ env.CLUSTER_RESOURCE_GROUP }}' # AKS Cluster Name - cluster-name: mk_aks + cluster-name: '${{ env.CLUSTER_NAME }}' # Create K8s secrets to pull images - name: Create secret in Kubernetes cluster From 8fe8be171ab5a807da695604aa6084e160d7b2fc Mon Sep 17 00:00:00 2001 From: sai Date: Sun, 3 Sep 2023 13:36:59 +0530 Subject: [PATCH 40/94] added azure login --- .github/workflows/main.yml | 60 +++++++------------------------------- 1 file changed, 11 insertions(+), 49 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f0ac988..4debf9c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -66,56 +66,18 @@ jobs: # Checks out the repository this file is in - uses: actions/checkout@v3 - # # Logs in with your Azure credentials - # - name: Azure login - # uses: azure/login@v1.4.6 - # with: - # client-id: ${{ secrets.AZURE_CLIENT_ID }} - # tenant-id: ${{ secrets.AZURE_TENANT_ID }} - # subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} - - # # Use kubelogin to configure your kubeconfig for Azure auth - # - name: Set up kubelogin for non-interactive login - # uses: azure/use-kubelogin@v1 - # with: - # kubelogin-version: 'v0.0.25' - - # Retrieves our Azure Kubernetes Service cluster's kubeconfig file - - name: Azure Kubernetes set context - uses: Azure/aks-set-context@v1 + # Logs in with your Azure credentials + - name: Azure login + uses: azure/login@v1.4.6 with: - # Azure credentials i.e. output of `az ad sp create-for-rbac --sdk-auth` - creds: '${{secrets.AZURE_CREDENTIALS}}' - # Resource Group Name - resource-group: '${{ env.CLUSTER_RESOURCE_GROUP }}' - # AKS Cluster Name - cluster-name: '${{ env.CLUSTER_NAME }}' + client-id: ${{ secrets.AZURE_CLIENT_ID }} + tenant-id: ${{ secrets.AZURE_TENANT_ID }} + subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} - # Create K8s secrets to pull images - - name: Create secret in Kubernetes cluster - uses: Azure/k8s-create-secret@v1.1 - with: - # Container registry url - container-registry-url: ${{ env.REGISTRY_NAME }}.azurecr.io - # Container registry username - container-registry-username: '${{secrets.REGISTRY_USERNAME}}' - # Container registry password - container-registry-password: '${{ secrets.REGISTRY_PASSWORD }}' - # Type of Kubernetes secret. For example, docker-registry or generic - secret-type: acr - # Name of the secret. You can use this secret name in the Kubernetes YAML configuration file. - secret-name: docker-image-pull-secret - - # Deploys application based on given manifest file - - name: Deploys application - uses: Azure/k8s-deploy@v4 + # Use kubelogin to configure your kubeconfig for Azure auth + - name: Set up kubelogin for non-interactive login + uses: azure/use-kubelogin@v1 with: - action: deploy - # Path to the manifest files which will be used for deployment. - manifests: | - kubernetes/deploy.yml - Kubernetes/service.yml - # Name of a docker-registry secret that has already been set up within the cluster. Each of these secret names are added under imagePullSecrets field for the workloads found in the input manifest files - images: | - ${{ env.REGISTRY_NAME }}.azurecr.io/${{ env.CONTAINER_NAME }}:${{ github.sha }} + kubelogin-version: 'v0.0.25' + \ No newline at end of file From 8ec372db56da6b606807a70b5c88f1b66bbac945 Mon Sep 17 00:00:00 2001 From: sai Date: Sun, 3 Sep 2023 17:00:33 +0530 Subject: [PATCH 41/94] added azure login --- .github/workflows/main.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 4debf9c..718f6f8 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -74,10 +74,6 @@ jobs: tenant-id: ${{ secrets.AZURE_TENANT_ID }} subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} - # Use kubelogin to configure your kubeconfig for Azure auth - - name: Set up kubelogin for non-interactive login - uses: azure/use-kubelogin@v1 - with: - kubelogin-version: 'v0.0.25' + \ No newline at end of file From 692934e7c37d13397c8fc63be5d0d178adaa8227 Mon Sep 17 00:00:00 2001 From: sai Date: Sun, 3 Sep 2023 17:04:38 +0530 Subject: [PATCH 42/94] set azure context --- .github/workflows/main.yml | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 718f6f8..442cc0c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -66,13 +66,23 @@ jobs: # Checks out the repository this file is in - uses: actions/checkout@v3 - # Logs in with your Azure credentials - - name: Azure login - uses: azure/login@v1.4.6 + # # Logs in with your Azure credentials + # - name: Azure login + # uses: azure/login@v1.4.6 + # with: + # client-id: ${{ secrets.AZURE_CLIENT_ID }} + # tenant-id: ${{ secrets.AZURE_TENANT_ID }} + # subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} + + - name: Azure Kubernetes set context + uses: Azure/aks-set-context@v1 with: - client-id: ${{ secrets.AZURE_CLIENT_ID }} - tenant-id: ${{ secrets.AZURE_TENANT_ID }} - subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} + # Azure credentials i.e. output of `az ad sp create-for-rbac --sdk-auth` + creds: '${{secrets.AZURE_CREDENTIALS}}' + # Resource Group Name + resource-group: sai-arch + # AKS Cluster Name + cluster-name: my_aks From 9863d855c2ff098759c3f6b7b88b247d3df85721 Mon Sep 17 00:00:00 2001 From: sai Date: Sun, 3 Sep 2023 17:27:35 +0530 Subject: [PATCH 43/94] set kubelogin and k8s secret --- .github/workflows/main.yml | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 442cc0c..df57980 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -80,9 +80,31 @@ jobs: # Azure credentials i.e. output of `az ad sp create-for-rbac --sdk-auth` creds: '${{secrets.AZURE_CREDENTIALS}}' # Resource Group Name - resource-group: sai-arch + resource-group: ${{ env.RESOURCE_GROUP }} # AKS Cluster Name - cluster-name: my_aks + cluster-name: ${{ env.CLUSTER_NAME }} + + + # Use kubelogin to configure your kubeconfig for Azure auth + - name: Set up kubelogin for non-interactive login + uses: azure/use-kubelogin@v1 + with: + kubelogin-version: 'v0.0.25' + + # Create K8s secrets to pull images + - name: Create secret in Kubernetes cluster + uses: Azure/k8s-create-secret@v1.1 + with: + # Container registry url + container-registry-url: https://${{ env.REGISTRY_NAME }}.azurecr.io/${{env.CONTAINER_NAME}} + # Container registry username + container-registry-username: '${{ secrets.REGISTRY_USERNAME }}' + # Container registry password + container-registry-password: '${{ secrets.REGISTRY_PASSWORD }}' + # Type of Kubernetes secret. For example, docker-registry or generic + secret-type: acr-registry + # Name of the secret. You can use this secret name in the Kubernetes YAML configuration file. + secret-name: acr-image-pull-secret From a79b39af48afeb3fc0a3e1ab8d6284d58beb7266 Mon Sep 17 00:00:00 2001 From: sai Date: Sun, 3 Sep 2023 17:31:22 +0530 Subject: [PATCH 44/94] changed the aks env name --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index df57980..9ac844e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -16,7 +16,7 @@ env: REGISTRY_NAME: myacr108 CONTAINER_NAME: my-container RESOURCE_GROUP: sai-arch - CLUSTER_NAME: my-aks + CLUSTER_NAME: my_aks CLUSTER_RESOURCE_GROUP: sai-arch NAMESPACE: default From b2b4281767f1a2bd62db94dcf47cde72f101e999 Mon Sep 17 00:00:00 2001 From: sai Date: Sun, 3 Sep 2023 17:40:44 +0530 Subject: [PATCH 45/94] changed secret type --- .github/workflows/main.yml | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 9ac844e..53a51dd 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -9,7 +9,7 @@ name: Python Flask on Kubernetes -on: push +on: workflow_dispatch # Below environment variables available to all jobs and steps in this workflow env: @@ -95,17 +95,14 @@ jobs: - name: Create secret in Kubernetes cluster uses: Azure/k8s-create-secret@v1.1 with: - # Container registry url + # Container registry URL container-registry-url: https://${{ env.REGISTRY_NAME }}.azurecr.io/${{env.CONTAINER_NAME}} # Container registry username container-registry-username: '${{ secrets.REGISTRY_USERNAME }}' # Container registry password container-registry-password: '${{ secrets.REGISTRY_PASSWORD }}' # Type of Kubernetes secret. For example, docker-registry or generic - secret-type: acr-registry + secret-type: docker-registry # Name of the secret. You can use this secret name in the Kubernetes YAML configuration file. secret-name: acr-image-pull-secret - - - \ No newline at end of file From 4425e1740772be7626243d6836967bf787f740fd Mon Sep 17 00:00:00 2001 From: sai Date: Sun, 3 Sep 2023 17:55:01 +0530 Subject: [PATCH 46/94] added aks deploy --- .github/workflows/main.yml | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 53a51dd..eb563a8 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -9,7 +9,7 @@ name: Python Flask on Kubernetes -on: workflow_dispatch +on: push # Below environment variables available to all jobs and steps in this workflow env: @@ -106,3 +106,17 @@ jobs: # Name of the secret. You can use this secret name in the Kubernetes YAML configuration file. secret-name: acr-image-pull-secret + # Deploy to k8s cluster + - name: Deploy to Kubernetes cluster + uses: Azure/k8s-deploy@v1 + with: + # Path to the manifest files which will be used for deployment. + manifests: | + kubernetes/deployment.yml + kubernetes/service.yml + # Fully qualified resource URL of the image(s) to be used for substitutions on the manifest files Example: contosodemo.azurecr.io/helloworld:test + images: '${{ env.REGISTRY_NAME }}.azurecr.io/${{ env.CONTAINER_NAME }}:${{ github.sha }}' + # Name of a docker-registry secret that has already been set up within the cluster. Each of these secret names are added under imagePullSecrets field for the workloads found in the input manifest files + imagepullsecrets: acr-image-pull-secret + # deploy/promote/reject + action: deploy \ No newline at end of file From 59757652287d125253a48c002df1647e20316f1b Mon Sep 17 00:00:00 2001 From: sai Date: Sun, 3 Sep 2023 17:57:20 +0530 Subject: [PATCH 47/94] added path of manifest --- .github/workflows/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index eb563a8..54941e3 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -112,8 +112,8 @@ jobs: with: # Path to the manifest files which will be used for deployment. manifests: | - kubernetes/deployment.yml - kubernetes/service.yml + Kubernetes/deploy.yml + Kubernetes/service.yml # Fully qualified resource URL of the image(s) to be used for substitutions on the manifest files Example: contosodemo.azurecr.io/helloworld:test images: '${{ env.REGISTRY_NAME }}.azurecr.io/${{ env.CONTAINER_NAME }}:${{ github.sha }}' # Name of a docker-registry secret that has already been set up within the cluster. Each of these secret names are added under imagePullSecrets field for the workloads found in the input manifest files From 6934c7e1fff56a43fdd339f3a26cb6e0d338c79c Mon Sep 17 00:00:00 2001 From: sai Date: Sun, 3 Sep 2023 18:45:36 +0530 Subject: [PATCH 48/94] edited deploy manifest --- .github/workflows/main.yml | 14 +++----------- Kubernetes/deploy.yml | 2 +- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 54941e3..66f55e2 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -63,16 +63,6 @@ jobs: needs: [build] steps: - # Checks out the repository this file is in - - uses: actions/checkout@v3 - - # # Logs in with your Azure credentials - # - name: Azure login - # uses: azure/login@v1.4.6 - # with: - # client-id: ${{ secrets.AZURE_CLIENT_ID }} - # tenant-id: ${{ secrets.AZURE_TENANT_ID }} - # subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} - name: Azure Kubernetes set context uses: Azure/aks-set-context@v1 @@ -109,7 +99,9 @@ jobs: # Deploy to k8s cluster - name: Deploy to Kubernetes cluster uses: Azure/k8s-deploy@v1 - with: + with: + # Choose the target Kubernetes namespace. If the namespace is not provided, the commands will run in the default namespace. + namespace: '${{ env.NAMESPACE }}' # Path to the manifest files which will be used for deployment. manifests: | Kubernetes/deploy.yml diff --git a/Kubernetes/deploy.yml b/Kubernetes/deploy.yml index 38d72aa..6d98d92 100644 --- a/Kubernetes/deploy.yml +++ b/Kubernetes/deploy.yml @@ -14,7 +14,7 @@ spec: spec: containers: - name: python-app - image: myacrimg.azurecr.io + image: myacr108.azurecr.io/my-container imagePullPolicy: Always resources: limits: From d882a61f9184061afcdf4486bca2c6d7c3c2849b Mon Sep 17 00:00:00 2001 From: sai Date: Sun, 3 Sep 2023 18:50:25 +0530 Subject: [PATCH 49/94] edited deploy manifest --- Kubernetes/deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Kubernetes/deploy.yml b/Kubernetes/deploy.yml index 6d98d92..e4433a0 100644 --- a/Kubernetes/deploy.yml +++ b/Kubernetes/deploy.yml @@ -14,7 +14,7 @@ spec: spec: containers: - name: python-app - image: myacr108.azurecr.io/my-container + image: myacr108.azurecr.io imagePullPolicy: Always resources: limits: From 7a3cd2957d38a07a35e44220b49842a070c3f3fa Mon Sep 17 00:00:00 2001 From: sai Date: Mon, 4 Sep 2023 11:36:03 +0530 Subject: [PATCH 50/94] edited deploy manifest --- .github/workflows/docker-image.yml | 25 +++++++++++++------------ Dockerfile | 2 +- docker/Dockerfile.Dev | 2 +- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 84cc1fc..a651962 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -8,9 +8,9 @@ on: workflow_dispatch env: REGISTRY_NAME: sai9356 CONTAINER_NAME: test-image - CLUSTER_NAME: my-aks-cluster - CLUSTER_RESOURCE_GROUP: dinkar-rg - NAMESPACE: default + # CLUSTER_NAME: my-aks-cluster + # CLUSTER_RESOURCE_GROUP: dinkar-rg + # NAMESPACE: default jobs: build: @@ -19,13 +19,13 @@ jobs: - name: Checkout code uses: actions/checkout@master - # Connecting to Azure Container registry (ACR) - - name: ACR Login - uses: azure/docker-login@v1 - with: - login-server: ${{ env.REGISTRY_NAME }}.azurecr.io - username: ${{ secrets.REGISTRY_USERNAME }} - password: ${{ secrets.REGISTRY_PASSWORD }} + # # Connecting to Azure Container registry (ACR) + # - name: ACR Login + # uses: azure/docker-login@v1 + # with: + # login-server: ${{ env.REGISTRY_NAME }}.jfrog.io + # username: ${{ secrets.REGISTRY_USERNAME }} + # password: ${{ secrets.REGISTRY_PASSWORD }} # Docker container build - name: Docker Build @@ -34,10 +34,11 @@ jobs: docker build . -t ${{ env.REGISTRY_NAME }}.jfrog.io/${{env.CONTAINER_NAME}}:${{ github.sha }} echo '<------------------------Docker build Ended------------------------>' + # Jfrog Artifactory Login - name: Docker Login run: | echo '<--------------- Docker Login --------------->' - docker login valaxy01.jfrog.io -u ${{ secrets.ARTIFACTORY_USERNAME }} -p ${{ secrets.ARTIFACTORY_PASSWORD }} + docker login ${{ env.REGISTRY_NAME }}.jfrog.io -u ${{ secrets.ARTIFACTORY_USERNAME }} -p ${{ secrets.ARTIFACTORY_PASSWORD }} echo '<--------------- Docker Login Ended --------------->' # Docker Container Push to ACR @@ -46,4 +47,4 @@ jobs: echo '<-----------------------Docker Publish started----------------------->' docker push ${{ env.REGISTRY_NAME }}.jfrog.io/${{env.CONTAINER_NAME}}:${{ github.sha }} echo '<------------------------Docker Publish Ended------------------------>' - + diff --git a/Dockerfile b/Dockerfile index 625d922..09992ba 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,7 @@ FROM python:3-alpine3.15 LABEL BuildBy="Dinkar Gedela" -LABEL BuilderEmail="dgedela@archinsurance.com" +LABEL BuilderEmail="dinkarsai03@gmail.com" #Set the working directory in the container WORKDIR /app diff --git a/docker/Dockerfile.Dev b/docker/Dockerfile.Dev index 625d922..09992ba 100644 --- a/docker/Dockerfile.Dev +++ b/docker/Dockerfile.Dev @@ -2,7 +2,7 @@ FROM python:3-alpine3.15 LABEL BuildBy="Dinkar Gedela" -LABEL BuilderEmail="dgedela@archinsurance.com" +LABEL BuilderEmail="dinkarsai03@gmail.com" #Set the working directory in the container WORKDIR /app From 9350aa1f52cc3058755aa8a5ee07af6bcb0fb774 Mon Sep 17 00:00:00 2001 From: sai Date: Mon, 4 Sep 2023 11:45:38 +0530 Subject: [PATCH 51/94] edited main.yml k8s --- .github/workflows/main.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 66f55e2..7ed2de1 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -99,9 +99,7 @@ jobs: # Deploy to k8s cluster - name: Deploy to Kubernetes cluster uses: Azure/k8s-deploy@v1 - with: - # Choose the target Kubernetes namespace. If the namespace is not provided, the commands will run in the default namespace. - namespace: '${{ env.NAMESPACE }}' + with: # Path to the manifest files which will be used for deployment. manifests: | Kubernetes/deploy.yml @@ -111,4 +109,5 @@ jobs: # Name of a docker-registry secret that has already been set up within the cluster. Each of these secret names are added under imagePullSecrets field for the workloads found in the input manifest files imagepullsecrets: acr-image-pull-secret # deploy/promote/reject - action: deploy \ No newline at end of file + action: deploy + \ No newline at end of file From 0e298954de7982fbf7dcfd30bbdc84dfc9a62471 Mon Sep 17 00:00:00 2001 From: sai Date: Mon, 4 Sep 2023 12:48:33 +0530 Subject: [PATCH 52/94] edited deploy path --- .github/workflows/main.yml | 2 +- Kubernetes/{deploy.yml => deployment.yml} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename Kubernetes/{deploy.yml => deployment.yml} (100%) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7ed2de1..275cc21 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -102,7 +102,7 @@ jobs: with: # Path to the manifest files which will be used for deployment. manifests: | - Kubernetes/deploy.yml + Kubernetes/deployment.yml Kubernetes/service.yml # Fully qualified resource URL of the image(s) to be used for substitutions on the manifest files Example: contosodemo.azurecr.io/helloworld:test images: '${{ env.REGISTRY_NAME }}.azurecr.io/${{ env.CONTAINER_NAME }}:${{ github.sha }}' diff --git a/Kubernetes/deploy.yml b/Kubernetes/deployment.yml similarity index 100% rename from Kubernetes/deploy.yml rename to Kubernetes/deployment.yml From 02c67ac879ac4b1867ea9e6db75bc05d453dc485 Mon Sep 17 00:00:00 2001 From: sai Date: Mon, 4 Sep 2023 13:14:54 +0530 Subject: [PATCH 53/94] edited mainfests path --- .github/workflows/main.yml | 9 +++++---- {Kubernetes => manifests}/deployment.yml | 2 +- {Kubernetes => manifests}/ingress.yml | 0 {Kubernetes => manifests}/service.yml | 0 4 files changed, 6 insertions(+), 5 deletions(-) rename {Kubernetes => manifests}/deployment.yml (89%) rename {Kubernetes => manifests}/ingress.yml (100%) rename {Kubernetes => manifests}/service.yml (100%) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 275cc21..801276b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -19,6 +19,9 @@ env: CLUSTER_NAME: my_aks CLUSTER_RESOURCE_GROUP: sai-arch NAMESPACE: default + DEPLOYMENT_MANIFEST_PATH: | + manifests/deployment.yaml + manifests/service.yaml jobs: build: @@ -101,11 +104,9 @@ jobs: uses: Azure/k8s-deploy@v1 with: # Path to the manifest files which will be used for deployment. - manifests: | - Kubernetes/deployment.yml - Kubernetes/service.yml + manifests: ${{ env.DEPLOYMENT_MANIFEST_PATH }} # Fully qualified resource URL of the image(s) to be used for substitutions on the manifest files Example: contosodemo.azurecr.io/helloworld:test - images: '${{ env.REGISTRY_NAME }}.azurecr.io/${{ env.CONTAINER_NAME }}:${{ github.sha }}' + images: ${{ env.REGISTRY_NAME }}.azurecr.io/${{ env.CONTAINER_NAME }}:${{ github.sha }} # Name of a docker-registry secret that has already been set up within the cluster. Each of these secret names are added under imagePullSecrets field for the workloads found in the input manifest files imagepullsecrets: acr-image-pull-secret # deploy/promote/reject diff --git a/Kubernetes/deployment.yml b/manifests/deployment.yml similarity index 89% rename from Kubernetes/deployment.yml rename to manifests/deployment.yml index e4433a0..6d98d92 100644 --- a/Kubernetes/deployment.yml +++ b/manifests/deployment.yml @@ -14,7 +14,7 @@ spec: spec: containers: - name: python-app - image: myacr108.azurecr.io + image: myacr108.azurecr.io/my-container imagePullPolicy: Always resources: limits: diff --git a/Kubernetes/ingress.yml b/manifests/ingress.yml similarity index 100% rename from Kubernetes/ingress.yml rename to manifests/ingress.yml diff --git a/Kubernetes/service.yml b/manifests/service.yml similarity index 100% rename from Kubernetes/service.yml rename to manifests/service.yml From 41e4505b85406c8afe53e7f46e48f0d8920216ba Mon Sep 17 00:00:00 2001 From: sai Date: Mon, 4 Sep 2023 13:38:46 +0530 Subject: [PATCH 54/94] docker tag --- .github/CODEOWNERS | 11 +++++++++++ .github/workflows/main.yml | 5 +++++ 2 files changed, 16 insertions(+) create mode 100644 .github/CODEOWNERS diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000..ec6d3d2 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1,11 @@ +# Global Owners +* @dinkar + +# dockerfiles +dockerfiles/** @dinkar + +# e2e tests +tests/e2e/** @dinkar + +# devworkspace happy path test +tests/devworkspace-happy-path/** \ No newline at end of file diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 801276b..c7d4969 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -46,6 +46,11 @@ jobs: echo '<-----------------------Docker build started----------------------->' docker build . -t ${{ env.REGISTRY_NAME }}.azurecr.io/${{env.CONTAINER_NAME}}:${{ github.sha }} echo '<------------------------Docker build Ended------------------------>' + + - name: tag docker image + run: | + echo '<--------------------------Docker Tagging-------------------------->' + docker tag githubactions-aks-demo:'${{github.sha}}' ${{ env.REGISTRY_NAME }}.azurecr.io/${{env.CONTAINER_NAME}}:'${{github.sha}}' # Docker Container Push to ACR - name: Docker Push From df0f92224049c32ed26c54506e068184bd03d7ad Mon Sep 17 00:00:00 2001 From: sai Date: Mon, 4 Sep 2023 13:42:51 +0530 Subject: [PATCH 55/94] docker tag 1 --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c7d4969..03a2714 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -50,7 +50,7 @@ jobs: - name: tag docker image run: | echo '<--------------------------Docker Tagging-------------------------->' - docker tag githubactions-aks-demo:'${{github.sha}}' ${{ env.REGISTRY_NAME }}.azurecr.io/${{env.CONTAINER_NAME}}:'${{github.sha}}' + docker tag ${{env.CONTAINER_NAME}}:'${{github.sha}}' ${{ env.REGISTRY_NAME }}.azurecr.io/${{env.CONTAINER_NAME}}:'${{github.sha}}' # Docker Container Push to ACR - name: Docker Push From d0be9ad722b528d03b9d30f5b595402f447577c0 Mon Sep 17 00:00:00 2001 From: sai Date: Mon, 4 Sep 2023 16:09:58 +0530 Subject: [PATCH 56/94] jfrog --- .github/workflows/main.yml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 03a2714..a244e1c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -9,7 +9,7 @@ name: Python Flask on Kubernetes -on: push +on: workflow_dispatch # Below environment variables available to all jobs and steps in this workflow env: @@ -46,11 +46,6 @@ jobs: echo '<-----------------------Docker build started----------------------->' docker build . -t ${{ env.REGISTRY_NAME }}.azurecr.io/${{env.CONTAINER_NAME}}:${{ github.sha }} echo '<------------------------Docker build Ended------------------------>' - - - name: tag docker image - run: | - echo '<--------------------------Docker Tagging-------------------------->' - docker tag ${{env.CONTAINER_NAME}}:'${{github.sha}}' ${{ env.REGISTRY_NAME }}.azurecr.io/${{env.CONTAINER_NAME}}:'${{github.sha}}' # Docker Container Push to ACR - name: Docker Push From 83db9cc9c25b735349e3cd926df5e988d406c147 Mon Sep 17 00:00:00 2001 From: sai Date: Mon, 4 Sep 2023 16:14:44 +0530 Subject: [PATCH 57/94] jfrog --- .github/workflows/docker-image.yml | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index a651962..379ee35 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -1,13 +1,18 @@ #this pipeline is for python API on Azure Kubernetes Services +#docker build . -t ${{ env.ARTIFACTORY_NAME }}.jfrog.io/${{env.CONTAINER_NAME}}:${{ github.sha }} +#docker push ${{ env.ARTIFACTORY_NAME }}.jfrog.io/${{env.CONTAINER_NAME}}:${{ github.sha }} name: Build CI -on: workflow_dispatch +on: push # Below environment variables available to all jobs and steps in this workflow env: - REGISTRY_NAME: sai9356 - CONTAINER_NAME: test-image + ARTIFACTORY_URL: https://dkregistry.jfrog.io/artifactory/docker/ + ARTIFACTORY_NAME: dkregistry + ARTIFACTORY_USERNAME: saidinkargedela97@gmail.com + ARTIFACTORY_PASSWORD: cmVmdGtuOjAxOjE3MjUzNTk0ODU6OUg3UlNJbVFEcVhQS2JYMXVvOHlZZHphYzhu + CONTAINER_NAME: myimage # CLUSTER_NAME: my-aks-cluster # CLUSTER_RESOURCE_GROUP: dinkar-rg # NAMESPACE: default @@ -19,32 +24,34 @@ jobs: - name: Checkout code uses: actions/checkout@master - # # Connecting to Azure Container registry (ACR) + # Connecting to Azure Container registry (ACR) # - name: ACR Login - # uses: azure/docker-login@v1 + # uses: docker/login-action@v1 # with: - # login-server: ${{ env.REGISTRY_NAME }}.jfrog.io - # username: ${{ secrets.REGISTRY_USERNAME }} - # password: ${{ secrets.REGISTRY_PASSWORD }} + # registry: ${{ env.ARTIFACTORY_NAME }}.jfrog.io + # username: ${{ secrets.JFROG_USERNAME }} + # password: ${{ secrets.JFROG_PASSWORD }}d # Docker container build - name: Docker Build run: | echo '<-----------------------Docker build started----------------------->' - docker build . -t ${{ env.REGISTRY_NAME }}.jfrog.io/${{env.CONTAINER_NAME}}:${{ github.sha }} + docker build . -t ${{ env.ARTIFACTORY_NAME }}.jfrog.io/docker/${{env.CONTAINER_NAME}}:${{ github.sha }} + echo '<------------------------Docker build Ended------------------------>' # Jfrog Artifactory Login - name: Docker Login run: | echo '<--------------- Docker Login --------------->' - docker login ${{ env.REGISTRY_NAME }}.jfrog.io -u ${{ secrets.ARTIFACTORY_USERNAME }} -p ${{ secrets.ARTIFACTORY_PASSWORD }} + docker login ${{ env.ARTIFACTORY_NAME }}.jfrog.io -u ${{ secrets.ARTIFACTORY_USERNAME }} -p ${{ secrets.ARTIFACTORY_PASSWORD }} echo '<--------------- Docker Login Ended --------------->' # Docker Container Push to ACR - name: Docker Push run: | echo '<-----------------------Docker Publish started----------------------->' - docker push ${{ env.REGISTRY_NAME }}.jfrog.io/${{env.CONTAINER_NAME}}:${{ github.sha }} + docker tag myimage dkregistry.jfrog.io/docker/${{env.CONTAINER_NAME}}:${{ github.sha }} + docker push dkregistry.jfrog.io/docker/${{env.CONTAINER_NAME}}:${{ github.sha }} echo '<------------------------Docker Publish Ended------------------------>' From f8f0925841b26fc239cd0025264dcdf0a9959bbd Mon Sep 17 00:00:00 2001 From: sai Date: Mon, 4 Sep 2023 16:23:32 +0530 Subject: [PATCH 58/94] jfrog --- .github/workflows/docker-image.yml | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 379ee35..bde5425 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -10,8 +10,8 @@ on: push env: ARTIFACTORY_URL: https://dkregistry.jfrog.io/artifactory/docker/ ARTIFACTORY_NAME: dkregistry - ARTIFACTORY_USERNAME: saidinkargedela97@gmail.com - ARTIFACTORY_PASSWORD: cmVmdGtuOjAxOjE3MjUzNTk0ODU6OUg3UlNJbVFEcVhQS2JYMXVvOHlZZHphYzhu + # ARTIFACTORY_USERNAME: saidinkargedela97@gmail.com + # ARTIFACTORY_PASSWORD: cmVmdGtuOjAxOjE3MjUzNTk0ODU6OUg3UlNJbVFEcVhQS2JYMXVvOHlZZHphYzhu CONTAINER_NAME: myimage # CLUSTER_NAME: my-aks-cluster # CLUSTER_RESOURCE_GROUP: dinkar-rg @@ -24,13 +24,13 @@ jobs: - name: Checkout code uses: actions/checkout@master - # Connecting to Azure Container registry (ACR) - # - name: ACR Login - # uses: docker/login-action@v1 - # with: - # registry: ${{ env.ARTIFACTORY_NAME }}.jfrog.io - # username: ${{ secrets.JFROG_USERNAME }} - # password: ${{ secrets.JFROG_PASSWORD }}d + # Connecting to Jfrog Artifactory + - name: Jfrog Artifactory Login + uses: docker/login-action@v1 + with: + registry: ${{ env.ARTIFACTORY_NAME }}.jfrog.io + username: ${{ secrets.ARTIFACTORY_USERNAME }} + password: ${{ secrets.ARTIFACTORY_PASSWORD }} # Docker container build - name: Docker Build @@ -40,12 +40,12 @@ jobs: echo '<------------------------Docker build Ended------------------------>' - # Jfrog Artifactory Login - - name: Docker Login - run: | - echo '<--------------- Docker Login --------------->' - docker login ${{ env.ARTIFACTORY_NAME }}.jfrog.io -u ${{ secrets.ARTIFACTORY_USERNAME }} -p ${{ secrets.ARTIFACTORY_PASSWORD }} - echo '<--------------- Docker Login Ended --------------->' + # # Jfrog Artifactory Login + # - name: Docker Login + # run: | + # echo '<--------------- Docker Login --------------->' + # docker login ${{ env.ARTIFACTORY_NAME }}.jfrog.io -u ${{ secrets.ARTIFACTORY_USERNAME }} -p ${{ secrets.ARTIFACTORY_PASSWORD }} + # echo '<--------------- Docker Login Ended --------------->' # Docker Container Push to ACR - name: Docker Push From 1f5c215764874298644b29f4a99cdb1014f6bc94 Mon Sep 17 00:00:00 2001 From: sai Date: Mon, 4 Sep 2023 16:31:36 +0530 Subject: [PATCH 59/94] jfrog --- .github/workflows/docker-image.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index bde5425..45e78aa 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -1,6 +1,7 @@ #this pipeline is for python API on Azure Kubernetes Services #docker build . -t ${{ env.ARTIFACTORY_NAME }}.jfrog.io/${{env.CONTAINER_NAME}}:${{ github.sha }} #docker push ${{ env.ARTIFACTORY_NAME }}.jfrog.io/${{env.CONTAINER_NAME}}:${{ github.sha }} +#docker tag myimage dkregistry.jfrog.io/docker/${{env.CONTAINER_NAME}}:${{ github.sha }} name: Build CI @@ -36,7 +37,7 @@ jobs: - name: Docker Build run: | echo '<-----------------------Docker build started----------------------->' - docker build . -t ${{ env.ARTIFACTORY_NAME }}.jfrog.io/docker/${{env.CONTAINER_NAME}}:${{ github.sha }} + docker build . -t ${{ env.ARTIFACTORY_NAME }}.jfrog.io/docker/mytestimage:${{ github.sha }} echo '<------------------------Docker build Ended------------------------>' @@ -51,7 +52,6 @@ jobs: - name: Docker Push run: | echo '<-----------------------Docker Publish started----------------------->' - docker tag myimage dkregistry.jfrog.io/docker/${{env.CONTAINER_NAME}}:${{ github.sha }} - docker push dkregistry.jfrog.io/docker/${{env.CONTAINER_NAME}}:${{ github.sha }} + docker push dkregistry.jfrog.io/docker/mytestimage:${{ github.sha }} echo '<------------------------Docker Publish Ended------------------------>' From 3bede6c7a7a732a27acbe1081f3ebe8b7c7e6ad6 Mon Sep 17 00:00:00 2001 From: sai Date: Mon, 4 Sep 2023 16:35:16 +0530 Subject: [PATCH 60/94] jfrog tag --- .github/workflows/docker-image.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 45e78aa..3dc2680 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -52,6 +52,7 @@ jobs: - name: Docker Push run: | echo '<-----------------------Docker Publish started----------------------->' + docker tag mytestimage dkregistry.jfrog.io/docker/mytestimage docker push dkregistry.jfrog.io/docker/mytestimage:${{ github.sha }} echo '<------------------------Docker Publish Ended------------------------>' From cc34a5cd82ab09952c8abdf701c015dd4725661a Mon Sep 17 00:00:00 2001 From: sai Date: Mon, 4 Sep 2023 16:48:55 +0530 Subject: [PATCH 61/94] jfrog tagged --- .github/workflows/docker-image.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 3dc2680..e716d05 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -52,7 +52,7 @@ jobs: - name: Docker Push run: | echo '<-----------------------Docker Publish started----------------------->' - docker tag mytestimage dkregistry.jfrog.io/docker/mytestimage + docker tag mytestimage:latest dkregistry.jfrog.io/docker/mytestimage:latest docker push dkregistry.jfrog.io/docker/mytestimage:${{ github.sha }} echo '<------------------------Docker Publish Ended------------------------>' From 1e8b06452808e2d96f6c6810141b626ef7547e0e Mon Sep 17 00:00:00 2001 From: sai Date: Mon, 4 Sep 2023 17:31:36 +0530 Subject: [PATCH 62/94] jfrog tagged --- .github/workflows/docker-image.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index e716d05..f9c8b1e 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -52,7 +52,7 @@ jobs: - name: Docker Push run: | echo '<-----------------------Docker Publish started----------------------->' - docker tag mytestimage:latest dkregistry.jfrog.io/docker/mytestimage:latest + docker tag mytestimage:latest dkregistry.jfrog.io/docker:latest docker push dkregistry.jfrog.io/docker/mytestimage:${{ github.sha }} echo '<------------------------Docker Publish Ended------------------------>' From d6707018fb8d46190b9e4b7ab3ff29b56bca3c1a Mon Sep 17 00:00:00 2001 From: sai Date: Mon, 4 Sep 2023 17:37:38 +0530 Subject: [PATCH 63/94] jfrog tagged 1 --- .github/workflows/docker-image.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index f9c8b1e..03a2696 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -52,7 +52,7 @@ jobs: - name: Docker Push run: | echo '<-----------------------Docker Publish started----------------------->' - docker tag mytestimage:latest dkregistry.jfrog.io/docker:latest + docker tag mytestimage:${{github.sha}} dkregistry.jfrog.io/docker:latest docker push dkregistry.jfrog.io/docker/mytestimage:${{ github.sha }} echo '<------------------------Docker Publish Ended------------------------>' From 8438c2aa41ae53bf2fe402975ccac4ebb0314f05 Mon Sep 17 00:00:00 2001 From: sai Date: Mon, 4 Sep 2023 17:38:49 +0530 Subject: [PATCH 64/94] jfrog tagged 2 --- .github/workflows/docker-image.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 03a2696..1e95f5f 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -52,7 +52,7 @@ jobs: - name: Docker Push run: | echo '<-----------------------Docker Publish started----------------------->' - docker tag mytestimage:${{github.sha}} dkregistry.jfrog.io/docker:latest + docker tag mytestimage dkregistry.jfrog.io/docker:latest docker push dkregistry.jfrog.io/docker/mytestimage:${{ github.sha }} echo '<------------------------Docker Publish Ended------------------------>' From 939b0d98904028be9128309ba471b379959f139c Mon Sep 17 00:00:00 2001 From: sai Date: Mon, 4 Sep 2023 17:41:27 +0530 Subject: [PATCH 65/94] jfrog tagged 2 --- .github/workflows/docker-image.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 1e95f5f..f862545 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -52,7 +52,7 @@ jobs: - name: Docker Push run: | echo '<-----------------------Docker Publish started----------------------->' - docker tag mytestimage dkregistry.jfrog.io/docker:latest + docker tag ${{github.sha}} dkregistry.jfrog.io/docker:latest docker push dkregistry.jfrog.io/docker/mytestimage:${{ github.sha }} echo '<------------------------Docker Publish Ended------------------------>' From c0b793d0ac6ed87946d0e9ffc068e312876e4425 Mon Sep 17 00:00:00 2001 From: sai Date: Mon, 4 Sep 2023 17:49:36 +0530 Subject: [PATCH 66/94] jfrog tagged 2 --- .github/workflows/docker-image.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index f862545..5fee14b 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -52,7 +52,7 @@ jobs: - name: Docker Push run: | echo '<-----------------------Docker Publish started----------------------->' - docker tag ${{github.sha}} dkregistry.jfrog.io/docker:latest + docker tag dkregistry.jfrog.io/docker/mytestimage:${{ github.sha }} dkregistry.jfrog.io/docker/mytestimage:latest docker push dkregistry.jfrog.io/docker/mytestimage:${{ github.sha }} echo '<------------------------Docker Publish Ended------------------------>' From 5ceb70ab4c310192568b5b9a5d297dfb98a26aea Mon Sep 17 00:00:00 2001 From: sai Date: Mon, 4 Sep 2023 19:11:22 +0530 Subject: [PATCH 67/94] tagging both jfrog and acr --- .github/workflows/docker-image.yml | 13 ++++++------- .github/workflows/main.yml | 5 +++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 5fee14b..5f30277 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -41,18 +41,17 @@ jobs: echo '<------------------------Docker build Ended------------------------>' - # # Jfrog Artifactory Login - # - name: Docker Login - # run: | - # echo '<--------------- Docker Login --------------->' - # docker login ${{ env.ARTIFACTORY_NAME }}.jfrog.io -u ${{ secrets.ARTIFACTORY_USERNAME }} -p ${{ secrets.ARTIFACTORY_PASSWORD }} - # echo '<--------------- Docker Login Ended --------------->' + # Docker Tag + - name: Docker Tag + run: | + echo '<--------------- Docker Image Retagging --------------->' + docker tag dkregistry.jfrog.io/docker/mytestimage:${{ github.sha }} dkregistry.jfrog.io/docker/mytestimage:1.0 # Docker Container Push to ACR - name: Docker Push run: | echo '<-----------------------Docker Publish started----------------------->' - docker tag dkregistry.jfrog.io/docker/mytestimage:${{ github.sha }} dkregistry.jfrog.io/docker/mytestimage:latest + docker push dkregistry.jfrog.io/docker/mytestimage:${{ github.sha }} echo '<------------------------Docker Publish Ended------------------------>' diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a244e1c..73eb7d6 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -9,7 +9,7 @@ name: Python Flask on Kubernetes -on: workflow_dispatch +on: push # Below environment variables available to all jobs and steps in this workflow env: @@ -51,6 +51,7 @@ jobs: - name: Docker Push run: | echo '<-----------------------Docker Publish started----------------------->' + docker tag ${{ env.REGISTRY_NAME }}.azurecr.io/${{env.CONTAINER_NAME}}:${{ github.sha }} ${{ env.REGISTRY_NAME }}.azurecr.io/${{env.CONTAINER_NAME}}:latest docker push ${{ env.REGISTRY_NAME }}.azurecr.io/${{env.CONTAINER_NAME}}:${{ github.sha }} echo '<------------------------Docker Publish Ended------------------------>' @@ -89,7 +90,7 @@ jobs: uses: Azure/k8s-create-secret@v1.1 with: # Container registry URL - container-registry-url: https://${{ env.REGISTRY_NAME }}.azurecr.io/${{env.CONTAINER_NAME}} + container-registry-url: https://${{env.REGISTRY_NAME}}.azurecr.io/${{env.CONTAINER_NAME}} # Container registry username container-registry-username: '${{ secrets.REGISTRY_USERNAME }}' # Container registry password From de2fcf603260349fcc111d837d9974beebde8bf0 Mon Sep 17 00:00:00 2001 From: sai Date: Mon, 4 Sep 2023 19:27:33 +0530 Subject: [PATCH 68/94] upgraded aks deploy to v4 --- .github/workflows/docker-image.yml | 2 +- .github/workflows/main.yml | 18 +++++++++++------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 5f30277..7f53bd7 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -5,7 +5,7 @@ name: Build CI -on: push +on: workflow_dispatch # Below environment variables available to all jobs and steps in this workflow env: diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 73eb7d6..1948136 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -102,14 +102,18 @@ jobs: # Deploy to k8s cluster - name: Deploy to Kubernetes cluster - uses: Azure/k8s-deploy@v1 - with: + uses: Azure/k8s-deploy@v4 + with: + # deploy/promote/reject + action: deploy # Path to the manifest files which will be used for deployment. - manifests: ${{ env.DEPLOYMENT_MANIFEST_PATH }} + manifests: | + ${{ env.DEPLOYMENT_MANIFEST_PATH }} # Fully qualified resource URL of the image(s) to be used for substitutions on the manifest files Example: contosodemo.azurecr.io/helloworld:test - images: ${{ env.REGISTRY_NAME }}.azurecr.io/${{ env.CONTAINER_NAME }}:${{ github.sha }} + images: | + ${{ env.REGISTRY_NAME }}.azurecr.io/${{ env.CONTAINER_NAME }}:${{ github.sha }} # Name of a docker-registry secret that has already been set up within the cluster. Each of these secret names are added under imagePullSecrets field for the workloads found in the input manifest files - imagepullsecrets: acr-image-pull-secret - # deploy/promote/reject - action: deploy + imagepullsecrets: | + acr-image-pull-secret + \ No newline at end of file From 5691e5a8efdf0c59c1cbf177f0db2f093f523774 Mon Sep 17 00:00:00 2001 From: sai Date: Mon, 4 Sep 2023 19:48:52 +0530 Subject: [PATCH 69/94] added code checkout --- .github/workflows/main.yml | 4 +++- AZ_SERVICECONNECTION.md | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 AZ_SERVICECONNECTION.md diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 1948136..f6d6644 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -67,11 +67,13 @@ jobs: needs: [build] steps: + # Checks out the repository this file is in + - uses: actions/checkout@v3 - name: Azure Kubernetes set context uses: Azure/aks-set-context@v1 with: - # Azure credentials i.e. output of `az ad sp create-for-rbac --sdk-auth` + # Azure credentials i.e. output of creds: '${{secrets.AZURE_CREDENTIALS}}' # Resource Group Name resource-group: ${{ env.RESOURCE_GROUP }} diff --git a/AZ_SERVICECONNECTION.md b/AZ_SERVICECONNECTION.md new file mode 100644 index 0000000..998a5e7 --- /dev/null +++ b/AZ_SERVICECONNECTION.md @@ -0,0 +1,38 @@ +# Use this below method to create azure service principal + +# Commad to be executed form Azure +az ad sp create-for-rbac \ + --name "myAzureServiceGitHubConnection" \ + --role contributor \ + --scopes /subscriptions/e94972e2-c0eb-497c-8f74-f98b46621f80/resourceGroups/sai-arch \ + --sdk-auth + +# Execute below powershell commands in Azure to generate the output for AZURE_CREDENTIALS + +$ServicePrincipalName = "MyGithubActionsConnection" +$AzSubscriptionName = "production" + +Connect-AzureAD + +$Subscription = (Get-AzSubscription -SubscriptionName $AzSubscriptionName) +$ServicePrincipal = Get-AzADServicePrincipal -DisplayName $ServicePrincipalName +$AzureADApplication = Get-AzureADApplication -SearchString $ServicePrincipalName + +$OutputObject = [PSCustomObject]@{ + clientId = $ServicePrincipal.AppId + clientSecret = (New-AzureADApplicationPasswordCredential -ObjectId $AzureADApplication.ObjectId).Value + subscriptionId = $Subscription.Id + tenantId = $Subscription.TenantId +} + +$OutputObject | ConvertTo-Json + + +# Expected output of the above commands and copy as the below mentioned json format to AZURE_CREDENTIALS + +{ + "clientId": "7b367077-d2ed-41b4-99f1-8b0f5b0e9ca7", + "clientSecret": "usNonfiGXJXvwlC9FyUzcAzn8OIgHe2JLCuaiEemH+Y=", + "subscriptionId": "e94972e2-c0eb-497c-8f74-f98b46621f80", + "tenantId": "9b4947ce-08e8-47b9-9c2d-c39b90bfaa7e" +} \ No newline at end of file From 35c6146e86d2ffab136c18df0faa2607ad4281c5 Mon Sep 17 00:00:00 2001 From: sai Date: Mon, 4 Sep 2023 22:48:26 +0530 Subject: [PATCH 70/94] added az sp --- Azure_servcie_connection.md | 50 +++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 Azure_servcie_connection.md diff --git a/Azure_servcie_connection.md b/Azure_servcie_connection.md new file mode 100644 index 0000000..e6d9f5e --- /dev/null +++ b/Azure_servcie_connection.md @@ -0,0 +1,50 @@ +# Use this below method to create azure service principal + +The quickest way and easiest way to create this Service Principal is to use Azure CLI and issue the command: + +```sh +az ad sp create-for-rbac \ + --name "myAzureServiceGitHubConnection" \ + --role contributor \ + --scopes /subscriptions/e94972e2-c0eb-497c-8f74-f98b46621f80/resourceGroups/sai-arch \ + --sdk-auth +``` + +# Execute below powershell commands in Azure to collect Service Principal information + +To store the information inside a GitHub Actions secret, it needs to be stored within a JSON format. We can run this PowerShell subscription to collect all the information you will need for GitHub and in the form that GitHub needs. + + +```sh +$ServicePrincipalName = "MyGithubActionsConnection" +$AzSubscriptionName = "production" + +Connect-AzureAD + +$Subscription = (Get-AzSubscription -SubscriptionName $AzSubscriptionName) +$ServicePrincipal = Get-AzADServicePrincipal -DisplayName $ServicePrincipalName +$AzureADApplication = Get-AzureADApplication -SearchString $ServicePrincipalName + +$OutputObject = [PSCustomObject]@{ + clientId = $ServicePrincipal.AppId + clientSecret = (New-AzureADApplicationPasswordCredential -ObjectId $AzureADApplication.ObjectId).Value + subscriptionId = $Subscription.Id + tenantId = $Subscription.TenantId +} + +$OutputObject | ConvertTo-Json +``` + + +# Expected output of the above commands and copy as the below mentioned json format to AZURE_CREDENTIALS + +Take a copy of the output from the PowerShell query. This will be stored inside a GitHub Secret for use within your workflows. +Within the repository where your workflow is, click on Settings > Secrets > Actions and then click on new repository secret. + +```sh +{ + "clientId": "7b367077-d2ed-41b4-99f1-8b0f5b0e9ca7", + "clientSecret": "usNonfiGXJXvwlC9FyUzcAzn8OIgHe2JLCuaiEemH+Y=", + "subscriptionId": "e94972e2-c0eb-497c-8f74-f98b46621f80", + "tenantId": "9b4947ce-08e8-47b9-9c2d-c39b90bfaa7e" +}``` \ No newline at end of file From 1b792295a6c2e8eaab6ae5cec370a13e7194bdad Mon Sep 17 00:00:00 2001 From: sai Date: Mon, 4 Sep 2023 22:51:50 +0530 Subject: [PATCH 71/94] added az sp --- Azure_servcie_connection.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Azure_servcie_connection.md b/Azure_servcie_connection.md index e6d9f5e..6b498b1 100644 --- a/Azure_servcie_connection.md +++ b/Azure_servcie_connection.md @@ -43,8 +43,8 @@ Within the repository where your workflow is, click on Settings > Secrets > Acti ```sh { - "clientId": "7b367077-d2ed-41b4-99f1-8b0f5b0e9ca7", - "clientSecret": "usNonfiGXJXvwlC9FyUzcAzn8OIgHe2JLCuaiEemH+Y=", - "subscriptionId": "e94972e2-c0eb-497c-8f74-f98b46621f80", - "tenantId": "9b4947ce-08e8-47b9-9c2d-c39b90bfaa7e" + "clientId": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", + "clientSecret": "xxxxxxxxxxxxxxxxxxxxxxxxxxxx", + "subscriptionId": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", + "tenantId": "xxxxxxxxxxxxxxxxxxxxxxxxxxxx" }``` \ No newline at end of file From f6240199ca925263f83f79eea53fdf6b9e788bee Mon Sep 17 00:00:00 2001 From: sai Date: Tue, 5 Sep 2023 13:28:02 +0530 Subject: [PATCH 72/94] added jfrog with aks --- .github/workflows/docker-image.yml | 86 +++++++++++++++++++++++++----- .github/workflows/main.yml | 3 +- AZ_SERVICECONNECTION.md | 38 ------------- 3 files changed, 76 insertions(+), 51 deletions(-) delete mode 100644 AZ_SERVICECONNECTION.md diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 7f53bd7..dea5e7d 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -1,22 +1,23 @@ #this pipeline is for python API on Azure Kubernetes Services -#docker build . -t ${{ env.ARTIFACTORY_NAME }}.jfrog.io/${{env.CONTAINER_NAME}}:${{ github.sha }} -#docker push ${{ env.ARTIFACTORY_NAME }}.jfrog.io/${{env.CONTAINER_NAME}}:${{ github.sha }} -#docker tag myimage dkregistry.jfrog.io/docker/${{env.CONTAINER_NAME}}:${{ github.sha }} + name: Build CI -on: workflow_dispatch +on: push # Below environment variables available to all jobs and steps in this workflow env: ARTIFACTORY_URL: https://dkregistry.jfrog.io/artifactory/docker/ ARTIFACTORY_NAME: dkregistry - # ARTIFACTORY_USERNAME: saidinkargedela97@gmail.com - # ARTIFACTORY_PASSWORD: cmVmdGtuOjAxOjE3MjUzNTk0ODU6OUg3UlNJbVFEcVhQS2JYMXVvOHlZZHphYzhu + ARTIFACTORY_USERNAME: saidinkargedela97@gmail.com CONTAINER_NAME: myimage - # CLUSTER_NAME: my-aks-cluster - # CLUSTER_RESOURCE_GROUP: dinkar-rg - # NAMESPACE: default + CLUSTER_NAME: my-aks-cluster + CLUSTER_RESOURCE_GROUP: dinkar-rg + NAMESPACE: default + DEPLOYMENT_MANIFEST_PATH: | + manifests/deployment.yaml + manifests/service.yaml + jobs: build: @@ -37,8 +38,7 @@ jobs: - name: Docker Build run: | echo '<-----------------------Docker build started----------------------->' - docker build . -t ${{ env.ARTIFACTORY_NAME }}.jfrog.io/docker/mytestimage:${{ github.sha }} - + docker build . -t dkregistry.jfrog.io/docker/mytestimage:${{ github.sha }} echo '<------------------------Docker build Ended------------------------>' # Docker Tag @@ -51,7 +51,69 @@ jobs: - name: Docker Push run: | echo '<-----------------------Docker Publish started----------------------->' - docker push dkregistry.jfrog.io/docker/mytestimage:${{ github.sha }} echo '<------------------------Docker Publish Ended------------------------>' + Deploy: + permissions: + actions: read + contents: read + id-token: write + + runs-on: ubuntu-latest + + # Delpoy job won't run until build job is completed + needs: [build] + + steps: + # Checks out the repository this file is in + - uses: actions/checkout@v3 + + - name: Azure Kubernetes set context + uses: Azure/aks-set-context@v1 + with: + # Azure credentials i.e. output of + creds: '${{secrets.AZURE_CREDENTIALS}}' + # Resource Group Name + resource-group: ${{ env.CLUSTER_RESOURCE_GROUP }} + # AKS Cluster Name + cluster-name: ${{ env.CLUSTER_NAME }} + + + # Use kubelogin to configure your kubeconfig for Azure auth + - name: Set up kubelogin for non-interactive login + uses: azure/use-kubelogin@v1 + with: + kubelogin-version: 'v0.0.25' + + # Create K8s secrets to pull images + - name: Create secret in Kubernetes cluster + uses: Azure/k8s-create-secret@v1.1 + with: + # Container registry URL + container-registry-url: ${{env.ARTIFACTORY_URL}} + # Container registry username + container-registry-username: '${{ secrets.ARTIFACTORY_USERNAME }}' + # Container registry password + container-registry-password: '${{ secrets.ARTIFACTORY_PASSWORD }}' + # Type of Kubernetes secret. For example, docker-registry or generic + secret-type: docker-registry + # Name of the secret. You can use this secret name in the Kubernetes YAML configuration file. + secret-name: jfrog-image-pull-secret + + # Deploy to k8s cluster + - name: Deploy to Kubernetes cluster + uses: Azure/k8s-deploy@v4 + with: + # deploy/promote/reject + action: deploy + # Path to the manifest files which will be used for deployment. + manifests: | + ${{ env.DEPLOYMENT_MANIFEST_PATH }} + # Fully qualified resource URL of the image(s) to be used for substitutions on the manifest files Example: contosodemo.azurecr.io/helloworld:test + images: | + dkregistry.jfrog.io/docker/mytestimage:${{ github.sha }} + # Name of a docker-registry secret that has already been set up within the cluster. Each of these secret names are added under imagePullSecrets field for the workloads found in the input manifest files + imagepullsecrets: | + acr-image-pull-secret + diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f6d6644..c9590cb 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -9,7 +9,8 @@ name: Python Flask on Kubernetes -on: push +on: + workflow_dispatch: # Below environment variables available to all jobs and steps in this workflow env: diff --git a/AZ_SERVICECONNECTION.md b/AZ_SERVICECONNECTION.md deleted file mode 100644 index 998a5e7..0000000 --- a/AZ_SERVICECONNECTION.md +++ /dev/null @@ -1,38 +0,0 @@ -# Use this below method to create azure service principal - -# Commad to be executed form Azure -az ad sp create-for-rbac \ - --name "myAzureServiceGitHubConnection" \ - --role contributor \ - --scopes /subscriptions/e94972e2-c0eb-497c-8f74-f98b46621f80/resourceGroups/sai-arch \ - --sdk-auth - -# Execute below powershell commands in Azure to generate the output for AZURE_CREDENTIALS - -$ServicePrincipalName = "MyGithubActionsConnection" -$AzSubscriptionName = "production" - -Connect-AzureAD - -$Subscription = (Get-AzSubscription -SubscriptionName $AzSubscriptionName) -$ServicePrincipal = Get-AzADServicePrincipal -DisplayName $ServicePrincipalName -$AzureADApplication = Get-AzureADApplication -SearchString $ServicePrincipalName - -$OutputObject = [PSCustomObject]@{ - clientId = $ServicePrincipal.AppId - clientSecret = (New-AzureADApplicationPasswordCredential -ObjectId $AzureADApplication.ObjectId).Value - subscriptionId = $Subscription.Id - tenantId = $Subscription.TenantId -} - -$OutputObject | ConvertTo-Json - - -# Expected output of the above commands and copy as the below mentioned json format to AZURE_CREDENTIALS - -{ - "clientId": "7b367077-d2ed-41b4-99f1-8b0f5b0e9ca7", - "clientSecret": "usNonfiGXJXvwlC9FyUzcAzn8OIgHe2JLCuaiEemH+Y=", - "subscriptionId": "e94972e2-c0eb-497c-8f74-f98b46621f80", - "tenantId": "9b4947ce-08e8-47b9-9c2d-c39b90bfaa7e" -} \ No newline at end of file From 84ad78fdd9844a34e089149940181ced37be4312 Mon Sep 17 00:00:00 2001 From: sai Date: Wed, 6 Sep 2023 16:39:06 +0530 Subject: [PATCH 73/94] repo restructure --- .github/workflows/docker-image.yml | 10 ++------ .github/workflows/jfrog.yml | 41 ++++++++++++++++++++++++++++++ .github/workflows/main.yml | 1 - Dockerfile | 5 ++-- docker/Dockerfile.Dev | 22 ---------------- 5 files changed, 45 insertions(+), 34 deletions(-) create mode 100644 .github/workflows/jfrog.yml delete mode 100644 docker/Dockerfile.Dev diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index dea5e7d..5a518fe 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -3,7 +3,7 @@ name: Build CI -on: push +on: workflow_dispatch # Below environment variables available to all jobs and steps in this workflow env: @@ -40,13 +40,7 @@ jobs: echo '<-----------------------Docker build started----------------------->' docker build . -t dkregistry.jfrog.io/docker/mytestimage:${{ github.sha }} echo '<------------------------Docker build Ended------------------------>' - - # Docker Tag - - name: Docker Tag - run: | - echo '<--------------- Docker Image Retagging --------------->' - docker tag dkregistry.jfrog.io/docker/mytestimage:${{ github.sha }} dkregistry.jfrog.io/docker/mytestimage:1.0 - + # Docker Container Push to ACR - name: Docker Push run: | diff --git a/.github/workflows/jfrog.yml b/.github/workflows/jfrog.yml new file mode 100644 index 0000000..5091d23 --- /dev/null +++ b/.github/workflows/jfrog.yml @@ -0,0 +1,41 @@ +name: Build and Tag Docker Image + +on: + push: + branches: + - workflow_dispatch + +jobs: + build-and-tag: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Setup JFrog CLI + uses: jfrog/setup-jfrog-cli@v3 + env: + JF_URL: ${{ secrets.JF_URL }} + JF_ACCESS_TOKEN: ${{ secrets.JF_ACCESS_TOKEN }} + + - name: Build Tag and push Docker Image + env: + IMAGE_NAME: dkregistry.jfrog.io/docker/jfrog-docker-example-image:${{ github.run_number }} + run: | + jf docker build -t $IMAGE_NAME . + jf docker push $IMAGE_NAME + + - name: Publish Build info With JFrog CLI + env: + # Generated and maintained by GitHub + JFROG_CLI_BUILD_NAME: jfrog-docker-build-example + # JFrog organization secret + JFROG_CLI_BUILD_NUMBER : ${{ github.run_number }} + run: | + # Export the build name and build nuber + # Collect environment variables for the build + jf rt build-collect-env + # Collect VCS details from git and add them to the build + jf rt build-add-git + # Publish build info + jf rt build-publish \ No newline at end of file diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c9590cb..0063408 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -52,7 +52,6 @@ jobs: - name: Docker Push run: | echo '<-----------------------Docker Publish started----------------------->' - docker tag ${{ env.REGISTRY_NAME }}.azurecr.io/${{env.CONTAINER_NAME}}:${{ github.sha }} ${{ env.REGISTRY_NAME }}.azurecr.io/${{env.CONTAINER_NAME}}:latest docker push ${{ env.REGISTRY_NAME }}.azurecr.io/${{env.CONTAINER_NAME}}:${{ github.sha }} echo '<------------------------Docker Publish Ended------------------------>' diff --git a/Dockerfile b/Dockerfile index 09992ba..9ceed0a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,10 +6,9 @@ LABEL BuilderEmail="dinkarsai03@gmail.com" #Set the working directory in the container WORKDIR /app -COPY . /app -#Copy the requirements file into the container -COPY requirements.txt . +#Copy the all files like requirements file into the container +COPY . /app #install the dependencies from requirements.txt RUN pip install -r requirements.txt diff --git a/docker/Dockerfile.Dev b/docker/Dockerfile.Dev deleted file mode 100644 index 09992ba..0000000 --- a/docker/Dockerfile.Dev +++ /dev/null @@ -1,22 +0,0 @@ -#This is the base image for this Dockerfile -FROM python:3-alpine3.15 - -LABEL BuildBy="Dinkar Gedela" -LABEL BuilderEmail="dinkarsai03@gmail.com" - -#Set the working directory in the container -WORKDIR /app -COPY . /app - -#Copy the requirements file into the container -COPY requirements.txt . - -#install the dependencies from requirements.txt -RUN pip install -r requirements.txt - -#Open the port on which Flask app will run -EXPOSE 8080 - -#commands to run the Flask app -ENTRYPOINT [ "python" ] -CMD [ "/src/app.py" ] \ No newline at end of file From 113e2c94892c2941362e5e093cf7dc67e676ff1d Mon Sep 17 00:00:00 2001 From: sai Date: Fri, 8 Sep 2023 13:51:00 +0530 Subject: [PATCH 74/94] added the testing parameter --- .github/workflows/testing.yml | 38 +++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 .github/workflows/testing.yml diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml new file mode 100644 index 0000000..b40bd19 --- /dev/null +++ b/.github/workflows/testing.yml @@ -0,0 +1,38 @@ +name: Python application + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +permissions: + contents: read + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Set up Python 3.10 + uses: actions/setup-python@v3 + with: + python-version: "3.10" + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install flake8 pytest + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + - name: Lint with flake8 + run: | + # stop the build if there are Python syntax errors or undefined names + flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics + # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide + flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + - name: Test with pytest + run: | + pip install pytest + export PYTHONPATH=src + pytest \ No newline at end of file From 9115939664a262a6ab8402e618a099639047bd7c Mon Sep 17 00:00:00 2001 From: sai Date: Fri, 8 Sep 2023 13:54:00 +0530 Subject: [PATCH 75/94] added the testing parameter --- .github/workflows/testing.yml | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index b40bd19..ee85f62 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -1,10 +1,6 @@ name: Python application -on: - push: - branches: [ "main" ] - pull_request: - branches: [ "main" ] +on: push permissions: contents: read @@ -35,4 +31,4 @@ jobs: run: | pip install pytest export PYTHONPATH=src - pytest \ No newline at end of file + pytest From 95e718a57f57a2357fd0406a1f16a43874d4b1e3 Mon Sep 17 00:00:00 2001 From: sai Date: Fri, 8 Sep 2023 15:01:07 +0530 Subject: [PATCH 76/94] checking code --- src/app.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/app.py b/src/app.py index f32d7b8..f114533 100644 --- a/src/app.py +++ b/src/app.py @@ -1,13 +1,11 @@ -from flask import Flask, request +from flask import Flask app = Flask(__name__) -@app.route("/first_script") -def hello_world(): - request_body = request.json - return f"

Hello, World! {request_body}

" +@app.route("/") +def index(): + return "Hello, world!" if __name__ == "__main__": - app.run(host='0.0.0.0' , port=8080) - + app.run(host='0.0.0.0') From 1c6f9a56f72b817fc1c82bf3dee92e504f46cd0e Mon Sep 17 00:00:00 2001 From: sai Date: Fri, 8 Sep 2023 16:06:04 +0530 Subject: [PATCH 77/94] testing code by changing values --- .github/workflows/testing.yml | 26 ++++++++++++++++++++++---- manifests/service.yml | 6 ++++-- src/app.py | 2 +- 3 files changed, 27 insertions(+), 7 deletions(-) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index ee85f62..98806d5 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -1,4 +1,4 @@ -name: Python application +name: Python application Testing on: push @@ -10,25 +10,43 @@ jobs: runs-on: ubuntu-latest + strategy: + matrix: + python-version: [3.8, 3.9] + steps: + #Code checkout and python setup - uses: actions/checkout@v3 - - name: Set up Python 3.10 + - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v3 with: - python-version: "3.10" + python-version: ${{ matrix.python-version }} + + #Installling all python Dependancies - name: Install dependencies run: | python -m pip install --upgrade pip + sudo apt install python${{ env.PYTHON_VERSION }}-venv + pip install setuptools pip install flake8 pytest + pip install pytest + pip install pylint if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + + #Python code linting with Flake8 - name: Lint with flake8 run: | # stop the build if there are Python syntax errors or undefined names flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + + - name: Analysing the code with pylint + run: | + pylint $(git ls-files '*.py') + + #python code test with pytest - name: Test with pytest run: | - pip install pytest export PYTHONPATH=src pytest diff --git a/manifests/service.yml b/manifests/service.yml index f573455..0e0bdcb 100644 --- a/manifests/service.yml +++ b/manifests/service.yml @@ -7,5 +7,7 @@ spec: app: python-app type: NodePort ports: - - port: 8080 - targetPort: 80 \ No newline at end of file + - protocol: TCP + port: 8080 + targetPort: 80 + nodePort: 30000 \ No newline at end of file diff --git a/src/app.py b/src/app.py index f114533..37b6a35 100644 --- a/src/app.py +++ b/src/app.py @@ -4,7 +4,7 @@ @app.route("/") def index(): - return "Hello, world!" + return "Hello Arch world!" if __name__ == "__main__": From 215095d055e516de24966c550f805890307874a8 Mon Sep 17 00:00:00 2001 From: sai Date: Fri, 8 Sep 2023 16:13:03 +0530 Subject: [PATCH 78/94] commented python venv --- .github/workflows/testing.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 98806d5..a623eea 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -26,7 +26,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - sudo apt install python${{ env.PYTHON_VERSION }}-venv + #sudo apt install python${{ env.PYTHON_VERSION }}-venv pip install setuptools pip install flake8 pytest pip install pytest From 757afe2cc46512973c859f5bae2ed7008e8e78c0 Mon Sep 17 00:00:00 2001 From: sai Date: Fri, 8 Sep 2023 16:15:00 +0530 Subject: [PATCH 79/94] changed path in pylint --- .github/workflows/testing.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index a623eea..e64c349 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -43,7 +43,7 @@ jobs: - name: Analysing the code with pylint run: | - pylint $(git ls-files '*.py') + pylint $(git ls-files '/src/app.py') #python code test with pytest - name: Test with pytest From 00e4cb1669dc62a64595bd2ec52ff507b70fe104 Mon Sep 17 00:00:00 2001 From: sai Date: Fri, 8 Sep 2023 16:16:18 +0530 Subject: [PATCH 80/94] changed path in pylint --- .github/workflows/testing.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index e64c349..2303eaf 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -43,7 +43,7 @@ jobs: - name: Analysing the code with pylint run: | - pylint $(git ls-files '/src/app.py') + pylint $(git ls-files 'src/app.py') #python code test with pytest - name: Test with pytest From 5956055a6d7b140084239d2be03036ee1b5b0ce2 Mon Sep 17 00:00:00 2001 From: sai Date: Fri, 8 Sep 2023 16:40:20 +0530 Subject: [PATCH 81/94] changed py version --- .github/workflows/testing.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 2303eaf..549f214 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -12,7 +12,7 @@ jobs: strategy: matrix: - python-version: [3.8, 3.9] + python-version: [3.10] steps: #Code checkout and python setup @@ -26,7 +26,6 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - #sudo apt install python${{ env.PYTHON_VERSION }}-venv pip install setuptools pip install flake8 pytest pip install pytest From 331da9974f6bd1f3ee47bb6ae6263dc8c9f23fcf Mon Sep 17 00:00:00 2001 From: sai Date: Mon, 11 Sep 2023 12:47:48 +0530 Subject: [PATCH 82/94] checking flake 8 --- .github/workflows/testing.yml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 549f214..2cde988 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -40,12 +40,12 @@ jobs: # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics - - name: Analysing the code with pylint - run: | - pylint $(git ls-files 'src/app.py') - - #python code test with pytest - - name: Test with pytest - run: | - export PYTHONPATH=src - pytest + # - name: Analysing the code with pylint + # run: | + # pylint $(git ls-files 'app.py') + + # #python code test with pytest + # - name: Test with pytest + # run: | + # export PYTHONPATH=src + # pytest From f1a8e7bb9028766a5d2b31f6f7159197301b786d Mon Sep 17 00:00:00 2001 From: sai Date: Mon, 11 Sep 2023 13:01:45 +0530 Subject: [PATCH 83/94] changed version of python --- .github/workflows/testing.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 2cde988..2cbdc02 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -12,7 +12,7 @@ jobs: strategy: matrix: - python-version: [3.10] + python-version: [3.15] steps: #Code checkout and python setup From cd52b862b38370742d17dee36bcf6d71f80d927a Mon Sep 17 00:00:00 2001 From: sai Date: Mon, 11 Sep 2023 13:03:24 +0530 Subject: [PATCH 84/94] changed version of python to 3.x --- .github/workflows/testing.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 2cbdc02..9dac2a6 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -12,7 +12,7 @@ jobs: strategy: matrix: - python-version: [3.15] + python-version: [3.x] steps: #Code checkout and python setup @@ -44,8 +44,8 @@ jobs: # run: | # pylint $(git ls-files 'app.py') - # #python code test with pytest - # - name: Test with pytest - # run: | - # export PYTHONPATH=src - # pytest + #python code test with pytest + - name: Test with pytest + run: | + export PYTHONPATH=src + pytest From 6104d6ecf0282974fe588d65553c1ac4a67316bd Mon Sep 17 00:00:00 2001 From: sai Date: Mon, 11 Sep 2023 13:06:32 +0530 Subject: [PATCH 85/94] added pylint --- .github/workflows/testing.yml | 6 +++--- src/app.py | 2 +- tests/test_app.py | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 9dac2a6..cfa4425 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -40,9 +40,9 @@ jobs: # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics - # - name: Analysing the code with pylint - # run: | - # pylint $(git ls-files 'app.py') + - name: Analysing the code with pylint + run: | + pylint $(git ls-files '*.py') #python code test with pytest - name: Test with pytest diff --git a/src/app.py b/src/app.py index 37b6a35..f114533 100644 --- a/src/app.py +++ b/src/app.py @@ -4,7 +4,7 @@ @app.route("/") def index(): - return "Hello Arch world!" + return "Hello, world!" if __name__ == "__main__": diff --git a/tests/test_app.py b/tests/test_app.py index abfa82a..c947e92 100644 --- a/tests/test_app.py +++ b/tests/test_app.py @@ -2,5 +2,5 @@ def test_index(): - assert index() == "Hello, world!" + assert index() == "Hello Arch world!" From 058e629212e315dd63fd4807bd14f542cc19c6d8 Mon Sep 17 00:00:00 2001 From: sai Date: Mon, 11 Sep 2023 13:12:08 +0530 Subject: [PATCH 86/94] added pylint --- .github/workflows/testing.yml | 6 +++--- src/app.py | 4 +++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index cfa4425..e3ab1e5 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -40,9 +40,9 @@ jobs: # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics - - name: Analysing the code with pylint - run: | - pylint $(git ls-files '*.py') + # - name: Analysing the code with pylint + # run: | + # pylint $(git ls-files '*.py') #python code test with pytest - name: Test with pytest diff --git a/src/app.py b/src/app.py index f114533..8d6e8f6 100644 --- a/src/app.py +++ b/src/app.py @@ -1,10 +1,12 @@ from flask import Flask + app = Flask(__name__) + @app.route("/") def index(): - return "Hello, world!" + return "Hello Arch world!" if __name__ == "__main__": From 32bceb0d707efca477c59c3411bcb4e591a2c41d Mon Sep 17 00:00:00 2001 From: sai Date: Mon, 11 Sep 2023 14:07:53 +0530 Subject: [PATCH 87/94] checking lint and pytest --- src/app.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app.py b/src/app.py index 8d6e8f6..7e19864 100644 --- a/src/app.py +++ b/src/app.py @@ -10,4 +10,4 @@ def index(): if __name__ == "__main__": - app.run(host='0.0.0.0') + app.run(host='0.0.0.0') \ No newline at end of file From 0992ac6cb6ef2cbb3568b6985732b1288d9f1c68 Mon Sep 17 00:00:00 2001 From: sai Date: Mon, 11 Sep 2023 16:43:07 +0530 Subject: [PATCH 88/94] checking pylint --- .github/workflows/testing.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index e3ab1e5..8fd828a 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -39,10 +39,11 @@ jobs: flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics - - # - name: Analysing the code with pylint - # run: | - # pylint $(git ls-files '*.py') + + #Python code linting with pylint + - name: Analysing the code with pylint + run: | + pylint $(git ls-files '*.py') #python code test with pytest - name: Test with pytest From fd8a725649da9794db24c7f2c5c2f70361ec8bd1 Mon Sep 17 00:00:00 2001 From: sai Date: Mon, 11 Sep 2023 16:50:25 +0530 Subject: [PATCH 89/94] checking pylint after fixing the issue --- .github/workflows/testing.yml | 2 +- src/app.py | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 8fd828a..d1bd6a1 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -43,7 +43,7 @@ jobs: #Python code linting with pylint - name: Analysing the code with pylint run: | - pylint $(git ls-files '*.py') + pylint $(git ls-files 'app.py') #python code test with pytest - name: Test with pytest diff --git a/src/app.py b/src/app.py index 7e19864..badcf73 100644 --- a/src/app.py +++ b/src/app.py @@ -1,3 +1,6 @@ +'''This is a module-level docstring that describes the purpose of the app.py module.''' + + from flask import Flask @@ -6,8 +9,9 @@ @app.route("/") def index(): + '''This is a module-level docstring that describes the purpose of the app.py module.''' return "Hello Arch world!" if __name__ == "__main__": - app.run(host='0.0.0.0') \ No newline at end of file + app.run(host='0.0.0.0') From 7d7c0ebeb839394d55d97fd89920a8fb1cffa96c Mon Sep 17 00:00:00 2001 From: sai Date: Mon, 11 Sep 2023 16:53:22 +0530 Subject: [PATCH 90/94] edited test --- .github/workflows/testing.yml | 2 +- tests/test_app.py | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index d1bd6a1..8fd828a 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -43,7 +43,7 @@ jobs: #Python code linting with pylint - name: Analysing the code with pylint run: | - pylint $(git ls-files 'app.py') + pylint $(git ls-files '*.py') #python code test with pytest - name: Test with pytest diff --git a/tests/test_app.py b/tests/test_app.py index c947e92..f1e08c5 100644 --- a/tests/test_app.py +++ b/tests/test_app.py @@ -1,6 +1,9 @@ +'''This is a module-level docstring that describes the purpose of the app.py module.''' + + from app import index def test_index(): + '''This is a module-level docstring that describes the purpose of the app.py module.''' assert index() == "Hello Arch world!" - From 39da61c6fa214a791a38847a946ce7976085062c Mon Sep 17 00:00:00 2001 From: sai Date: Mon, 11 Sep 2023 17:01:38 +0530 Subject: [PATCH 91/94] checking pylint true --- .github/workflows/testing.yml | 2 +- src/app.py | 1 - tests/test_app.py | 4 ++-- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 8fd828a..5d6515a 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -43,7 +43,7 @@ jobs: #Python code linting with pylint - name: Analysing the code with pylint run: | - pylint $(git ls-files '*.py') + pylint $(git ls-files '*.py') || true #python code test with pytest - name: Test with pytest diff --git a/src/app.py b/src/app.py index badcf73..619b248 100644 --- a/src/app.py +++ b/src/app.py @@ -9,7 +9,6 @@ @app.route("/") def index(): - '''This is a module-level docstring that describes the purpose of the app.py module.''' return "Hello Arch world!" diff --git a/tests/test_app.py b/tests/test_app.py index f1e08c5..a7fe235 100644 --- a/tests/test_app.py +++ b/tests/test_app.py @@ -1,9 +1,9 @@ -'''This is a module-level docstring that describes the purpose of the app.py module.''' +'''This is a module-level docstring that describes the purpose of the test_app.py module.''' from app import index def test_index(): - '''This is a module-level docstring that describes the purpose of the app.py module.''' + '''This is a docstring that describes the test_index function.''' assert index() == "Hello Arch world!" From 520bafe84533dc3c1ad5701963b66cb9f2f950ab Mon Sep 17 00:00:00 2001 From: sai Date: Fri, 15 Sep 2023 17:42:55 +0530 Subject: [PATCH 92/94] added new pipeline for test --- .github/workflows/test_scan.yml | 70 +++++++++++++++++++++++++++++++++ manifests/deployment.yml | 2 +- manifests/ingress.yml | 2 +- 3 files changed, 72 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/test_scan.yml diff --git a/.github/workflows/test_scan.yml b/.github/workflows/test_scan.yml new file mode 100644 index 0000000..dd654f9 --- /dev/null +++ b/.github/workflows/test_scan.yml @@ -0,0 +1,70 @@ +name: Pull Request - Build, Test, & Scan + +on: + push + +jobs: + build-test: + name: Build and Test + runs-on: ubuntu-latest + strategy: + matrix: + python-version: [3.7, 3.8] + + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install flake8 pytest + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + - name: Lint with flake8 + run: | + # stop the build if there are Python syntax errors or undefined names + flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics + # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide + flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + - name: Test with pytest + run: | + pytest + + lint: + name: Lint Codebase + runs-on: ubuntu-latest + steps: + - name: Check out Git repository + uses: actions/checkout@v2 + + - name: Set up Python + uses: actions/setup-python@v1 + with: + python-version: 3.8 + + - name: Install Python dependencies + run: pip install black flake8 + + - name: Run linters + uses: wearerequired/lint-action@v1 + with: + flake8: true + + build-scan-image: + name: Build and Scan Container + runs-on: ubuntu-latest + needs: [lint, build-test] + steps: + - uses: actions/checkout@v1 + + - name: Build docker image + run: | + docker build -t my-app:${{ github.sha }} . + - name: Scan container image + uses: Azure/container-scan@v0 + with: + image-name: my-app:${{ github.sha }} + severity-threshold: CRITICAL + run-quality-checks: false \ No newline at end of file diff --git a/manifests/deployment.yml b/manifests/deployment.yml index 6d98d92..edd087a 100644 --- a/manifests/deployment.yml +++ b/manifests/deployment.yml @@ -14,7 +14,7 @@ spec: spec: containers: - name: python-app - image: myacr108.azurecr.io/my-container + image: myacr.azurecr.io/my-container imagePullPolicy: Always resources: limits: diff --git a/manifests/ingress.yml b/manifests/ingress.yml index 1e44271..56bcfe0 100644 --- a/manifests/ingress.yml +++ b/manifests/ingress.yml @@ -6,7 +6,7 @@ metadata: name: python-app spec: rules: - - host: + - host: http: paths: - pathType: Prefix From 1bb594994cfcf968e80ec3e1d111536dc6cd13fd Mon Sep 17 00:00:00 2001 From: sai Date: Fri, 15 Sep 2023 17:49:11 +0530 Subject: [PATCH 93/94] added pytest path --- .github/workflows/test_scan.yml | 4 ++++ .github/workflows/testing.yml | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test_scan.yml b/.github/workflows/test_scan.yml index dd654f9..3f6f418 100644 --- a/.github/workflows/test_scan.yml +++ b/.github/workflows/test_scan.yml @@ -17,19 +17,23 @@ jobs: uses: actions/setup-python@v2 with: python-version: ${{ matrix.python-version }} + - name: Install dependencies run: | python -m pip install --upgrade pip pip install flake8 pytest if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + - name: Lint with flake8 run: | # stop the build if there are Python syntax errors or undefined names flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + - name: Test with pytest run: | + export PYTHONPATH=src pytest lint: diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 5d6515a..6cc3470 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -1,6 +1,7 @@ name: Python application Testing -on: push +on: + workflow_dispatch permissions: contents: read From 0dcbfb1715626a21c2bac93905196dec6ab6120a Mon Sep 17 00:00:00 2001 From: saidinkar <60877278+saidinkar@users.noreply.github.com> Date: Tue, 10 Oct 2023 12:58:55 +0530 Subject: [PATCH 94/94] Update Azure_servcie_connection.md --- Azure_servcie_connection.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Azure_servcie_connection.md b/Azure_servcie_connection.md index 6b498b1..cc5f30f 100644 --- a/Azure_servcie_connection.md +++ b/Azure_servcie_connection.md @@ -6,7 +6,7 @@ The quickest way and easiest way to create this Service Principal is to use Azur az ad sp create-for-rbac \ --name "myAzureServiceGitHubConnection" \ --role contributor \ - --scopes /subscriptions/e94972e2-c0eb-497c-8f74-f98b46621f80/resourceGroups/sai-arch \ + --scopes /subscriptions/{subscription-ID}/resourceGroups/{RG-name} \ --sdk-auth ``` @@ -47,4 +47,4 @@ Within the repository where your workflow is, click on Settings > Secrets > Acti "clientSecret": "xxxxxxxxxxxxxxxxxxxxxxxxxxxx", "subscriptionId": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", "tenantId": "xxxxxxxxxxxxxxxxxxxxxxxxxxxx" -}``` \ No newline at end of file +}```