From 64783179a8aff38a10ebc59cfd1acab8f279079d Mon Sep 17 00:00:00 2001 From: Vitor da Costa Silva Date: Fri, 10 Nov 2023 23:44:09 -0300 Subject: [PATCH 01/53] feat: Add Dockerfile, docker-compose.yaml and Makefile --- projeto-fsharp/Dockerfile | 15 +++++++++++++++ projeto-fsharp/Makefile | 9 +++++++++ projeto-fsharp/docker-compose.yaml | 11 +++++++++++ 3 files changed, 35 insertions(+) create mode 100644 projeto-fsharp/Dockerfile create mode 100644 projeto-fsharp/Makefile create mode 100644 projeto-fsharp/docker-compose.yaml diff --git a/projeto-fsharp/Dockerfile b/projeto-fsharp/Dockerfile new file mode 100644 index 0000000..0794cc0 --- /dev/null +++ b/projeto-fsharp/Dockerfile @@ -0,0 +1,15 @@ +FROM mcr.microsoft.com/dotnet/sdk:6.0.413 AS builder +#Criando um diretório específico dentro do container para melhor organização +WORKDIR /api +COPY . . +#Restaurando os pacotes necessários para executar o projeto e Buildando. +RUN ./restore.sh && \ + dotnet fake run build.fsx -t "Build" + +#Iniciando Server. (Multistaging) +FROM mcr.microsoft.com/dotnet/aspnet:6.0.0 AS runtime +WORKDIR /api +EXPOSE 8085 +COPY --from=builder /api/src/Server/out /api +#Comando para iniciar o servidor +CMD ./Server \ No newline at end of file diff --git a/projeto-fsharp/Makefile b/projeto-fsharp/Makefile new file mode 100644 index 0000000..b62482f --- /dev/null +++ b/projeto-fsharp/Makefile @@ -0,0 +1,9 @@ +build: + @docker build -t vitorcostasilva/api-devops-challenge:1.0 . + +run: + @docker run -d -p 8085:8085 --name api-devops-challenge vitorcostasilva/api-devops-challenge:1.0 + +compose: + @docker compose build + @docker compose up \ No newline at end of file diff --git a/projeto-fsharp/docker-compose.yaml b/projeto-fsharp/docker-compose.yaml new file mode 100644 index 0000000..a2d9d50 --- /dev/null +++ b/projeto-fsharp/docker-compose.yaml @@ -0,0 +1,11 @@ +version: "3.8" + +services: + api-devops-challenge: + image: vitorcostasilva/api-devops-challenge:1.0 + # build: + # context: . + # restart: always + container_name: api-devops-challenge + ports: + - 8085:8085 \ No newline at end of file From 8ef8deb1d20901a3b60c45b188f0aaf5a056c689 Mon Sep 17 00:00:00 2001 From: Vitor Costa <56806562+vitor-csilva@users.noreply.github.com> Date: Sat, 11 Nov 2023 00:52:32 -0300 Subject: [PATCH 02/53] pipeline.yml --- .github/workflows/blank.yml | 38 +++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 .github/workflows/blank.yml diff --git a/.github/workflows/blank.yml b/.github/workflows/blank.yml new file mode 100644 index 0000000..27bf578 --- /dev/null +++ b/.github/workflows/blank.yml @@ -0,0 +1,38 @@ +# This is a basic workflow to help you get started with Actions + +name: Build and Push Image + +on: + # Triggers the workflow on push or pull request events but only for the "master" branch + push: + branches: [ "master" ] + +env: + REGISTRY: ghcr.io + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + build-and-push-image: + runs-on: ubuntu-latest + + permissions: + contents: read + packages: write + + # Steps represent a sequence of tasks that will be executed as part of the job + steps: + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + - name: Realizando checkout do repositório + uses: actions/checkout@v4 + + - name: Log in no GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build e push Docker image + run: | + docker build . --tag ghcr.io/vitor-csilva/api-devops-challenge:latest + docker push ghcr.io/vitor-csilva/api-devops-challenge:latest From 5e5f26aebb54d6832c05e01ee290fed8e113a419 Mon Sep 17 00:00:00 2001 From: Vitor da Costa Silva Date: Sat, 11 Nov 2023 00:59:33 -0300 Subject: [PATCH 03/53] fix: Bug git actions --- .github/workflows/blank.yml | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/workflows/blank.yml b/.github/workflows/blank.yml index 27bf578..4e2bce9 100644 --- a/.github/workflows/blank.yml +++ b/.github/workflows/blank.yml @@ -31,8 +31,12 @@ jobs: registry: ${{ env.REGISTRY }} username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - - name: Build e push Docker image + + - name: teste run: | - docker build . --tag ghcr.io/vitor-csilva/api-devops-challenge:latest - docker push ghcr.io/vitor-csilva/api-devops-challenge:latest + ls -la + + # - name: Build e push Docker image + # run: | + # docker build . --tag ghcr.io/vitor-csilva/api-devops-challenge:latest + # docker push ghcr.io/vitor-csilva/api-devops-challenge:latest From daa4491c1599c71025273dfcdad90552ac424382 Mon Sep 17 00:00:00 2001 From: Vitor da Costa Silva Date: Sat, 11 Nov 2023 01:09:21 -0300 Subject: [PATCH 04/53] fix: Bug 2 git actions --- .github/workflows/blank.yml | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/.github/workflows/blank.yml b/.github/workflows/blank.yml index 4e2bce9..16e7488 100644 --- a/.github/workflows/blank.yml +++ b/.github/workflows/blank.yml @@ -31,12 +31,9 @@ jobs: registry: ${{ env.REGISTRY }} username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - - name: teste - run: | - ls -la - # - name: Build e push Docker image - # run: | - # docker build . --tag ghcr.io/vitor-csilva/api-devops-challenge:latest - # docker push ghcr.io/vitor-csilva/api-devops-challenge:latest + - name: Build e push Docker image + run: | + cd projeto-fsharp + docker build . --tag ghcr.io/vitor-csilva/api-devops-challenge:latest + docker push ghcr.io/vitor-csilva/api-devops-challenge:latest From bf42f05ef68398dde83b5835a2303c947c2b6048 Mon Sep 17 00:00:00 2001 From: Vitor da Costa Silva Date: Sat, 11 Nov 2023 11:18:21 -0300 Subject: [PATCH 05/53] fix: Define docker platform git actions --- .github/workflows/blank.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/blank.yml b/.github/workflows/blank.yml index 16e7488..9f534f8 100644 --- a/.github/workflows/blank.yml +++ b/.github/workflows/blank.yml @@ -35,5 +35,6 @@ jobs: - name: Build e push Docker image run: | cd projeto-fsharp + export DOCKER_DEFAULT_PLATFORM=linux/arm64 docker build . --tag ghcr.io/vitor-csilva/api-devops-challenge:latest docker push ghcr.io/vitor-csilva/api-devops-challenge:latest From eedd940da459e0e42e95821fab3b9af0baf833be Mon Sep 17 00:00:00 2001 From: Vitor da Costa Silva Date: Sat, 11 Nov 2023 11:34:48 -0300 Subject: [PATCH 06/53] fix: Define docker platform git actions 2 --- .github/workflows/blank.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/blank.yml b/.github/workflows/blank.yml index 9f534f8..e2488ef 100644 --- a/.github/workflows/blank.yml +++ b/.github/workflows/blank.yml @@ -10,6 +10,7 @@ on: env: REGISTRY: ghcr.io + # A workflow run is made up of one or more jobs that can run sequentially or in parallel jobs: build-and-push-image: @@ -34,7 +35,7 @@ jobs: - name: Build e push Docker image run: | - cd projeto-fsharp - export DOCKER_DEFAULT_PLATFORM=linux/arm64 - docker build . --tag ghcr.io/vitor-csilva/api-devops-challenge:latest - docker push ghcr.io/vitor-csilva/api-devops-challenge:latest + cd projeto-fsharp + docker buildx create --use + docker buildx build --platform linux/arm64 --tag ghcr.io/vitor-csilva/api-devops-challenge:latest . + docker push ghcr.io/vitor-csilva/api-devops-challenge:latest From 5ab1f4437b4cc0fbde35bb56cba0b14341a41ba4 Mon Sep 17 00:00:00 2001 From: Vitor da Costa Silva Date: Sat, 11 Nov 2023 11:38:46 -0300 Subject: [PATCH 07/53] fix: Return docker platform amd64 git actions --- .github/workflows/blank.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/blank.yml b/.github/workflows/blank.yml index e2488ef..5dea057 100644 --- a/.github/workflows/blank.yml +++ b/.github/workflows/blank.yml @@ -36,6 +36,5 @@ jobs: - name: Build e push Docker image run: | cd projeto-fsharp - docker buildx create --use - docker buildx build --platform linux/arm64 --tag ghcr.io/vitor-csilva/api-devops-challenge:latest . + docker build . --tag ghcr.io/vitor-csilva/api-devops-challenge:latest docker push ghcr.io/vitor-csilva/api-devops-challenge:latest From 97c72211ffc2e2800922684635986deb28261c5c Mon Sep 17 00:00:00 2001 From: Vitor Costa <56806562+vitor-csilva@users.noreply.github.com> Date: Sat, 11 Nov 2023 11:48:09 -0300 Subject: [PATCH 08/53] feat: Create pipeline-arm.yml --- .github/workflows/pipeline-arm.yml | 44 ++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 .github/workflows/pipeline-arm.yml diff --git a/.github/workflows/pipeline-arm.yml b/.github/workflows/pipeline-arm.yml new file mode 100644 index 0000000..c5439fd --- /dev/null +++ b/.github/workflows/pipeline-arm.yml @@ -0,0 +1,44 @@ +# This is a basic workflow to help you get started with Actions + +name: Build and Push Image platform ARM + +on: + # Triggers the workflow on push or pull request events but only for the "master" branch + push: + branches: [ "master" ] + +env: + REGISTRY: ghcr.io + + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + build-and-push-image: + runs-on: ubuntu-latest + + permissions: + contents: read + packages: write + + # Steps represent a sequence of tasks that will be executed as part of the job + steps: + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + - name: Realizando checkout do repositório + uses: actions/checkout@v4 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Log in no GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build e push Docker image + run: | + cd projeto-fsharp + docker buildx create --use + docker buildx build --platform linux/amd64,linux/arm64 -t ghcr.io/vitor-csilva/api-devops-challenge:latest . + docker push ghcr.io/vitor-csilva/api-devops-challenge:latest From 52d5edfcfde174d3876a16c6d6fae9be3f4759d5 Mon Sep 17 00:00:00 2001 From: Vitor da Costa Silva Date: Sat, 11 Nov 2023 12:03:52 -0300 Subject: [PATCH 09/53] fix: Change Docker platform pipeline-arm.yml --- projeto-fsharp/Dockerfile | 7 +++++-- projeto-fsharp/Makefile | 1 + 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/projeto-fsharp/Dockerfile b/projeto-fsharp/Dockerfile index 0794cc0..e95494a 100644 --- a/projeto-fsharp/Dockerfile +++ b/projeto-fsharp/Dockerfile @@ -3,8 +3,11 @@ FROM mcr.microsoft.com/dotnet/sdk:6.0.413 AS builder WORKDIR /api COPY . . #Restaurando os pacotes necessários para executar o projeto e Buildando. -RUN ./restore.sh && \ - dotnet fake run build.fsx -t "Build" +RUN echo 'source https://www.nuget.org/api/v2' > paket.dependencies \ + && echo 'nuget FAKE' >> paket.dependencies \ + && echo 'nuget FSharp.Core ' >> paket.dependencies \ + && ./restore.sh && \ + && dotnet fake run build.fsx -t "Build" #Iniciando Server. (Multistaging) FROM mcr.microsoft.com/dotnet/aspnet:6.0.0 AS runtime diff --git a/projeto-fsharp/Makefile b/projeto-fsharp/Makefile index b62482f..98a05f8 100644 --- a/projeto-fsharp/Makefile +++ b/projeto-fsharp/Makefile @@ -5,5 +5,6 @@ run: @docker run -d -p 8085:8085 --name api-devops-challenge vitorcostasilva/api-devops-challenge:1.0 compose: + #export DOCKER_DEFAULT_PLATFORM=linux/arm64 @docker compose build @docker compose up \ No newline at end of file From 4fc2992ab5a67d169aa0fb4ee985a128aa2ac830 Mon Sep 17 00:00:00 2001 From: Vitor da Costa Silva Date: Sat, 11 Nov 2023 12:06:03 -0300 Subject: [PATCH 10/53] fix: Change Dockerfile --- projeto-fsharp/Dockerfile | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/projeto-fsharp/Dockerfile b/projeto-fsharp/Dockerfile index e95494a..0794cc0 100644 --- a/projeto-fsharp/Dockerfile +++ b/projeto-fsharp/Dockerfile @@ -3,11 +3,8 @@ FROM mcr.microsoft.com/dotnet/sdk:6.0.413 AS builder WORKDIR /api COPY . . #Restaurando os pacotes necessários para executar o projeto e Buildando. -RUN echo 'source https://www.nuget.org/api/v2' > paket.dependencies \ - && echo 'nuget FAKE' >> paket.dependencies \ - && echo 'nuget FSharp.Core ' >> paket.dependencies \ - && ./restore.sh && \ - && dotnet fake run build.fsx -t "Build" +RUN ./restore.sh && \ + dotnet fake run build.fsx -t "Build" #Iniciando Server. (Multistaging) FROM mcr.microsoft.com/dotnet/aspnet:6.0.0 AS runtime From 6776756d02f7a1792a836c93806fb10f3703e093 Mon Sep 17 00:00:00 2001 From: Vitor da Costa Silva Date: Sat, 11 Nov 2023 12:16:47 -0300 Subject: [PATCH 11/53] fix: Change pipeline-arm.yaml --- .github/workflows/pipeline-arm.yml | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/.github/workflows/pipeline-arm.yml b/.github/workflows/pipeline-arm.yml index c5439fd..d59231c 100644 --- a/.github/workflows/pipeline-arm.yml +++ b/.github/workflows/pipeline-arm.yml @@ -14,7 +14,7 @@ env: # A workflow run is made up of one or more jobs that can run sequentially or in parallel jobs: build-and-push-image: - runs-on: ubuntu-latest + runs-on: macos-latest permissions: contents: read @@ -35,10 +35,16 @@ jobs: registry: ${{ env.REGISTRY }} username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - + - name: Build e push Docker image run: | cd projeto-fsharp - docker buildx create --use - docker buildx build --platform linux/amd64,linux/arm64 -t ghcr.io/vitor-csilva/api-devops-challenge:latest . - docker push ghcr.io/vitor-csilva/api-devops-challenge:latest + docker build . --tag ghcr.io/vitor-csilva/api-devops-challenge:arm + docker push ghcr.io/vitor-csilva/api-devops-challenge:arm + + # - name: Build e push Docker image + # run: | + # cd projeto-fsharp + # docker buildx create --use + # docker buildx build --platform linux/amd64,linux/arm64 -t ghcr.io/vitor-csilva/api-devops-challenge:latest . + # docker push ghcr.io/vitor-csilva/api-devops-challenge:latest From 59c6b715a51b0cc6832b1397fd6fa4e0e762ee93 Mon Sep 17 00:00:00 2001 From: Vitor da Costa Silva Date: Sat, 11 Nov 2023 12:23:52 -0300 Subject: [PATCH 12/53] fix: Change 3 pipeline-arm.yml --- .github/workflows/pipeline-arm.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pipeline-arm.yml b/.github/workflows/pipeline-arm.yml index d59231c..27efbde 100644 --- a/.github/workflows/pipeline-arm.yml +++ b/.github/workflows/pipeline-arm.yml @@ -26,8 +26,8 @@ jobs: - name: Realizando checkout do repositório uses: actions/checkout@v4 - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 + # - name: Set up QEMU + # uses: docker/setup-qemu-action@v3 - name: Log in no GitHub Container Registry uses: docker/login-action@v3 From 5f7ecfa87b5cbcbced73e36b867ff824569588ee Mon Sep 17 00:00:00 2001 From: Vitor da Costa Silva Date: Sat, 11 Nov 2023 12:33:29 -0300 Subject: [PATCH 13/53] fix: Change 4 pipeline-arm.yml --- .github/workflows/pipeline-arm.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/pipeline-arm.yml b/.github/workflows/pipeline-arm.yml index 27efbde..3130ae8 100644 --- a/.github/workflows/pipeline-arm.yml +++ b/.github/workflows/pipeline-arm.yml @@ -26,6 +26,9 @@ jobs: - name: Realizando checkout do repositório uses: actions/checkout@v4 + - name: Set up Docker + uses: docker/setup-docker@v2 + # - name: Set up QEMU # uses: docker/setup-qemu-action@v3 From 875090905ee1b3801cbf816abbd2543a389ee0f8 Mon Sep 17 00:00:00 2001 From: Vitor da Costa Silva Date: Sat, 11 Nov 2023 12:49:00 -0300 Subject: [PATCH 14/53] fix: Change 5 pipeline-arm.yml --- .github/workflows/pipeline-arm.yml | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/.github/workflows/pipeline-arm.yml b/.github/workflows/pipeline-arm.yml index 3130ae8..3062f6f 100644 --- a/.github/workflows/pipeline-arm.yml +++ b/.github/workflows/pipeline-arm.yml @@ -14,7 +14,7 @@ env: # A workflow run is made up of one or more jobs that can run sequentially or in parallel jobs: build-and-push-image: - runs-on: macos-latest + runs-on: ubuntu-latest permissions: contents: read @@ -39,15 +39,16 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} + # - name: Build e push Docker image + # run: | + # cd projeto-fsharp + # docker build . --tag ghcr.io/vitor-csilva/api-devops-challenge:arm + # docker push ghcr.io/vitor-csilva/api-devops-challenge:arm + - name: Build e push Docker image run: | cd projeto-fsharp - docker build . --tag ghcr.io/vitor-csilva/api-devops-challenge:arm + docker buildx create --name mybuilder + docker buildx use mybuilder + docker buildx build --platform linux/arm64 -t ghcr.io/vitor-csilva/api-devops-challenge:arm . docker push ghcr.io/vitor-csilva/api-devops-challenge:arm - - # - name: Build e push Docker image - # run: | - # cd projeto-fsharp - # docker buildx create --use - # docker buildx build --platform linux/amd64,linux/arm64 -t ghcr.io/vitor-csilva/api-devops-challenge:latest . - # docker push ghcr.io/vitor-csilva/api-devops-challenge:latest From 84ffd49ca11c72acacc734bc27510b1080909acd Mon Sep 17 00:00:00 2001 From: Vitor da Costa Silva Date: Sat, 11 Nov 2023 12:50:03 -0300 Subject: [PATCH 15/53] fix: Change 6 pipeline-arm.yml --- .github/workflows/pipeline-arm.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pipeline-arm.yml b/.github/workflows/pipeline-arm.yml index 3062f6f..8f25dcb 100644 --- a/.github/workflows/pipeline-arm.yml +++ b/.github/workflows/pipeline-arm.yml @@ -26,8 +26,8 @@ jobs: - name: Realizando checkout do repositório uses: actions/checkout@v4 - - name: Set up Docker - uses: docker/setup-docker@v2 + # - name: Set up Docker + # uses: docker/setup-docker@v2 # - name: Set up QEMU # uses: docker/setup-qemu-action@v3 From 012aa6364e1e7b59dd0fcc7ec333946f54dca1a9 Mon Sep 17 00:00:00 2001 From: Vitor da Costa Silva Date: Sat, 11 Nov 2023 12:54:12 -0300 Subject: [PATCH 16/53] fix: Change 6 pipeline-arm.yml --- .github/workflows/pipeline-arm.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pipeline-arm.yml b/.github/workflows/pipeline-arm.yml index 8f25dcb..db69390 100644 --- a/.github/workflows/pipeline-arm.yml +++ b/.github/workflows/pipeline-arm.yml @@ -29,8 +29,8 @@ jobs: # - name: Set up Docker # uses: docker/setup-docker@v2 - # - name: Set up QEMU - # uses: docker/setup-qemu-action@v3 + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 - name: Log in no GitHub Container Registry uses: docker/login-action@v3 From 2671bccafe05cb35422aa7759d772ee190ff4ccc Mon Sep 17 00:00:00 2001 From: Vitor da Costa Silva Date: Sat, 11 Nov 2023 13:09:29 -0300 Subject: [PATCH 17/53] fix: Change 7 pipeline-arm.yml --- .github/workflows/pipeline-arm.yml | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/.github/workflows/pipeline-arm.yml b/.github/workflows/pipeline-arm.yml index db69390..5e8b681 100644 --- a/.github/workflows/pipeline-arm.yml +++ b/.github/workflows/pipeline-arm.yml @@ -25,19 +25,21 @@ jobs: # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - name: Realizando checkout do repositório uses: actions/checkout@v4 - - # - name: Set up Docker - # uses: docker/setup-docker@v2 - - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - + - name: Log in no GitHub Container Registry uses: docker/login-action@v3 with: registry: ${{ env.REGISTRY }} username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + # - name: Set up QEMU + # uses: tonistiigi/binfmt@v3 + # with: + # registry: ghcr.io + # - name: Build e push Docker image # run: | From 4f26d49ece88e35f81bfaba3ba41b336e111fa8f Mon Sep 17 00:00:00 2001 From: Vitor da Costa Silva Date: Sat, 11 Nov 2023 13:12:12 -0300 Subject: [PATCH 18/53] fix: Change 8 pipeline-arm.yml --- .github/workflows/pipeline-arm.yml | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/.github/workflows/pipeline-arm.yml b/.github/workflows/pipeline-arm.yml index 5e8b681..0e4801a 100644 --- a/.github/workflows/pipeline-arm.yml +++ b/.github/workflows/pipeline-arm.yml @@ -25,21 +25,20 @@ jobs: # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - name: Realizando checkout do repositório uses: actions/checkout@v4 - + + # - name: Set up QEMU + # uses: docker/setup-qemu-action@v3 + - name: Set up QEMU + uses: tonistiigi/binfmt@v3 + with: + registry: ghcr.io + - name: Log in no GitHub Container Registry uses: docker/login-action@v3 with: registry: ${{ env.REGISTRY }} username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - # - name: Set up QEMU - # uses: tonistiigi/binfmt@v3 - # with: - # registry: ghcr.io - # - name: Build e push Docker image # run: | From 1cc36fdc8a346dd03197e4e6fd19da0d2bd0346d Mon Sep 17 00:00:00 2001 From: Vitor da Costa Silva Date: Sat, 11 Nov 2023 13:19:36 -0300 Subject: [PATCH 19/53] fix: Change 9 pipeline-arm.yml --- .github/workflows/pipeline-arm.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/pipeline-arm.yml b/.github/workflows/pipeline-arm.yml index 0e4801a..618cc78 100644 --- a/.github/workflows/pipeline-arm.yml +++ b/.github/workflows/pipeline-arm.yml @@ -29,9 +29,7 @@ jobs: # - name: Set up QEMU # uses: docker/setup-qemu-action@v3 - name: Set up QEMU - uses: tonistiigi/binfmt@v3 - with: - registry: ghcr.io + uses: tonistiigi/binfmt@master - name: Log in no GitHub Container Registry uses: docker/login-action@v3 From c729c4d6f2bbebba7b4d350052eb31834e196a6a Mon Sep 17 00:00:00 2001 From: Vitor da Costa Silva Date: Sat, 11 Nov 2023 13:31:13 -0300 Subject: [PATCH 20/53] fix: Change 10 pipeline-arm.yml --- .github/workflows/pipeline-arm.yml | 35 +++++++++++++++--------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/.github/workflows/pipeline-arm.yml b/.github/workflows/pipeline-arm.yml index 618cc78..46761cd 100644 --- a/.github/workflows/pipeline-arm.yml +++ b/.github/workflows/pipeline-arm.yml @@ -26,17 +26,18 @@ jobs: - name: Realizando checkout do repositório uses: actions/checkout@v4 + - name: Docker Setup QEMU + uses: docker/setup-qemu-action@v3.0.0 + # - name: Set up QEMU - # uses: docker/setup-qemu-action@v3 - - name: Set up QEMU - uses: tonistiigi/binfmt@master - - - name: Log in no GitHub Container Registry - uses: docker/login-action@v3 - with: - registry: ${{ env.REGISTRY }} - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} + # uses: tonistiigi/binfmt@master + + # - name: Log in no GitHub Container Registry + # uses: docker/login-action@v3 + # with: + # registry: ${{ env.REGISTRY }} + # username: ${{ github.actor }} + # password: ${{ secrets.GITHUB_TOKEN }} # - name: Build e push Docker image # run: | @@ -44,10 +45,10 @@ jobs: # docker build . --tag ghcr.io/vitor-csilva/api-devops-challenge:arm # docker push ghcr.io/vitor-csilva/api-devops-challenge:arm - - name: Build e push Docker image - run: | - cd projeto-fsharp - docker buildx create --name mybuilder - docker buildx use mybuilder - docker buildx build --platform linux/arm64 -t ghcr.io/vitor-csilva/api-devops-challenge:arm . - docker push ghcr.io/vitor-csilva/api-devops-challenge:arm + # - name: Build e push Docker image + # run: | + # cd projeto-fsharp + # docker buildx create --name mybuilder + # docker buildx use mybuilder + # docker buildx build --platform linux/arm64 -t ghcr.io/vitor-csilva/api-devops-challenge:arm . + # docker push ghcr.io/vitor-csilva/api-devops-challenge:arm From f7e230030d222a5ea7c19efadfb2f11721bb2ade Mon Sep 17 00:00:00 2001 From: Vitor da Costa Silva Date: Sat, 11 Nov 2023 13:37:53 -0300 Subject: [PATCH 21/53] fix: Change 11 pipeline-arm.yml --- .github/workflows/pipeline-arm.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pipeline-arm.yml b/.github/workflows/pipeline-arm.yml index 46761cd..08df4e1 100644 --- a/.github/workflows/pipeline-arm.yml +++ b/.github/workflows/pipeline-arm.yml @@ -27,7 +27,7 @@ jobs: uses: actions/checkout@v4 - name: Docker Setup QEMU - uses: docker/setup-qemu-action@v3.0.0 + uses: docker/setup-qemu-action@v1 # - name: Set up QEMU # uses: tonistiigi/binfmt@master From a6d69bb2380b65e6587b02d041139244f7a44348 Mon Sep 17 00:00:00 2001 From: Vitor da Costa Silva Date: Sat, 11 Nov 2023 13:49:58 -0300 Subject: [PATCH 22/53] fix: Change 12 pipeline-arm.yml --- .github/workflows/pipeline-arm.yml | 41 +++++++++++++++--------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/.github/workflows/pipeline-arm.yml b/.github/workflows/pipeline-arm.yml index 08df4e1..224b7b7 100644 --- a/.github/workflows/pipeline-arm.yml +++ b/.github/workflows/pipeline-arm.yml @@ -27,28 +27,29 @@ jobs: uses: actions/checkout@v4 - name: Docker Setup QEMU - uses: docker/setup-qemu-action@v1 - + uses: docker/setup-qemu-action@v3 + with: + platforms: all # - name: Set up QEMU # uses: tonistiigi/binfmt@master - # - name: Log in no GitHub Container Registry - # uses: docker/login-action@v3 - # with: - # registry: ${{ env.REGISTRY }} - # username: ${{ github.actor }} - # password: ${{ secrets.GITHUB_TOKEN }} + - name: Log in no GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} - # - name: Build e push Docker image - # run: | - # cd projeto-fsharp - # docker build . --tag ghcr.io/vitor-csilva/api-devops-challenge:arm - # docker push ghcr.io/vitor-csilva/api-devops-challenge:arm + - name: Build e push Docker image + run: | + cd projeto-fsharp + docker build . --tag ghcr.io/vitor-csilva/api-devops-challenge:arm + docker push ghcr.io/vitor-csilva/api-devops-challenge:arm - # - name: Build e push Docker image - # run: | - # cd projeto-fsharp - # docker buildx create --name mybuilder - # docker buildx use mybuilder - # docker buildx build --platform linux/arm64 -t ghcr.io/vitor-csilva/api-devops-challenge:arm . - # docker push ghcr.io/vitor-csilva/api-devops-challenge:arm + - name: Build e push Docker image + run: | + cd projeto-fsharp + docker buildx create --name mybuilder + docker buildx use mybuilder + docker buildx build --platform linux/arm64 -t ghcr.io/vitor-csilva/api-devops-challenge:arm . + docker push ghcr.io/vitor-csilva/api-devops-challenge:arm From 7cd4d465944ded4aaeb32c8f3f4f0c593734b452 Mon Sep 17 00:00:00 2001 From: Vitor da Costa Silva Date: Sat, 11 Nov 2023 13:54:26 -0300 Subject: [PATCH 23/53] fix: Change 13 pipeline-arm.yml --- .github/workflows/pipeline-arm.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/pipeline-arm.yml b/.github/workflows/pipeline-arm.yml index 224b7b7..05cbdbe 100644 --- a/.github/workflows/pipeline-arm.yml +++ b/.github/workflows/pipeline-arm.yml @@ -27,9 +27,7 @@ jobs: uses: actions/checkout@v4 - name: Docker Setup QEMU - uses: docker/setup-qemu-action@v3 - with: - platforms: all + uses: crazy-max/ghaction-docker-buildx@v3 # - name: Set up QEMU # uses: tonistiigi/binfmt@master From cb59510c416f3e9e837dff1c32b1de572cdd18fd Mon Sep 17 00:00:00 2001 From: Vitor da Costa Silva Date: Sat, 11 Nov 2023 13:57:11 -0300 Subject: [PATCH 24/53] fix: Change 14 pipeline-arm.yml --- .github/workflows/pipeline-arm.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.github/workflows/pipeline-arm.yml b/.github/workflows/pipeline-arm.yml index 05cbdbe..89d742a 100644 --- a/.github/workflows/pipeline-arm.yml +++ b/.github/workflows/pipeline-arm.yml @@ -37,12 +37,6 @@ jobs: registry: ${{ env.REGISTRY }} username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - - name: Build e push Docker image - run: | - cd projeto-fsharp - docker build . --tag ghcr.io/vitor-csilva/api-devops-challenge:arm - docker push ghcr.io/vitor-csilva/api-devops-challenge:arm - name: Build e push Docker image run: | From 68cab1035f4d4c61377a65cfeeb7a6e4a9ae913e Mon Sep 17 00:00:00 2001 From: Vitor da Costa Silva Date: Sat, 11 Nov 2023 14:07:16 -0300 Subject: [PATCH 25/53] fix: Change 15 pipeline-arm.yml --- .github/workflows/pipeline-arm.yml | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/.github/workflows/pipeline-arm.yml b/.github/workflows/pipeline-arm.yml index 89d742a..760ded1 100644 --- a/.github/workflows/pipeline-arm.yml +++ b/.github/workflows/pipeline-arm.yml @@ -3,15 +3,12 @@ name: Build and Push Image platform ARM on: - # Triggers the workflow on push or pull request events but only for the "master" branch push: branches: [ "master" ] env: REGISTRY: ghcr.io - -# A workflow run is made up of one or more jobs that can run sequentially or in parallel jobs: build-and-push-image: runs-on: ubuntu-latest @@ -20,16 +17,20 @@ jobs: contents: read packages: write - # Steps represent a sequence of tasks that will be executed as part of the job steps: - # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - name: Realizando checkout do repositório uses: actions/checkout@v4 - - name: Docker Setup QEMU - uses: crazy-max/ghaction-docker-buildx@v3 - # - name: Set up QEMU - # uses: tonistiigi/binfmt@master + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + # - name: Docker Setup QEMU + # uses: crazy-max/ghaction-docker-buildx@v3 + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 - name: Log in no GitHub Container Registry uses: docker/login-action@v3 From f2340ac5652218ae09d71621b07c087a4b0b61dd Mon Sep 17 00:00:00 2001 From: Vitor da Costa Silva Date: Sat, 11 Nov 2023 14:22:51 -0300 Subject: [PATCH 26/53] fix: Change 16 pipeline-arm.yml --- .github/workflows/blank.yml | 2 +- .github/workflows/pipeline-arm.yml | 30 ++++++++++++++++++------------ 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/.github/workflows/blank.yml b/.github/workflows/blank.yml index 5dea057..06f15f5 100644 --- a/.github/workflows/blank.yml +++ b/.github/workflows/blank.yml @@ -5,7 +5,7 @@ name: Build and Push Image on: # Triggers the workflow on push or pull request events but only for the "master" branch push: - branches: [ "master" ] + branches: [ "develop" ] env: REGISTRY: ghcr.io diff --git a/.github/workflows/pipeline-arm.yml b/.github/workflows/pipeline-arm.yml index 760ded1..42eeffb 100644 --- a/.github/workflows/pipeline-arm.yml +++ b/.github/workflows/pipeline-arm.yml @@ -11,7 +11,7 @@ env: jobs: build-and-push-image: - runs-on: ubuntu-latest + runs-on: macos-13 permissions: contents: read @@ -21,16 +21,16 @@ jobs: - name: Realizando checkout do repositório uses: actions/checkout@v4 - - name: Login to Docker Hub - uses: docker/login-action@v3 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} + # - name: Login to Docker Hub + # uses: docker/login-action@v3 + # with: + # username: ${{ secrets.DOCKERHUB_USERNAME }} + # password: ${{ secrets.DOCKERHUB_TOKEN }} # - name: Docker Setup QEMU # uses: crazy-max/ghaction-docker-buildx@v3 - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 + # - name: Set up QEMU + # uses: docker/setup-qemu-action@v3 - name: Log in no GitHub Container Registry uses: docker/login-action@v3 @@ -38,11 +38,17 @@ jobs: registry: ${{ env.REGISTRY }} username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - + - name: Build e push Docker image run: | cd projeto-fsharp - docker buildx create --name mybuilder - docker buildx use mybuilder - docker buildx build --platform linux/arm64 -t ghcr.io/vitor-csilva/api-devops-challenge:arm . + docker build . --tag ghcr.io/vitor-csilva/api-devops-challenge:arm docker push ghcr.io/vitor-csilva/api-devops-challenge:arm + + # - name: Build e push Docker image + # run: | + # cd projeto-fsharp + # docker buildx create --name mybuilder + # docker buildx use mybuilder + # docker buildx build --platform linux/arm64 -t ghcr.io/vitor-csilva/api-devops-challenge:arm . + # docker push ghcr.io/vitor-csilva/api-devops-challenge:arm From 0045927b30e570a26956c8e9cc71513cc4aa68cd Mon Sep 17 00:00:00 2001 From: Vitor da Costa Silva Date: Sat, 11 Nov 2023 14:27:08 -0300 Subject: [PATCH 27/53] fix: Change 17 pipeline-arm.yml --- .github/workflows/pipeline-arm.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/pipeline-arm.yml b/.github/workflows/pipeline-arm.yml index 42eeffb..dc1f66c 100644 --- a/.github/workflows/pipeline-arm.yml +++ b/.github/workflows/pipeline-arm.yml @@ -32,6 +32,9 @@ jobs: # - name: Set up QEMU # uses: docker/setup-qemu-action@v3 + - name: Set up Docker + uses: docker/setup-docker@v2 + - name: Log in no GitHub Container Registry uses: docker/login-action@v3 with: From c7528fb84454686e01ad0121ff9dad94e247765a Mon Sep 17 00:00:00 2001 From: Vitor da Costa Silva Date: Sat, 11 Nov 2023 14:29:14 -0300 Subject: [PATCH 28/53] fix: Change 18 pipeline-arm.yml --- .github/workflows/pipeline-arm.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pipeline-arm.yml b/.github/workflows/pipeline-arm.yml index dc1f66c..98f50f4 100644 --- a/.github/workflows/pipeline-arm.yml +++ b/.github/workflows/pipeline-arm.yml @@ -32,8 +32,8 @@ jobs: # - name: Set up QEMU # uses: docker/setup-qemu-action@v3 - - name: Set up Docker - uses: docker/setup-docker@v2 + - name: Setup Docker on macOS + uses: douglascamata/setup-docker-macos-action@v1-alpha - name: Log in no GitHub Container Registry uses: docker/login-action@v3 From 2506520c833f6ca8a449ef6a2e6281646511cf0d Mon Sep 17 00:00:00 2001 From: Vitor da Costa Silva Date: Sat, 11 Nov 2023 14:43:36 -0300 Subject: [PATCH 29/53] fix: Change 19 pipeline-arm.yml --- .github/workflows/pipeline-arm.yml | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/.github/workflows/pipeline-arm.yml b/.github/workflows/pipeline-arm.yml index 98f50f4..c519990 100644 --- a/.github/workflows/pipeline-arm.yml +++ b/.github/workflows/pipeline-arm.yml @@ -31,22 +31,25 @@ jobs: # uses: crazy-max/ghaction-docker-buildx@v3 # - name: Set up QEMU # uses: docker/setup-qemu-action@v3 + - name: test + run: | + uname -p - - name: Setup Docker on macOS - uses: douglascamata/setup-docker-macos-action@v1-alpha + # - name: Setup Docker on macOS + # uses: douglascamata/setup-docker-macos-action@v1-alpha - - name: Log in no GitHub Container Registry - uses: docker/login-action@v3 - with: - registry: ${{ env.REGISTRY }} - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} + # - name: Log in no GitHub Container Registry + # uses: docker/login-action@v3 + # with: + # registry: ${{ env.REGISTRY }} + # username: ${{ github.actor }} + # password: ${{ secrets.GITHUB_TOKEN }} - - name: Build e push Docker image - run: | - cd projeto-fsharp - docker build . --tag ghcr.io/vitor-csilva/api-devops-challenge:arm - docker push ghcr.io/vitor-csilva/api-devops-challenge:arm + # - name: Build e push Docker image + # run: | + # cd projeto-fsharp + # docker build . --tag ghcr.io/vitor-csilva/api-devops-challenge:arm + # docker push ghcr.io/vitor-csilva/api-devops-challenge:arm # - name: Build e push Docker image # run: | From 381e41e3a9ca7aa3fb183838ffde6ac08f1985aa Mon Sep 17 00:00:00 2001 From: Vitor da Costa Silva Date: Sat, 11 Nov 2023 14:46:33 -0300 Subject: [PATCH 30/53] fix: Change 20 pipeline-arm.yml --- .github/workflows/pipeline-arm.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pipeline-arm.yml b/.github/workflows/pipeline-arm.yml index c519990..6ec8ffe 100644 --- a/.github/workflows/pipeline-arm.yml +++ b/.github/workflows/pipeline-arm.yml @@ -11,7 +11,11 @@ env: jobs: build-and-push-image: - runs-on: macos-13 + runs-on: ubuntu-latest + + strategy: + matrix: + arch: [arm64] permissions: contents: read From cb7752aaa3226297b267943974078555d3c1219e Mon Sep 17 00:00:00 2001 From: Vitor da Costa Silva Date: Sat, 11 Nov 2023 14:48:52 -0300 Subject: [PATCH 31/53] fix: Change 21 pipeline-arm.yml --- .github/workflows/pipeline-arm.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/pipeline-arm.yml b/.github/workflows/pipeline-arm.yml index 6ec8ffe..22f7137 100644 --- a/.github/workflows/pipeline-arm.yml +++ b/.github/workflows/pipeline-arm.yml @@ -11,11 +11,11 @@ env: jobs: build-and-push-image: - runs-on: ubuntu-latest + runs-on: ubuntu-latest-ARM - strategy: - matrix: - arch: [arm64] + # strategy: + # matrix: + # arch: [arm64] permissions: contents: read From 9e7990d93b1cc46e40e108b1221ef401107a5c8a Mon Sep 17 00:00:00 2001 From: Vitor da Costa Silva Date: Sat, 11 Nov 2023 14:53:30 -0300 Subject: [PATCH 32/53] fix: Change 22 pipeline-arm.yml --- .github/workflows/pipeline-arm.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/pipeline-arm.yml b/.github/workflows/pipeline-arm.yml index 22f7137..c29897c 100644 --- a/.github/workflows/pipeline-arm.yml +++ b/.github/workflows/pipeline-arm.yml @@ -11,7 +11,7 @@ env: jobs: build-and-push-image: - runs-on: ubuntu-latest-ARM + runs-on: ubuntu-latest # strategy: # matrix: @@ -33,11 +33,11 @@ jobs: # - name: Docker Setup QEMU # uses: crazy-max/ghaction-docker-buildx@v3 - # - name: Set up QEMU - # uses: docker/setup-qemu-action@v3 - - name: test - run: | - uname -p + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + # - name: test + # run: | + # uname -p # - name: Setup Docker on macOS # uses: douglascamata/setup-docker-macos-action@v1-alpha From 8598e6ba835c005800905dbfb9ee6a4236de4eb8 Mon Sep 17 00:00:00 2001 From: Vitor da Costa Silva Date: Sat, 11 Nov 2023 14:54:55 -0300 Subject: [PATCH 33/53] fix: Change 23 pipeline-arm.yml --- .github/workflows/pipeline-arm.yml | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/.github/workflows/pipeline-arm.yml b/.github/workflows/pipeline-arm.yml index c29897c..cebac99 100644 --- a/.github/workflows/pipeline-arm.yml +++ b/.github/workflows/pipeline-arm.yml @@ -42,12 +42,12 @@ jobs: # - name: Setup Docker on macOS # uses: douglascamata/setup-docker-macos-action@v1-alpha - # - name: Log in no GitHub Container Registry - # uses: docker/login-action@v3 - # with: - # registry: ${{ env.REGISTRY }} - # username: ${{ github.actor }} - # password: ${{ secrets.GITHUB_TOKEN }} + - name: Log in no GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} # - name: Build e push Docker image # run: | @@ -55,10 +55,10 @@ jobs: # docker build . --tag ghcr.io/vitor-csilva/api-devops-challenge:arm # docker push ghcr.io/vitor-csilva/api-devops-challenge:arm - # - name: Build e push Docker image - # run: | - # cd projeto-fsharp - # docker buildx create --name mybuilder - # docker buildx use mybuilder - # docker buildx build --platform linux/arm64 -t ghcr.io/vitor-csilva/api-devops-challenge:arm . - # docker push ghcr.io/vitor-csilva/api-devops-challenge:arm + - name: Build e push Docker image + run: | + cd projeto-fsharp + docker buildx create --name mybuilder + docker buildx use mybuilder + docker buildx build --platform linux/arm64 -t ghcr.io/vitor-csilva/api-devops-challenge:arm . + docker push ghcr.io/vitor-csilva/api-devops-challenge:arm From 88336e97d15a98b74bbc940c34eefd90de357ffd Mon Sep 17 00:00:00 2001 From: Vitor da Costa Silva Date: Sat, 11 Nov 2023 15:00:27 -0300 Subject: [PATCH 34/53] fix: Change 24 pipeline-arm.yml --- .github/workflows/pipeline-arm.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pipeline-arm.yml b/.github/workflows/pipeline-arm.yml index cebac99..c993789 100644 --- a/.github/workflows/pipeline-arm.yml +++ b/.github/workflows/pipeline-arm.yml @@ -60,5 +60,5 @@ jobs: cd projeto-fsharp docker buildx create --name mybuilder docker buildx use mybuilder - docker buildx build --platform linux/arm64 -t ghcr.io/vitor-csilva/api-devops-challenge:arm . + docker buildx build . --platform linux/arm64 -t ghcr.io/vitor-csilva/api-devops-challenge:arm docker push ghcr.io/vitor-csilva/api-devops-challenge:arm From cec148cbfe0b11b61e7b0365d5956d5ed97b1dc3 Mon Sep 17 00:00:00 2001 From: Vitor da Costa Silva Date: Sat, 11 Nov 2023 15:09:08 -0300 Subject: [PATCH 35/53] fix: Change 25 pipeline-arm.yml --- .github/workflows/pipeline-arm.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pipeline-arm.yml b/.github/workflows/pipeline-arm.yml index c993789..dd5e49a 100644 --- a/.github/workflows/pipeline-arm.yml +++ b/.github/workflows/pipeline-arm.yml @@ -54,11 +54,13 @@ jobs: # cd projeto-fsharp # docker build . --tag ghcr.io/vitor-csilva/api-devops-challenge:arm # docker push ghcr.io/vitor-csilva/api-devops-challenge:arm - + # docker buildx create --name mybuilder + # docker buildx use mybuilder - name: Build e push Docker image run: | cd projeto-fsharp - docker buildx create --name mybuilder - docker buildx use mybuilder + docker buildx create --use + docker images docker buildx build . --platform linux/arm64 -t ghcr.io/vitor-csilva/api-devops-challenge:arm + docker images docker push ghcr.io/vitor-csilva/api-devops-challenge:arm From 07845544cf484c265d94e70904eb47dad6803d2e Mon Sep 17 00:00:00 2001 From: Vitor da Costa Silva Date: Sat, 11 Nov 2023 15:16:22 -0300 Subject: [PATCH 36/53] fix: Change 26 pipeline-arm.yml --- .github/workflows/pipeline-arm.yml | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/.github/workflows/pipeline-arm.yml b/.github/workflows/pipeline-arm.yml index dd5e49a..8721c2e 100644 --- a/.github/workflows/pipeline-arm.yml +++ b/.github/workflows/pipeline-arm.yml @@ -56,11 +56,20 @@ jobs: # docker push ghcr.io/vitor-csilva/api-devops-challenge:arm # docker buildx create --name mybuilder # docker buildx use mybuilder - - name: Build e push Docker image - run: | - cd projeto-fsharp - docker buildx create --use - docker images - docker buildx build . --platform linux/arm64 -t ghcr.io/vitor-csilva/api-devops-challenge:arm - docker images - docker push ghcr.io/vitor-csilva/api-devops-challenge:arm + + # - name: Build e push Docker image + # run: | + # cd projeto-fsharp + # docker buildx create --use + # docker images + # docker buildx build --platform linux/arm64 -t ghcr.io/vitor-csilva/api-devops-challenge:arm . + # docker images + # docker push ghcr.io/vitor-csilva/api-devops-challenge:arm + + - name: Build and push + uses: docker/build-push-action@v5 + with: + context: . + platforms: linux/arm64 + push: true + tags: ghcr.io/vitor-csilva/api-devops-challenge:arm From 04f7f2d935b690acdf9a8f1dde67cce701246b4f Mon Sep 17 00:00:00 2001 From: Vitor da Costa Silva Date: Sat, 11 Nov 2023 15:18:51 -0300 Subject: [PATCH 37/53] fix: Change 27 pipeline-arm.yml --- .github/workflows/pipeline-arm.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pipeline-arm.yml b/.github/workflows/pipeline-arm.yml index 8721c2e..9f74539 100644 --- a/.github/workflows/pipeline-arm.yml +++ b/.github/workflows/pipeline-arm.yml @@ -69,7 +69,7 @@ jobs: - name: Build and push uses: docker/build-push-action@v5 with: - context: . + context: projeto-fsharp platforms: linux/arm64 push: true tags: ghcr.io/vitor-csilva/api-devops-challenge:arm From e76d94830497202a299e4cdaa89b9f76fdd3d5b6 Mon Sep 17 00:00:00 2001 From: Vitor da Costa Silva Date: Sat, 11 Nov 2023 15:30:29 -0300 Subject: [PATCH 38/53] fix: Change 28 pipeline-arm.yml --- .github/workflows/pipeline-arm.yml | 35 ++---------------------------- 1 file changed, 2 insertions(+), 33 deletions(-) diff --git a/.github/workflows/pipeline-arm.yml b/.github/workflows/pipeline-arm.yml index 9f74539..1d90ca8 100644 --- a/.github/workflows/pipeline-arm.yml +++ b/.github/workflows/pipeline-arm.yml @@ -25,22 +25,8 @@ jobs: - name: Realizando checkout do repositório uses: actions/checkout@v4 - # - name: Login to Docker Hub - # uses: docker/login-action@v3 - # with: - # username: ${{ secrets.DOCKERHUB_USERNAME }} - # password: ${{ secrets.DOCKERHUB_TOKEN }} - - # - name: Docker Setup QEMU - # uses: crazy-max/ghaction-docker-buildx@v3 - name: Set up QEMU uses: docker/setup-qemu-action@v3 - # - name: test - # run: | - # uname -p - - # - name: Setup Docker on macOS - # uses: douglascamata/setup-docker-macos-action@v1-alpha - name: Log in no GitHub Container Registry uses: docker/login-action@v3 @@ -49,27 +35,10 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - # - name: Build e push Docker image - # run: | - # cd projeto-fsharp - # docker build . --tag ghcr.io/vitor-csilva/api-devops-challenge:arm - # docker push ghcr.io/vitor-csilva/api-devops-challenge:arm - # docker buildx create --name mybuilder - # docker buildx use mybuilder - - # - name: Build e push Docker image - # run: | - # cd projeto-fsharp - # docker buildx create --use - # docker images - # docker buildx build --platform linux/arm64 -t ghcr.io/vitor-csilva/api-devops-challenge:arm . - # docker images - # docker push ghcr.io/vitor-csilva/api-devops-challenge:arm - - name: Build and push uses: docker/build-push-action@v5 with: context: projeto-fsharp - platforms: linux/arm64 + platforms: linux/amd64,linux/arm64 push: true - tags: ghcr.io/vitor-csilva/api-devops-challenge:arm + tags: ghcr.io/vitor-csilva/api-devops-challenge:latest From dc64fffa92136b64b46087c141ccec6921255cc1 Mon Sep 17 00:00:00 2001 From: Vitor da Costa Silva Date: Sat, 11 Nov 2023 15:33:00 -0300 Subject: [PATCH 39/53] fix: Change 29 pipeline-arm.yml --- .github/workflows/pipeline-arm.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/pipeline-arm.yml b/.github/workflows/pipeline-arm.yml index 1d90ca8..831cc4b 100644 --- a/.github/workflows/pipeline-arm.yml +++ b/.github/workflows/pipeline-arm.yml @@ -27,6 +27,9 @@ jobs: - name: Set up QEMU uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 - name: Log in no GitHub Container Registry uses: docker/login-action@v3 From a6e73b0dbf06c32c6766c841e550312b7afd07df Mon Sep 17 00:00:00 2001 From: Vitor da Costa Silva Date: Sat, 11 Nov 2023 15:45:29 -0300 Subject: [PATCH 40/53] fix: Change 30 pipeline.yml --- .github/workflows/blank.yml | 40 ------------------- .../{pipeline-arm.yml => pipeline.yml} | 7 +--- 2 files changed, 1 insertion(+), 46 deletions(-) delete mode 100644 .github/workflows/blank.yml rename .github/workflows/{pipeline-arm.yml => pipeline.yml} (90%) diff --git a/.github/workflows/blank.yml b/.github/workflows/blank.yml deleted file mode 100644 index 06f15f5..0000000 --- a/.github/workflows/blank.yml +++ /dev/null @@ -1,40 +0,0 @@ -# This is a basic workflow to help you get started with Actions - -name: Build and Push Image - -on: - # Triggers the workflow on push or pull request events but only for the "master" branch - push: - branches: [ "develop" ] - -env: - REGISTRY: ghcr.io - - -# A workflow run is made up of one or more jobs that can run sequentially or in parallel -jobs: - build-and-push-image: - runs-on: ubuntu-latest - - permissions: - contents: read - packages: write - - # Steps represent a sequence of tasks that will be executed as part of the job - steps: - # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - - name: Realizando checkout do repositório - uses: actions/checkout@v4 - - - name: Log in no GitHub Container Registry - uses: docker/login-action@v3 - with: - registry: ${{ env.REGISTRY }} - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Build e push Docker image - run: | - cd projeto-fsharp - docker build . --tag ghcr.io/vitor-csilva/api-devops-challenge:latest - docker push ghcr.io/vitor-csilva/api-devops-challenge:latest diff --git a/.github/workflows/pipeline-arm.yml b/.github/workflows/pipeline.yml similarity index 90% rename from .github/workflows/pipeline-arm.yml rename to .github/workflows/pipeline.yml index 831cc4b..144d3b8 100644 --- a/.github/workflows/pipeline-arm.yml +++ b/.github/workflows/pipeline.yml @@ -1,6 +1,5 @@ # This is a basic workflow to help you get started with Actions - -name: Build and Push Image platform ARM +name: Build and Push Project on: push: @@ -13,10 +12,6 @@ jobs: build-and-push-image: runs-on: ubuntu-latest - # strategy: - # matrix: - # arch: [arm64] - permissions: contents: read packages: write From 2d1a7db771755b635d910c69e5729c187cf9a773 Mon Sep 17 00:00:00 2001 From: Vitor da Costa Silva Date: Sat, 11 Nov 2023 18:19:42 -0300 Subject: [PATCH 41/53] feat: Add manifests deployment and service kubernetes --- .DS_Store | Bin 0 -> 8196 bytes projeto-fsharp/k8s/deployment/deployment.yaml | 27 ++++++++++++++++++ projeto-fsharp/k8s/service/service.yaml | 12 ++++++++ 3 files changed, 39 insertions(+) create mode 100644 .DS_Store create mode 100644 projeto-fsharp/k8s/deployment/deployment.yaml create mode 100644 projeto-fsharp/k8s/service/service.yaml diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..e3428caed4dbac1e3e5ef90ebaf726eac27c3988 GIT binary patch literal 8196 zcmeHMU2GLa6h3EL=R*f*>f)dU}wo{0Wbi7QRP%$K+OdTpXYT}Q6f$yQ6zl;8$$45JsgB!mUPUB zJrH{!_CV}`*aNW#E(H(Joy`lI|rVh_yr01uyPC_s_&_QTWi_fas3TgZ+Dg{)OwH)Vv16Oso12pDt;d^^$68ujTB+aGeEhh|mNsnc*poTp<~{!b zX%HTW?@&QmR#8(+OA}6*4mi9OC2gpKT78HS_iAaCUrRH=ksJwAldcCHpcGYPrlgam>AFABqV)*Hq?zSwrlvaQH&qu;oV z>7S5}?s#Q~&`g^vLCqRcjdCA^2i1mDbF?iCR=@_jpL*c{MNR=uz(ep1oPw9(O?V$Z zfREt}d;wp=SMW7_4?n@ra1MS!1uJkK&c`KKj|p6jjkpOnV;i>PR_wtY*o%F53l8Bh zj^KVY@h~32JbGBhdvP33;7NQKpTwu|X?zi1#R+^J-@teAG=7L5;pg}b{(xukNBk9k z!{6}_rADb$Rw+s43i-~;RE!KwhnB)k{Ks>EVk9~Tl>CKaB+;`&>%AmmIN?F90m|d?xlNc2=xhr6u+f!tJAT1)N^RvCJm9^qQoW z(C1MM$l+CMX*i$oFNfDQCK9?rVJC+hHYPN^f`UpFx|Zi>B$76kh7&isi;K z?M7{z%7a=5A-kQg#Hjph&`!YH@E)9oNdoP+@Ex3mKapWI))7Rn#&vidHsN}L=@z^J zI|Nj3BB1WXT{wV)1lD~7*Bsh-2uIPuB8FHJkiAbp_I`W>AH~P;aeM+#;j{Q0K94Wp zO9bE7W&pEqIxz8_ivhEoE_$x-9U{3Ya8F+%9?ju_3duKk{@*kA@BedX$L!bxu?PMS z9>B`(bay9NGS~UZbL}M6JE`)*<;EoyD%5Zh&KK!8(er;8Qa>5Zr6M{mDa}y%&wmJ@ TPtf@OpZ(Dq-~R%Rmre5*kijhz literal 0 HcmV?d00001 diff --git a/projeto-fsharp/k8s/deployment/deployment.yaml b/projeto-fsharp/k8s/deployment/deployment.yaml new file mode 100644 index 0000000..fb2ffb8 --- /dev/null +++ b/projeto-fsharp/k8s/deployment/deployment.yaml @@ -0,0 +1,27 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + labels: + app: api-devops-challenge + name: api-devops-challenge +spec: + replicas: 1 + selector: + matchLabels: + app: api-devops-challenge + template: + metadata: + labels: + app: api-devops-challenge + spec: + containers: + - image: ghcr.io/vitor-csilva/api-devops-challenge:latest + name: api-devops-challenge + readinessProbe: + httpGet: + path: "/endpoint/get/hello" + port: 8085 + # livenessProbe: + # httpGet: + # path: "/" + # port: 8085 diff --git a/projeto-fsharp/k8s/service/service.yaml b/projeto-fsharp/k8s/service/service.yaml new file mode 100644 index 0000000..7a60091 --- /dev/null +++ b/projeto-fsharp/k8s/service/service.yaml @@ -0,0 +1,12 @@ +apiVersion: v1 +kind: Service +metadata: + name: api-devops-challenge +spec: + selector: + app: api-devops-challenge + ports: + - name: https + port: 80 + targetPort: 8085 + type: ClusterIP \ No newline at end of file From 3b43e265013066e0d32f123a3539cea7070cb543 Mon Sep 17 00:00:00 2001 From: Vitor da Costa Silva Date: Sun, 12 Nov 2023 00:56:56 -0300 Subject: [PATCH 42/53] feat: Add Ingress --- projeto-fsharp/k8s/ingress/deploy.yaml | 647 ++++++++++++++++++++++++ projeto-fsharp/k8s/ingress/ingress.yaml | 31 ++ 2 files changed, 678 insertions(+) create mode 100644 projeto-fsharp/k8s/ingress/deploy.yaml create mode 100644 projeto-fsharp/k8s/ingress/ingress.yaml diff --git a/projeto-fsharp/k8s/ingress/deploy.yaml b/projeto-fsharp/k8s/ingress/deploy.yaml new file mode 100644 index 0000000..fff2001 --- /dev/null +++ b/projeto-fsharp/k8s/ingress/deploy.yaml @@ -0,0 +1,647 @@ +apiVersion: v1 +kind: Namespace +metadata: + labels: + app.kubernetes.io/instance: ingress-nginx + app.kubernetes.io/name: ingress-nginx + name: ingress-nginx +--- +apiVersion: v1 +automountServiceAccountToken: true +kind: ServiceAccount +metadata: + labels: + app.kubernetes.io/component: controller + app.kubernetes.io/instance: ingress-nginx + app.kubernetes.io/name: ingress-nginx + app.kubernetes.io/part-of: ingress-nginx + app.kubernetes.io/version: 1.8.2 + name: ingress-nginx + namespace: ingress-nginx +--- +apiVersion: v1 +kind: ServiceAccount +metadata: + labels: + app.kubernetes.io/component: admission-webhook + app.kubernetes.io/instance: ingress-nginx + app.kubernetes.io/name: ingress-nginx + app.kubernetes.io/part-of: ingress-nginx + app.kubernetes.io/version: 1.8.2 + name: ingress-nginx-admission + namespace: ingress-nginx +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: Role +metadata: + labels: + app.kubernetes.io/component: controller + app.kubernetes.io/instance: ingress-nginx + app.kubernetes.io/name: ingress-nginx + app.kubernetes.io/part-of: ingress-nginx + app.kubernetes.io/version: 1.8.2 + name: ingress-nginx + namespace: ingress-nginx +rules: +- apiGroups: + - "" + resources: + - namespaces + verbs: + - get +- apiGroups: + - "" + resources: + - configmaps + - pods + - secrets + - endpoints + verbs: + - get + - list + - watch +- apiGroups: + - "" + resources: + - services + verbs: + - get + - list + - watch +- apiGroups: + - networking.k8s.io + resources: + - ingresses + verbs: + - get + - list + - watch +- apiGroups: + - networking.k8s.io + resources: + - ingresses/status + verbs: + - update +- apiGroups: + - networking.k8s.io + resources: + - ingressclasses + verbs: + - get + - list + - watch +- apiGroups: + - coordination.k8s.io + resourceNames: + - ingress-nginx-leader + resources: + - leases + verbs: + - get + - update +- apiGroups: + - coordination.k8s.io + resources: + - leases + verbs: + - create +- apiGroups: + - "" + resources: + - events + verbs: + - create + - patch +- apiGroups: + - discovery.k8s.io + resources: + - endpointslices + verbs: + - list + - watch + - get +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: Role +metadata: + labels: + app.kubernetes.io/component: admission-webhook + app.kubernetes.io/instance: ingress-nginx + app.kubernetes.io/name: ingress-nginx + app.kubernetes.io/part-of: ingress-nginx + app.kubernetes.io/version: 1.8.2 + name: ingress-nginx-admission + namespace: ingress-nginx +rules: +- apiGroups: + - "" + resources: + - secrets + verbs: + - get + - create +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + labels: + app.kubernetes.io/instance: ingress-nginx + app.kubernetes.io/name: ingress-nginx + app.kubernetes.io/part-of: ingress-nginx + app.kubernetes.io/version: 1.8.2 + name: ingress-nginx +rules: +- apiGroups: + - "" + resources: + - configmaps + - endpoints + - nodes + - pods + - secrets + - namespaces + verbs: + - list + - watch +- apiGroups: + - coordination.k8s.io + resources: + - leases + verbs: + - list + - watch +- apiGroups: + - "" + resources: + - nodes + verbs: + - get +- apiGroups: + - "" + resources: + - services + verbs: + - get + - list + - watch +- apiGroups: + - networking.k8s.io + resources: + - ingresses + verbs: + - get + - list + - watch +- apiGroups: + - "" + resources: + - events + verbs: + - create + - patch +- apiGroups: + - networking.k8s.io + resources: + - ingresses/status + verbs: + - update +- apiGroups: + - networking.k8s.io + resources: + - ingressclasses + verbs: + - get + - list + - watch +- apiGroups: + - discovery.k8s.io + resources: + - endpointslices + verbs: + - list + - watch + - get +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + labels: + app.kubernetes.io/component: admission-webhook + app.kubernetes.io/instance: ingress-nginx + app.kubernetes.io/name: ingress-nginx + app.kubernetes.io/part-of: ingress-nginx + app.kubernetes.io/version: 1.8.2 + name: ingress-nginx-admission +rules: +- apiGroups: + - admissionregistration.k8s.io + resources: + - validatingwebhookconfigurations + verbs: + - get + - update +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: RoleBinding +metadata: + labels: + app.kubernetes.io/component: controller + app.kubernetes.io/instance: ingress-nginx + app.kubernetes.io/name: ingress-nginx + app.kubernetes.io/part-of: ingress-nginx + app.kubernetes.io/version: 1.8.2 + name: ingress-nginx + namespace: ingress-nginx +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: Role + name: ingress-nginx +subjects: +- kind: ServiceAccount + name: ingress-nginx + namespace: ingress-nginx +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: RoleBinding +metadata: + labels: + app.kubernetes.io/component: admission-webhook + app.kubernetes.io/instance: ingress-nginx + app.kubernetes.io/name: ingress-nginx + app.kubernetes.io/part-of: ingress-nginx + app.kubernetes.io/version: 1.8.2 + name: ingress-nginx-admission + namespace: ingress-nginx +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: Role + name: ingress-nginx-admission +subjects: +- kind: ServiceAccount + name: ingress-nginx-admission + namespace: ingress-nginx +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + labels: + app.kubernetes.io/instance: ingress-nginx + app.kubernetes.io/name: ingress-nginx + app.kubernetes.io/part-of: ingress-nginx + app.kubernetes.io/version: 1.8.2 + name: ingress-nginx +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: ingress-nginx +subjects: +- kind: ServiceAccount + name: ingress-nginx + namespace: ingress-nginx +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + labels: + app.kubernetes.io/component: admission-webhook + app.kubernetes.io/instance: ingress-nginx + app.kubernetes.io/name: ingress-nginx + app.kubernetes.io/part-of: ingress-nginx + app.kubernetes.io/version: 1.8.2 + name: ingress-nginx-admission +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: ingress-nginx-admission +subjects: +- kind: ServiceAccount + name: ingress-nginx-admission + namespace: ingress-nginx +--- +apiVersion: v1 +data: + allow-snippet-annotations: "true" +kind: ConfigMap +metadata: + labels: + app.kubernetes.io/component: controller + app.kubernetes.io/instance: ingress-nginx + app.kubernetes.io/name: ingress-nginx + app.kubernetes.io/part-of: ingress-nginx + app.kubernetes.io/version: 1.8.2 + name: ingress-nginx-controller + namespace: ingress-nginx +--- +apiVersion: v1 +kind: Service +metadata: + labels: + app.kubernetes.io/component: controller + app.kubernetes.io/instance: ingress-nginx + app.kubernetes.io/name: ingress-nginx + app.kubernetes.io/part-of: ingress-nginx + app.kubernetes.io/version: 1.8.2 + name: ingress-nginx-controller + namespace: ingress-nginx +spec: + ipFamilies: + - IPv4 + ipFamilyPolicy: SingleStack + ports: + - appProtocol: http + name: http + port: 80 + protocol: TCP + targetPort: http + - appProtocol: https + name: https + port: 443 + protocol: TCP + targetPort: https + selector: + app.kubernetes.io/component: controller + app.kubernetes.io/instance: ingress-nginx + app.kubernetes.io/name: ingress-nginx + type: LoadBalancer +--- +apiVersion: v1 +kind: Service +metadata: + labels: + app.kubernetes.io/component: controller + app.kubernetes.io/instance: ingress-nginx + app.kubernetes.io/name: ingress-nginx + app.kubernetes.io/part-of: ingress-nginx + app.kubernetes.io/version: 1.8.2 + name: ingress-nginx-controller-admission + namespace: ingress-nginx +spec: + ports: + - appProtocol: https + name: https-webhook + port: 443 + targetPort: webhook + selector: + app.kubernetes.io/component: controller + app.kubernetes.io/instance: ingress-nginx + app.kubernetes.io/name: ingress-nginx + type: ClusterIP +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + labels: + app.kubernetes.io/component: controller + app.kubernetes.io/instance: ingress-nginx + app.kubernetes.io/name: ingress-nginx + app.kubernetes.io/part-of: ingress-nginx + app.kubernetes.io/version: 1.8.2 + name: ingress-nginx-controller + namespace: ingress-nginx +spec: + minReadySeconds: 0 + revisionHistoryLimit: 10 + selector: + matchLabels: + app.kubernetes.io/component: controller + app.kubernetes.io/instance: ingress-nginx + app.kubernetes.io/name: ingress-nginx + strategy: + rollingUpdate: + maxUnavailable: 1 + type: RollingUpdate + template: + metadata: + labels: + app.kubernetes.io/component: controller + app.kubernetes.io/instance: ingress-nginx + app.kubernetes.io/name: ingress-nginx + app.kubernetes.io/part-of: ingress-nginx + app.kubernetes.io/version: 1.8.2 + spec: + containers: + - args: + - /nginx-ingress-controller + - --election-id=ingress-nginx-leader + - --controller-class=k8s.io/ingress-nginx + - --ingress-class=nginx + - --configmap=$(POD_NAMESPACE)/ingress-nginx-controller + - --validating-webhook=:8443 + - --validating-webhook-certificate=/usr/local/certificates/cert + - --validating-webhook-key=/usr/local/certificates/key + env: + - name: POD_NAME + valueFrom: + fieldRef: + fieldPath: metadata.name + - name: POD_NAMESPACE + valueFrom: + fieldRef: + fieldPath: metadata.namespace + - name: LD_PRELOAD + value: /usr/local/lib/libmimalloc.so + image: registry.k8s.io/ingress-nginx/controller:v1.8.2@sha256:74834d3d25b336b62cabeb8bf7f1d788706e2cf1cfd64022de4137ade8881ff2 + imagePullPolicy: IfNotPresent + lifecycle: + preStop: + exec: + command: + - /wait-shutdown + livenessProbe: + failureThreshold: 5 + httpGet: + path: /healthz + port: 10254 + scheme: HTTP + initialDelaySeconds: 10 + periodSeconds: 10 + successThreshold: 1 + timeoutSeconds: 1 + name: controller + ports: + - containerPort: 80 + name: http + protocol: TCP + - containerPort: 443 + name: https + protocol: TCP + - containerPort: 8443 + name: webhook + protocol: TCP + readinessProbe: + failureThreshold: 3 + httpGet: + path: /healthz + port: 10254 + scheme: HTTP + initialDelaySeconds: 10 + periodSeconds: 10 + successThreshold: 1 + timeoutSeconds: 1 + resources: + requests: + cpu: 100m + memory: 90Mi + securityContext: + allowPrivilegeEscalation: true + capabilities: + add: + - NET_BIND_SERVICE + drop: + - ALL + runAsUser: 101 + volumeMounts: + - mountPath: /usr/local/certificates/ + name: webhook-cert + readOnly: true + dnsPolicy: ClusterFirst + nodeSelector: + kubernetes.io/os: linux + serviceAccountName: ingress-nginx + terminationGracePeriodSeconds: 300 + volumes: + - name: webhook-cert + secret: + secretName: ingress-nginx-admission +--- +apiVersion: batch/v1 +kind: Job +metadata: + labels: + app.kubernetes.io/component: admission-webhook + app.kubernetes.io/instance: ingress-nginx + app.kubernetes.io/name: ingress-nginx + app.kubernetes.io/part-of: ingress-nginx + app.kubernetes.io/version: 1.8.2 + name: ingress-nginx-admission-create + namespace: ingress-nginx +spec: + template: + metadata: + labels: + app.kubernetes.io/component: admission-webhook + app.kubernetes.io/instance: ingress-nginx + app.kubernetes.io/name: ingress-nginx + app.kubernetes.io/part-of: ingress-nginx + app.kubernetes.io/version: 1.8.2 + name: ingress-nginx-admission-create + spec: + containers: + - args: + - create + - --host=ingress-nginx-controller-admission,ingress-nginx-controller-admission.$(POD_NAMESPACE).svc + - --namespace=$(POD_NAMESPACE) + - --secret-name=ingress-nginx-admission + env: + - name: POD_NAMESPACE + valueFrom: + fieldRef: + fieldPath: metadata.namespace + image: registry.k8s.io/ingress-nginx/kube-webhook-certgen:v20230407@sha256:543c40fd093964bc9ab509d3e791f9989963021f1e9e4c9c7b6700b02bfb227b + imagePullPolicy: IfNotPresent + name: create + securityContext: + allowPrivilegeEscalation: false + nodeSelector: + kubernetes.io/os: linux + restartPolicy: OnFailure + securityContext: + fsGroup: 2000 + runAsNonRoot: true + runAsUser: 2000 + serviceAccountName: ingress-nginx-admission +--- +apiVersion: batch/v1 +kind: Job +metadata: + labels: + app.kubernetes.io/component: admission-webhook + app.kubernetes.io/instance: ingress-nginx + app.kubernetes.io/name: ingress-nginx + app.kubernetes.io/part-of: ingress-nginx + app.kubernetes.io/version: 1.8.2 + name: ingress-nginx-admission-patch + namespace: ingress-nginx +spec: + template: + metadata: + labels: + app.kubernetes.io/component: admission-webhook + app.kubernetes.io/instance: ingress-nginx + app.kubernetes.io/name: ingress-nginx + app.kubernetes.io/part-of: ingress-nginx + app.kubernetes.io/version: 1.8.2 + name: ingress-nginx-admission-patch + spec: + containers: + - args: + - patch + - --webhook-name=ingress-nginx-admission + - --namespace=$(POD_NAMESPACE) + - --patch-mutating=false + - --secret-name=ingress-nginx-admission + - --patch-failure-policy=Fail + env: + - name: POD_NAMESPACE + valueFrom: + fieldRef: + fieldPath: metadata.namespace + image: registry.k8s.io/ingress-nginx/kube-webhook-certgen:v20230407@sha256:543c40fd093964bc9ab509d3e791f9989963021f1e9e4c9c7b6700b02bfb227b + imagePullPolicy: IfNotPresent + name: patch + securityContext: + allowPrivilegeEscalation: false + nodeSelector: + kubernetes.io/os: linux + restartPolicy: OnFailure + securityContext: + fsGroup: 2000 + runAsNonRoot: true + runAsUser: 2000 + serviceAccountName: ingress-nginx-admission +--- +apiVersion: networking.k8s.io/v1 +kind: IngressClass +metadata: + labels: + app.kubernetes.io/component: controller + app.kubernetes.io/instance: ingress-nginx + app.kubernetes.io/name: ingress-nginx + app.kubernetes.io/part-of: ingress-nginx + app.kubernetes.io/version: 1.8.2 + name: nginx +spec: + controller: k8s.io/ingress-nginx +--- +apiVersion: admissionregistration.k8s.io/v1 +kind: ValidatingWebhookConfiguration +metadata: + labels: + app.kubernetes.io/component: admission-webhook + app.kubernetes.io/instance: ingress-nginx + app.kubernetes.io/name: ingress-nginx + app.kubernetes.io/part-of: ingress-nginx + app.kubernetes.io/version: 1.8.2 + name: ingress-nginx-admission +webhooks: +- admissionReviewVersions: + - v1 + clientConfig: + service: + name: ingress-nginx-controller-admission + namespace: ingress-nginx + path: /networking/v1/ingresses + failurePolicy: Fail + matchPolicy: Equivalent + name: validate.nginx.ingress.kubernetes.io + rules: + - apiGroups: + - networking.k8s.io + apiVersions: + - v1 + operations: + - CREATE + - UPDATE + resources: + - ingresses + sideEffects: None \ No newline at end of file diff --git a/projeto-fsharp/k8s/ingress/ingress.yaml b/projeto-fsharp/k8s/ingress/ingress.yaml new file mode 100644 index 0000000..949de33 --- /dev/null +++ b/projeto-fsharp/k8s/ingress/ingress.yaml @@ -0,0 +1,31 @@ +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: web-services-ingress + annotations: + nginx.ingress.kubernetes.io/use-regex: "true" + # nginx.ingress.kubernetes.io/rewrite-target: /$2 +spec: + ingressClassName: nginx #Irá ser injetado a regra dentro do ingress que contém essa classe. + rules: + # digitar esse dns o mesmo será redirecionado para esse service. + - host: "api-devops-challenge.demo.com" + http: + paths: + - path: / + pathType: Prefix + backend: + service: + name: api-devops-challenge + port: + number: 80 + # - host: "httpd.demo.com" + # http: + # paths: + # - path: / + # pathType: Prefix + # backend: + # service: + # name: httpd + # port: + # number: 80 \ No newline at end of file From 43a05d8d16c7a60013b8807e72a8db24a4545d32 Mon Sep 17 00:00:00 2001 From: Vitor da Costa Silva Date: Sun, 12 Nov 2023 11:01:06 -0300 Subject: [PATCH 43/53] feat: Add readness and liveness Probe --- projeto-fsharp/k8s/deployment/deployment.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/projeto-fsharp/k8s/deployment/deployment.yaml b/projeto-fsharp/k8s/deployment/deployment.yaml index fb2ffb8..3c8e493 100644 --- a/projeto-fsharp/k8s/deployment/deployment.yaml +++ b/projeto-fsharp/k8s/deployment/deployment.yaml @@ -21,7 +21,7 @@ spec: httpGet: path: "/endpoint/get/hello" port: 8085 - # livenessProbe: - # httpGet: - # path: "/" - # port: 8085 + livenessProbe: + httpGet: + path: "/endpoint/get/hello" + port: 8085 From a95908382acdd070b377c25ff43506698866d7e9 Mon Sep 17 00:00:00 2001 From: Vitor da Costa Silva Date: Sun, 12 Nov 2023 11:32:26 -0300 Subject: [PATCH 44/53] feat: Add Requests and Limits deployment --- projeto-fsharp/k8s/deployment/deployment.yaml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/projeto-fsharp/k8s/deployment/deployment.yaml b/projeto-fsharp/k8s/deployment/deployment.yaml index 3c8e493..557434c 100644 --- a/projeto-fsharp/k8s/deployment/deployment.yaml +++ b/projeto-fsharp/k8s/deployment/deployment.yaml @@ -25,3 +25,10 @@ spec: httpGet: path: "/endpoint/get/hello" port: 8085 + resources: + requests: + cpu: 1 #(Pode ser informado por miliCpus 100m ou uma CPU inteira 1 isso porque aqui se define Vcpu) + memory: 512M + limits: + cpu: 2 + memory: 1G From 73f739f7df655cd5be8091368925208782fbce66 Mon Sep 17 00:00:00 2001 From: Vitor da Costa Silva Date: Sun, 12 Nov 2023 11:58:25 -0300 Subject: [PATCH 45/53] feat: Add metrics-server --- .../k8s/metrics-server/components.yaml | 197 ++++++++++++++++++ 1 file changed, 197 insertions(+) create mode 100644 projeto-fsharp/k8s/metrics-server/components.yaml diff --git a/projeto-fsharp/k8s/metrics-server/components.yaml b/projeto-fsharp/k8s/metrics-server/components.yaml new file mode 100644 index 0000000..ce7ec2c --- /dev/null +++ b/projeto-fsharp/k8s/metrics-server/components.yaml @@ -0,0 +1,197 @@ +apiVersion: v1 +kind: ServiceAccount +metadata: + labels: + k8s-app: metrics-server + name: metrics-server + namespace: kube-system +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + labels: + k8s-app: metrics-server + rbac.authorization.k8s.io/aggregate-to-admin: "true" + rbac.authorization.k8s.io/aggregate-to-edit: "true" + rbac.authorization.k8s.io/aggregate-to-view: "true" + name: system:aggregated-metrics-reader +rules: +- apiGroups: + - metrics.k8s.io + resources: + - pods + - nodes + verbs: + - get + - list + - watch +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + labels: + k8s-app: metrics-server + name: system:metrics-server +rules: +- apiGroups: + - "" + resources: + - nodes/metrics + verbs: + - get +- apiGroups: + - "" + resources: + - pods + - nodes + verbs: + - get + - list + - watch +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: RoleBinding +metadata: + labels: + k8s-app: metrics-server + name: metrics-server-auth-reader + namespace: kube-system +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: Role + name: extension-apiserver-authentication-reader +subjects: +- kind: ServiceAccount + name: metrics-server + namespace: kube-system +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + labels: + k8s-app: metrics-server + name: metrics-server:system:auth-delegator +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: system:auth-delegator +subjects: +- kind: ServiceAccount + name: metrics-server + namespace: kube-system +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + labels: + k8s-app: metrics-server + name: system:metrics-server +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: system:metrics-server +subjects: +- kind: ServiceAccount + name: metrics-server + namespace: kube-system +--- +apiVersion: v1 +kind: Service +metadata: + labels: + k8s-app: metrics-server + name: metrics-server + namespace: kube-system +spec: + ports: + - name: https + port: 443 + protocol: TCP + targetPort: https + selector: + k8s-app: metrics-server +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + labels: + k8s-app: metrics-server + name: metrics-server + namespace: kube-system +spec: + selector: + matchLabels: + k8s-app: metrics-server + strategy: + rollingUpdate: + maxUnavailable: 0 + template: + metadata: + labels: + k8s-app: metrics-server + spec: + containers: + - args: + - --cert-dir=/tmp + - --secure-port=4443 + - --kubelet-preferred-address-types=InternalIP,ExternalIP,Hostname + - --kubelet-use-node-status-port + - --kubelet-insecure-tls + - --metric-resolution=15s + image: registry.k8s.io/metrics-server/metrics-server:v0.6.4 + imagePullPolicy: IfNotPresent + livenessProbe: + failureThreshold: 3 + httpGet: + path: /livez + port: https + scheme: HTTPS + periodSeconds: 10 + name: metrics-server + ports: + - containerPort: 4443 + name: https + protocol: TCP + readinessProbe: + failureThreshold: 3 + httpGet: + path: /readyz + port: https + scheme: HTTPS + initialDelaySeconds: 20 + periodSeconds: 10 + resources: + requests: + cpu: 100m + memory: 200Mi + securityContext: + allowPrivilegeEscalation: false + readOnlyRootFilesystem: true + runAsNonRoot: true + runAsUser: 1000 + volumeMounts: + - mountPath: /tmp + name: tmp-dir + nodeSelector: + kubernetes.io/os: linux + priorityClassName: system-cluster-critical + serviceAccountName: metrics-server + volumes: + - emptyDir: {} + name: tmp-dir +--- +apiVersion: apiregistration.k8s.io/v1 +kind: APIService +metadata: + labels: + k8s-app: metrics-server + name: v1beta1.metrics.k8s.io +spec: + group: metrics.k8s.io + groupPriorityMinimum: 100 + insecureSkipTLSVerify: true + service: + name: metrics-server + namespace: kube-system + version: v1beta1 + versionPriority: 100 From 3d84fbc9c5d4b7faf30bb59034835ef72fc6bb6f Mon Sep 17 00:00:00 2001 From: Vitor da Costa Silva Date: Sun, 12 Nov 2023 11:58:59 -0300 Subject: [PATCH 46/53] feat: Add hpa in deployment --- projeto-fsharp/k8s/deployment/deployment.yaml | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/projeto-fsharp/k8s/deployment/deployment.yaml b/projeto-fsharp/k8s/deployment/deployment.yaml index 557434c..2f15564 100644 --- a/projeto-fsharp/k8s/deployment/deployment.yaml +++ b/projeto-fsharp/k8s/deployment/deployment.yaml @@ -1,3 +1,23 @@ +apiVersion: autoscaling/v2 +kind: HorizontalPodAutoscaler +metadata: + name: api-devops-challenge-hpa +spec: + metrics: + - resource: + name: cpu + target: + averageUtilization: 60 + type: Utilization + type: Resource + minReplicas: 3 + maxReplicas: 6 + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: api-devops-challenge + +--- apiVersion: apps/v1 kind: Deployment metadata: @@ -27,8 +47,8 @@ spec: port: 8085 resources: requests: - cpu: 1 #(Pode ser informado por miliCpus 100m ou uma CPU inteira 1 isso porque aqui se define Vcpu) + cpu: 50m memory: 512M limits: - cpu: 2 + cpu: 100m memory: 1G From 6b87637b6f771761500f36c9b85a72ce07517aa0 Mon Sep 17 00:00:00 2001 From: Vitor da Costa Silva Date: Sun, 12 Nov 2023 14:53:48 -0300 Subject: [PATCH 47/53] feat: Add new resources in hpa --- projeto-fsharp/Makefile | 4 ++-- projeto-fsharp/k8s/deployment/deployment.yaml | 10 ++++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/projeto-fsharp/Makefile b/projeto-fsharp/Makefile index 98a05f8..10819b3 100644 --- a/projeto-fsharp/Makefile +++ b/projeto-fsharp/Makefile @@ -1,8 +1,8 @@ build: - @docker build -t vitorcostasilva/api-devops-challenge:1.0 . + @docker build -t api-devops-challenge:latest . run: - @docker run -d -p 8085:8085 --name api-devops-challenge vitorcostasilva/api-devops-challenge:1.0 + @docker run -d -p 8085:8085 --name api-devops-challenge api-devops-challenge:latest compose: #export DOCKER_DEFAULT_PLATFORM=linux/arm64 diff --git a/projeto-fsharp/k8s/deployment/deployment.yaml b/projeto-fsharp/k8s/deployment/deployment.yaml index 2f15564..10acfab 100644 --- a/projeto-fsharp/k8s/deployment/deployment.yaml +++ b/projeto-fsharp/k8s/deployment/deployment.yaml @@ -4,12 +4,18 @@ metadata: name: api-devops-challenge-hpa spec: metrics: - - resource: + - type: Resource + resource: name: cpu target: + type: Utilization averageUtilization: 60 + - type: Resource + resource: + name: memory + target: type: Utilization - type: Resource + averageValue: 100Mi minReplicas: 3 maxReplicas: 6 scaleTargetRef: From cf9ae74c6221cf9cfa4881ed5ebfcabbab74c1ad Mon Sep 17 00:00:00 2001 From: Vitor da Costa Silva Date: Sun, 12 Nov 2023 17:11:17 -0300 Subject: [PATCH 48/53] feat: Add k8s manifests --- projeto-fsharp/apply.sh | 31 +++++++++++++++++++++++++ projeto-fsharp/k8s/ingress/ingress.yaml | 12 +--------- projeto-fsharp/k8s/kind/config.yaml | 25 ++++++++++++++++++++ projeto-fsharp/k8s/metallb/metallb.yaml | 18 ++++++++++++++ 4 files changed, 75 insertions(+), 11 deletions(-) create mode 100755 projeto-fsharp/apply.sh create mode 100644 projeto-fsharp/k8s/kind/config.yaml create mode 100644 projeto-fsharp/k8s/metallb/metallb.yaml diff --git a/projeto-fsharp/apply.sh b/projeto-fsharp/apply.sh new file mode 100755 index 0000000..ea76ef8 --- /dev/null +++ b/projeto-fsharp/apply.sh @@ -0,0 +1,31 @@ +#!/bin/bash + +function _create_cluster () { + kind create cluster \ + --config ./k8s/kind/config.yaml \ + --name api-devops-challenge + + _apply_manifests + _clean +} + +function _clean () { + rm -f get-docker.sh +} + +function _apply_manifests () { + export KUBECONFIG=$HOME/.kube/config + kubectl apply -f https://raw.githubusercontent.com/metallb/metallb/v0.13.11/config/manifests/metallb-native.yaml + sleep 60 + kubectl apply -f ./k8s/metallb/metallb.yaml + kubectl apply -f ./k8s/metrics-server/components.yaml + sleep 10 + kubectl apply -f ./k8s/deployment/deployment.yaml + kubectl apply -f ./k8s/service/service.yaml + kubectl apply -f ./k8s/ingress/deploy.yaml + sleep 360 + kubectl apply -f ./k8s/ingress/ingress.yaml +} + +#Create Clustes and apply manifests +[ ! -z "`kind version`" ] && _create_cluster diff --git a/projeto-fsharp/k8s/ingress/ingress.yaml b/projeto-fsharp/k8s/ingress/ingress.yaml index 949de33..9b01faa 100644 --- a/projeto-fsharp/k8s/ingress/ingress.yaml +++ b/projeto-fsharp/k8s/ingress/ingress.yaml @@ -18,14 +18,4 @@ spec: service: name: api-devops-challenge port: - number: 80 - # - host: "httpd.demo.com" - # http: - # paths: - # - path: / - # pathType: Prefix - # backend: - # service: - # name: httpd - # port: - # number: 80 \ No newline at end of file + number: 80 \ No newline at end of file diff --git a/projeto-fsharp/k8s/kind/config.yaml b/projeto-fsharp/k8s/kind/config.yaml new file mode 100644 index 0000000..b4b0a1e --- /dev/null +++ b/projeto-fsharp/k8s/kind/config.yaml @@ -0,0 +1,25 @@ +kind: Cluster +apiVersion: kind.x-k8s.io/v1alpha4 +nodes: +- role: control-plane + kubeadmConfigPatches: + - | + kind: InitConfiguration + nodeRegistration: + kubeletExtraArgs: + node-labels: "ingress-ready=true" + extraPortMappings: + - containerPort: 80 + hostPort: 80 + listenAddress: "0.0.0.0" + protocol: TCP + - containerPort: 443 + hostPort: 443 + listenAddress: "0.0.0.0" + protocol: TCP + - containerPort: 8080 + hostPort: 8080 + listenAddress: "0.0.0.0" + protocol: TCP +- role: worker +- role: worker \ No newline at end of file diff --git a/projeto-fsharp/k8s/metallb/metallb.yaml b/projeto-fsharp/k8s/metallb/metallb.yaml new file mode 100644 index 0000000..7312a4e --- /dev/null +++ b/projeto-fsharp/k8s/metallb/metallb.yaml @@ -0,0 +1,18 @@ +apiVersion: metallb.io/v1beta1 +kind: IPAddressPool +metadata: + name: private-subnet-pool + namespace: metallb-system +spec: + addresses: + - 172.18.0.240-172.18.0.250 + +--- +apiVersion: metallb.io/v1beta1 +kind: L2Advertisement +metadata: + name: private-subnet-advertisement + namespace: metallb-system +spec: + ipAddressPools: + - private-subnet-pool From f7fb093f94c4da233efc5749e511cb1cfea07703 Mon Sep 17 00:00:00 2001 From: Vitor da Costa Silva Date: Sun, 12 Nov 2023 22:15:46 -0300 Subject: [PATCH 49/53] fix: apply.sh k8s --- projeto-fsharp/apply.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/projeto-fsharp/apply.sh b/projeto-fsharp/apply.sh index ea76ef8..1acf4b6 100755 --- a/projeto-fsharp/apply.sh +++ b/projeto-fsharp/apply.sh @@ -24,6 +24,9 @@ function _apply_manifests () { kubectl apply -f ./k8s/service/service.yaml kubectl apply -f ./k8s/ingress/deploy.yaml sleep 360 + echo -e "\n---> Caso oocorra problema ao aplicar o ingress, aguarde mais alguns minutos e tente rodar executar novamente de forma mannual: \n" + echo -e "Command:kubectl apply -f ./k8s/ingress/ingress.yaml" + echo -e "\nAplicando ingress:\n" kubectl apply -f ./k8s/ingress/ingress.yaml } From 134560294d6b03a284655f4dab6c9d6baf5b3a96 Mon Sep 17 00:00:00 2001 From: Vitor da Costa Silva Date: Mon, 13 Nov 2023 00:45:34 -0300 Subject: [PATCH 50/53] fix: backup files --- .DS_Store | Bin 8196 -> 8196 bytes .gitignore | 9 + projeto-fsharp/Makefile | 4 +- projeto-fsharp/apply.sh | 34 +++ projeto-fsharp/k8s/deployment/deployment.yaml | 41 +++- projeto-fsharp/k8s/ingress/ingress.yaml | 12 +- projeto-fsharp/k8s/kind/config.yaml | 25 +++ projeto-fsharp/k8s/metallb/metallb.yaml | 18 ++ .../k8s/metrics-server/components.yaml | 197 ++++++++++++++++++ terraform/.DS_Store | Bin 0 -> 6148 bytes terraform/.terraform.lock.hcl | 21 ++ terraform/main.tf | 96 +++++++++ terraform/ssh/vm-api-devops-challenge | 27 +++ terraform/ssh/vm-api-devops-challenge.pub | 1 + terraform/variables.tf | 57 +++++ 15 files changed, 525 insertions(+), 17 deletions(-) create mode 100644 .gitignore create mode 100755 projeto-fsharp/apply.sh create mode 100644 projeto-fsharp/k8s/kind/config.yaml create mode 100644 projeto-fsharp/k8s/metallb/metallb.yaml create mode 100644 projeto-fsharp/k8s/metrics-server/components.yaml create mode 100644 terraform/.DS_Store create mode 100644 terraform/.terraform.lock.hcl create mode 100644 terraform/main.tf create mode 100644 terraform/ssh/vm-api-devops-challenge create mode 100644 terraform/ssh/vm-api-devops-challenge.pub create mode 100644 terraform/variables.tf diff --git a/.DS_Store b/.DS_Store index e3428caed4dbac1e3e5ef90ebaf726eac27c3988..7497a7c21a5a5732959c833c76e4b4b4a39ab445 100644 GIT binary patch delta 186 zcmZp1XmOa}&&a+pU^hP_`{WM-3Y&EVHn0hEGL$f+G86$}B10NOK9J6xtRryT2#a`1 cadJ*letr%E5MYs>d{#_;GrPo9Dw`<-06iKl>i_@% delta 44 vcmZp1XmOa}&&aYdU^hP_%j6FN3Y&EVHn2_pE-tXKL7H(hyTnx}M}iRmSsD*J diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b44637d --- /dev/null +++ b/.gitignore @@ -0,0 +1,9 @@ +/terraform/.terraform +/terraform/terraform.tfstate +/terraform/terraform.tfstate.backup +/terraform/teste.sh + +# **/.terraform/* +# terraform.tfstate +# terraform.tfstate.backup +# teste.sh \ No newline at end of file diff --git a/projeto-fsharp/Makefile b/projeto-fsharp/Makefile index 98a05f8..10819b3 100644 --- a/projeto-fsharp/Makefile +++ b/projeto-fsharp/Makefile @@ -1,8 +1,8 @@ build: - @docker build -t vitorcostasilva/api-devops-challenge:1.0 . + @docker build -t api-devops-challenge:latest . run: - @docker run -d -p 8085:8085 --name api-devops-challenge vitorcostasilva/api-devops-challenge:1.0 + @docker run -d -p 8085:8085 --name api-devops-challenge api-devops-challenge:latest compose: #export DOCKER_DEFAULT_PLATFORM=linux/arm64 diff --git a/projeto-fsharp/apply.sh b/projeto-fsharp/apply.sh new file mode 100755 index 0000000..1acf4b6 --- /dev/null +++ b/projeto-fsharp/apply.sh @@ -0,0 +1,34 @@ +#!/bin/bash + +function _create_cluster () { + kind create cluster \ + --config ./k8s/kind/config.yaml \ + --name api-devops-challenge + + _apply_manifests + _clean +} + +function _clean () { + rm -f get-docker.sh +} + +function _apply_manifests () { + export KUBECONFIG=$HOME/.kube/config + kubectl apply -f https://raw.githubusercontent.com/metallb/metallb/v0.13.11/config/manifests/metallb-native.yaml + sleep 60 + kubectl apply -f ./k8s/metallb/metallb.yaml + kubectl apply -f ./k8s/metrics-server/components.yaml + sleep 10 + kubectl apply -f ./k8s/deployment/deployment.yaml + kubectl apply -f ./k8s/service/service.yaml + kubectl apply -f ./k8s/ingress/deploy.yaml + sleep 360 + echo -e "\n---> Caso oocorra problema ao aplicar o ingress, aguarde mais alguns minutos e tente rodar executar novamente de forma mannual: \n" + echo -e "Command:kubectl apply -f ./k8s/ingress/ingress.yaml" + echo -e "\nAplicando ingress:\n" + kubectl apply -f ./k8s/ingress/ingress.yaml +} + +#Create Clustes and apply manifests +[ ! -z "`kind version`" ] && _create_cluster diff --git a/projeto-fsharp/k8s/deployment/deployment.yaml b/projeto-fsharp/k8s/deployment/deployment.yaml index fb2ffb8..10acfab 100644 --- a/projeto-fsharp/k8s/deployment/deployment.yaml +++ b/projeto-fsharp/k8s/deployment/deployment.yaml @@ -1,3 +1,29 @@ +apiVersion: autoscaling/v2 +kind: HorizontalPodAutoscaler +metadata: + name: api-devops-challenge-hpa +spec: + metrics: + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: 60 + - type: Resource + resource: + name: memory + target: + type: Utilization + averageValue: 100Mi + minReplicas: 3 + maxReplicas: 6 + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: api-devops-challenge + +--- apiVersion: apps/v1 kind: Deployment metadata: @@ -21,7 +47,14 @@ spec: httpGet: path: "/endpoint/get/hello" port: 8085 - # livenessProbe: - # httpGet: - # path: "/" - # port: 8085 + livenessProbe: + httpGet: + path: "/endpoint/get/hello" + port: 8085 + resources: + requests: + cpu: 50m + memory: 512M + limits: + cpu: 100m + memory: 1G diff --git a/projeto-fsharp/k8s/ingress/ingress.yaml b/projeto-fsharp/k8s/ingress/ingress.yaml index 949de33..9b01faa 100644 --- a/projeto-fsharp/k8s/ingress/ingress.yaml +++ b/projeto-fsharp/k8s/ingress/ingress.yaml @@ -18,14 +18,4 @@ spec: service: name: api-devops-challenge port: - number: 80 - # - host: "httpd.demo.com" - # http: - # paths: - # - path: / - # pathType: Prefix - # backend: - # service: - # name: httpd - # port: - # number: 80 \ No newline at end of file + number: 80 \ No newline at end of file diff --git a/projeto-fsharp/k8s/kind/config.yaml b/projeto-fsharp/k8s/kind/config.yaml new file mode 100644 index 0000000..b4b0a1e --- /dev/null +++ b/projeto-fsharp/k8s/kind/config.yaml @@ -0,0 +1,25 @@ +kind: Cluster +apiVersion: kind.x-k8s.io/v1alpha4 +nodes: +- role: control-plane + kubeadmConfigPatches: + - | + kind: InitConfiguration + nodeRegistration: + kubeletExtraArgs: + node-labels: "ingress-ready=true" + extraPortMappings: + - containerPort: 80 + hostPort: 80 + listenAddress: "0.0.0.0" + protocol: TCP + - containerPort: 443 + hostPort: 443 + listenAddress: "0.0.0.0" + protocol: TCP + - containerPort: 8080 + hostPort: 8080 + listenAddress: "0.0.0.0" + protocol: TCP +- role: worker +- role: worker \ No newline at end of file diff --git a/projeto-fsharp/k8s/metallb/metallb.yaml b/projeto-fsharp/k8s/metallb/metallb.yaml new file mode 100644 index 0000000..7312a4e --- /dev/null +++ b/projeto-fsharp/k8s/metallb/metallb.yaml @@ -0,0 +1,18 @@ +apiVersion: metallb.io/v1beta1 +kind: IPAddressPool +metadata: + name: private-subnet-pool + namespace: metallb-system +spec: + addresses: + - 172.18.0.240-172.18.0.250 + +--- +apiVersion: metallb.io/v1beta1 +kind: L2Advertisement +metadata: + name: private-subnet-advertisement + namespace: metallb-system +spec: + ipAddressPools: + - private-subnet-pool diff --git a/projeto-fsharp/k8s/metrics-server/components.yaml b/projeto-fsharp/k8s/metrics-server/components.yaml new file mode 100644 index 0000000..ce7ec2c --- /dev/null +++ b/projeto-fsharp/k8s/metrics-server/components.yaml @@ -0,0 +1,197 @@ +apiVersion: v1 +kind: ServiceAccount +metadata: + labels: + k8s-app: metrics-server + name: metrics-server + namespace: kube-system +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + labels: + k8s-app: metrics-server + rbac.authorization.k8s.io/aggregate-to-admin: "true" + rbac.authorization.k8s.io/aggregate-to-edit: "true" + rbac.authorization.k8s.io/aggregate-to-view: "true" + name: system:aggregated-metrics-reader +rules: +- apiGroups: + - metrics.k8s.io + resources: + - pods + - nodes + verbs: + - get + - list + - watch +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + labels: + k8s-app: metrics-server + name: system:metrics-server +rules: +- apiGroups: + - "" + resources: + - nodes/metrics + verbs: + - get +- apiGroups: + - "" + resources: + - pods + - nodes + verbs: + - get + - list + - watch +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: RoleBinding +metadata: + labels: + k8s-app: metrics-server + name: metrics-server-auth-reader + namespace: kube-system +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: Role + name: extension-apiserver-authentication-reader +subjects: +- kind: ServiceAccount + name: metrics-server + namespace: kube-system +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + labels: + k8s-app: metrics-server + name: metrics-server:system:auth-delegator +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: system:auth-delegator +subjects: +- kind: ServiceAccount + name: metrics-server + namespace: kube-system +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + labels: + k8s-app: metrics-server + name: system:metrics-server +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: system:metrics-server +subjects: +- kind: ServiceAccount + name: metrics-server + namespace: kube-system +--- +apiVersion: v1 +kind: Service +metadata: + labels: + k8s-app: metrics-server + name: metrics-server + namespace: kube-system +spec: + ports: + - name: https + port: 443 + protocol: TCP + targetPort: https + selector: + k8s-app: metrics-server +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + labels: + k8s-app: metrics-server + name: metrics-server + namespace: kube-system +spec: + selector: + matchLabels: + k8s-app: metrics-server + strategy: + rollingUpdate: + maxUnavailable: 0 + template: + metadata: + labels: + k8s-app: metrics-server + spec: + containers: + - args: + - --cert-dir=/tmp + - --secure-port=4443 + - --kubelet-preferred-address-types=InternalIP,ExternalIP,Hostname + - --kubelet-use-node-status-port + - --kubelet-insecure-tls + - --metric-resolution=15s + image: registry.k8s.io/metrics-server/metrics-server:v0.6.4 + imagePullPolicy: IfNotPresent + livenessProbe: + failureThreshold: 3 + httpGet: + path: /livez + port: https + scheme: HTTPS + periodSeconds: 10 + name: metrics-server + ports: + - containerPort: 4443 + name: https + protocol: TCP + readinessProbe: + failureThreshold: 3 + httpGet: + path: /readyz + port: https + scheme: HTTPS + initialDelaySeconds: 20 + periodSeconds: 10 + resources: + requests: + cpu: 100m + memory: 200Mi + securityContext: + allowPrivilegeEscalation: false + readOnlyRootFilesystem: true + runAsNonRoot: true + runAsUser: 1000 + volumeMounts: + - mountPath: /tmp + name: tmp-dir + nodeSelector: + kubernetes.io/os: linux + priorityClassName: system-cluster-critical + serviceAccountName: metrics-server + volumes: + - emptyDir: {} + name: tmp-dir +--- +apiVersion: apiregistration.k8s.io/v1 +kind: APIService +metadata: + labels: + k8s-app: metrics-server + name: v1beta1.metrics.k8s.io +spec: + group: metrics.k8s.io + groupPriorityMinimum: 100 + insecureSkipTLSVerify: true + service: + name: metrics-server + namespace: kube-system + version: v1beta1 + versionPriority: 100 diff --git a/terraform/.DS_Store b/terraform/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..5008ddfcf53c02e82d7eee2e57c38e5672ef89f6 GIT binary patch literal 6148 zcmeH~Jr2S!425mzP>H1@V-^m;4Wg<&0T*E43hX&L&p$$qDprKhvt+--jT7}7np#A3 zem<@ulZcFPQ@L2!n>{z**++&mCkOWA81W14cNZlEfg7;MkzE(HCqgga^y>{tEnwC%0;vJ&^%eQ zLs35+`xjp>T0 Date: Mon, 13 Nov 2023 12:10:46 -0300 Subject: [PATCH 51/53] feat: Add pipeline-provision --- .github/workflows/pipeline-provision.yml | 38 ++++++++++++++++++++++++ .github/workflows/pipeline.yml | 3 +- 2 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/pipeline-provision.yml diff --git a/.github/workflows/pipeline-provision.yml b/.github/workflows/pipeline-provision.yml new file mode 100644 index 0000000..bf52250 --- /dev/null +++ b/.github/workflows/pipeline-provision.yml @@ -0,0 +1,38 @@ +name: 'Provision Azure' + +on: + push: + branches: [ "develop" ] + +jobs: + terraform: + name: 'Terraform' + runs-on: ubuntu-latest + defaults: + run: + working-directory: terraform + + permissions: + contents: read + packages: write + + steps: + - name: Checkout Repository + uses: actions/checkout@v3 + + - name: Setup Terraform + uses: hashicorp/setup-terraform@v2 + + - name: Azure Login + uses: Azure/login@v1.4.6 + with: + creds: ${{ secrets.AZURE_CREDENTIALS }} + + - name: Terraform Init + run: terraform init + + - name: Terraform Plan + run: terraform plan + + - name: Terraform Apply + run: terraform apply -auto-approve \ No newline at end of file diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index 144d3b8..78e60dd 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -4,6 +4,7 @@ name: Build and Push Project on: push: branches: [ "master" ] + # branches: [ "master","develop" ] env: REGISTRY: ghcr.io @@ -17,7 +18,7 @@ jobs: packages: write steps: - - name: Realizando checkout do repositório + - name: Checkout Repository uses: actions/checkout@v4 - name: Set up QEMU From b9cd9eb8fe5bfdc739f830a667849f947b2044ca Mon Sep 17 00:00:00 2001 From: Vitor da Costa Silva Date: Mon, 13 Nov 2023 19:14:02 -0300 Subject: [PATCH 52/53] feat: Add Revision 1 --- .../{pipeline.yml => pipeline-build-push.yml} | 6 +- .github/workflows/pipeline-provision.yml | 4 +- README.md | 113 ++++++++++++++---- README2.md | 30 +++++ projeto-fsharp/Dockerfile | 2 +- projeto-fsharp/Makefile | 2 +- projeto-fsharp/docker-compose.yaml | 7 +- 7 files changed, 133 insertions(+), 31 deletions(-) rename .github/workflows/{pipeline.yml => pipeline-build-push.yml} (89%) create mode 100644 README2.md diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline-build-push.yml similarity index 89% rename from .github/workflows/pipeline.yml rename to .github/workflows/pipeline-build-push.yml index 78e60dd..fac5427 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline-build-push.yml @@ -3,8 +3,10 @@ name: Build and Push Project on: push: - branches: [ "master" ] - # branches: [ "master","develop" ] + branches: [ "master","develop" ] + paths: + - 'projeto-fsharp/Dockerfile' + - 'projeto-fsharp/**' env: REGISTRY: ghcr.io diff --git a/.github/workflows/pipeline-provision.yml b/.github/workflows/pipeline-provision.yml index bf52250..403e4b2 100644 --- a/.github/workflows/pipeline-provision.yml +++ b/.github/workflows/pipeline-provision.yml @@ -2,7 +2,9 @@ name: 'Provision Azure' on: push: - branches: [ "develop" ] + branches: [ "master","develop" ] + paths: + - terraform/** jobs: terraform: diff --git a/README.md b/README.md index 9e2060e..c5b8c75 100644 --- a/README.md +++ b/README.md @@ -1,30 +1,99 @@ -# Datapi DevOps Challenge +# Documentação Devops Challenge -Para melhor entendermos o seu nível técnico, nós preparamos este desafio como parte do nosso processo de contratação. Por isso, tenha em mente que não é necessário cumprir com todos os pontos mencionados, nem cumpri-los em uma ordem específica. +## Sobre -O importante é entregar o que você conseguir fazer, com a devida documentação. +Toda a construção do projeto foi utilizado o conceito de namespace, por questões de organização e também por motivos de controle sobre o acesso. -# Desafios +Como apoio na organização dos códigos e branches foi utilizada a extensão `Git-Flow`. -Segue abaixo uma lista de desafios abrangendo várias áreas de responsabilidade para um DevOps no time do Datapi. Nossa sugestão é tentar seguir cada item na ordem apresentada, porém você está livre para atuar nos pontos que quiser e tiver mais familiaridade. +# Requisitos para utilização do script -- Instanciar uma VM numa cloud provider. Recomendação: Microsoft Azure. - - Criar a configuração dessa VM usando uma ferramenta de IaC (Infrastructure as Code). Recomendação: Terraform. - - Criar um job de CI (Continuous Integration) para aplicar a configuração da ferramenta de provisionamento. Recomendação: GitHub Actions. -- Adicionar um Dockerfile à aplicação disponibilizada na pasta `projeto-fsharp/` para containerizar o mesmo. Note que foi utilizada a linguagem F# (.NET) para escrever a aplicação. Para facilitar o entendimento do projeto, adicionamos um README.md com instruções de teste e uso do mesmo localmente. Você deverá ser capaz de traduzir essas instruções para a criação do Dockerfile. - - Criar um job de CI para enviar a imagem gerada para um Docker Registry. Recomendação: GitHub Container Registry. -- Criar os manifestos YAML para hospedar a aplicação usando Kubernetes. Nesse ponto os testes podem ser realizados apenas localmente, porém devem ser apresentados os arquivos YAML criados. - * Utilizar IaC para configurar o Kubernetes. Recomendação: Terraform. - * Configurar a hospedagem a partir do registry gerado na tarefa anterior. - * Caso possua mais familiaridade, sinta-se motivado a customizar mais as configurações (secrets, ingress, etc.). -- Adicionar um README ao projeto detalhando o processo e justificando as decisões tomadas. Recomendação: Markdown. Todos os refinamentos adicionados nos tópicos mencionados anteriormente, e demais ideias que possam melhorar o projeto serão considerados na avaliação da solução. +Segue todos os requisitos necessários para utilização do script: -Faça um fork e envie um PR com a sua solução, o tempo de entrega é de no máximo 4 dias e será contabilizado a partir da data do fork. +- 1- Realizar a Instalação do Docker. -## Será avaliado: +- 2- Realizar a instalação do Make(Ferramenta utilizada para automatizar o processo de contrução de imagens docker). -- % do que foi entregue em relação ao que foi pedido. -- Qualidade dos aquivos Terraform. -- Boas práticas de infra e uso do Kubernetes. -- Corretude das tarefas. -- Uso eficiente em relação ao custo de máquina. +Segue os passos para instalação em sistemas Linux(Ubuntu e Debian): +``` +$ sudo apt-get update +$ sudo apt-get install make + +``` + +# Dockerfile + +O `dockerfile` na qual está localizado na raiz do projeto `projeto-fsharp` foi desenvolvido utilizando boas práticas como Multi-stage builds, priorizando sempre a redução do tamanho da imagem e garantindo que as layers sejam executadas de forma performática. +Imagens utilizadas: +- Builder: mcr.microsoft.com/dotnet/sdk:6.0.413 +- Runtime: mcr.microsoft.com/dotnet/aspnet:6.0.0 + +Apesar do formato yaml ser bem legível, foi documentado o `Dockerfile.yaml` a partir de comentários todos os passos realizados e a definição de cada passo. + + + +# Ambiente de Desenvolvimento + +Foi criado para o projeto um ambiente de desenvolvimento para execução e testes da API. + +Para o ambiente de desenvolvimento utilizamos o `Make` que é uma ferramenta utilizada para automações de processos sendo muito útil para ambiente de desenvolvimento aumentando a produtividade e eficiência, sendo assim todo o processo de build da imagem, run e compose build foram utilizando essa ferramenta. + +## docker-compose.yaml + +O `docker-compose.yaml` na qual está localizado na raiz do projeto foi construido com todas as instruções necessárias para execução e testes da API, dessa forma proporcionou uma melhor eficiencia no desenvolvimento. + +## Utilização do Script + +Atualmente existem 3 funcionalidades disponíveis para utilização do script, sendo elas: +1-build: + O comando `build` executa a construção da imagem a partir das instruções que estão presentes no `Dockerfile.yaml` incluindo o nome da imagem sendo `api-devops-challenge:latest`. + A partir do diretório raiz do projeto execute o comando abaixo: +``` +$ make build +``` + +2-run: + O comando `run` executa a imagem `api-devops-challenge:latest` gerada a partir do comando de build visto anteriormente. + A partir do diretório raiz do projeto execute o comando abaixo: + +``` +$ make run +``` + +3-compose: + O comando `compose` ele é o responsável por subir todo o projeto e pronto para ser utilizado. + Este comando executa a construção da imagem a partir das instruções que estão presentes no `Dockerfile.yaml`, e faz o export das portas necessárias para acesso a aplicação. + A partir do diretório raiz do projeto execute o comando abaixo: + +``` +$ make compose +``` + +# k8s + +A ferramenta utilizada para simulação do ambiente kubernetes foi o `kind` onde foi criado 1 control-plane e 2 data-planes para o nosso cluster, todas essas definições foram feitas no arquivo `config.yaml` disponível no diretório `/k8s/kind/config.yaml`. + +Todos os manifestos utilizados para deploy no cluster k8s como deployment, service, ingress e etc estão disponíveis e que podem ser acessado a partir do caminho `/k8s`. + +Contamos também com a automação desenvolvida a partir do script `apply.sh` localizado também na raiz do projeto na qual ele é o responsável por realizar toda a criação do cluster, fazer as aplicações dos manifestos e deixar tudo pronto para o usuário. +Dessa forma faz com que todo o ambiente fique disponível com apenas a execução do mesmo: +(necessário ser executado a partir do diretório raiz do projeto) + +``` +$ ./apply.sh + +``` + +# Pipeline CI/CD Git Hub Actions + +Foram criados 2 workflows sendo eles: + +- pipeline-build-push.yml + Pipeline responsável por fazer toda a automação build, gerar versão\tag, realizar o push da imagem para o repositório do `ghcr.io`. + +``` +Obs: A imagem gerada é compatível com processadores x86(linux/amd64) e ARM(linux/arm64) e ambos estão disponíveis no repositório do `ghcr.io`. +``` + +- pipeline-provision.yml + Pipeline responsável por fazer o provisionamento da infra infraestrutura na Azure Cloud. diff --git a/README2.md b/README2.md new file mode 100644 index 0000000..9e2060e --- /dev/null +++ b/README2.md @@ -0,0 +1,30 @@ +# Datapi DevOps Challenge + +Para melhor entendermos o seu nível técnico, nós preparamos este desafio como parte do nosso processo de contratação. Por isso, tenha em mente que não é necessário cumprir com todos os pontos mencionados, nem cumpri-los em uma ordem específica. + +O importante é entregar o que você conseguir fazer, com a devida documentação. + +# Desafios + +Segue abaixo uma lista de desafios abrangendo várias áreas de responsabilidade para um DevOps no time do Datapi. Nossa sugestão é tentar seguir cada item na ordem apresentada, porém você está livre para atuar nos pontos que quiser e tiver mais familiaridade. + +- Instanciar uma VM numa cloud provider. Recomendação: Microsoft Azure. + - Criar a configuração dessa VM usando uma ferramenta de IaC (Infrastructure as Code). Recomendação: Terraform. + - Criar um job de CI (Continuous Integration) para aplicar a configuração da ferramenta de provisionamento. Recomendação: GitHub Actions. +- Adicionar um Dockerfile à aplicação disponibilizada na pasta `projeto-fsharp/` para containerizar o mesmo. Note que foi utilizada a linguagem F# (.NET) para escrever a aplicação. Para facilitar o entendimento do projeto, adicionamos um README.md com instruções de teste e uso do mesmo localmente. Você deverá ser capaz de traduzir essas instruções para a criação do Dockerfile. + - Criar um job de CI para enviar a imagem gerada para um Docker Registry. Recomendação: GitHub Container Registry. +- Criar os manifestos YAML para hospedar a aplicação usando Kubernetes. Nesse ponto os testes podem ser realizados apenas localmente, porém devem ser apresentados os arquivos YAML criados. + * Utilizar IaC para configurar o Kubernetes. Recomendação: Terraform. + * Configurar a hospedagem a partir do registry gerado na tarefa anterior. + * Caso possua mais familiaridade, sinta-se motivado a customizar mais as configurações (secrets, ingress, etc.). +- Adicionar um README ao projeto detalhando o processo e justificando as decisões tomadas. Recomendação: Markdown. Todos os refinamentos adicionados nos tópicos mencionados anteriormente, e demais ideias que possam melhorar o projeto serão considerados na avaliação da solução. + +Faça um fork e envie um PR com a sua solução, o tempo de entrega é de no máximo 4 dias e será contabilizado a partir da data do fork. + +## Será avaliado: + +- % do que foi entregue em relação ao que foi pedido. +- Qualidade dos aquivos Terraform. +- Boas práticas de infra e uso do Kubernetes. +- Corretude das tarefas. +- Uso eficiente em relação ao custo de máquina. diff --git a/projeto-fsharp/Dockerfile b/projeto-fsharp/Dockerfile index 0794cc0..9495e26 100644 --- a/projeto-fsharp/Dockerfile +++ b/projeto-fsharp/Dockerfile @@ -6,7 +6,7 @@ COPY . . RUN ./restore.sh && \ dotnet fake run build.fsx -t "Build" -#Iniciando Server. (Multistaging) +#Iniciando Server. (Multi-stage) FROM mcr.microsoft.com/dotnet/aspnet:6.0.0 AS runtime WORKDIR /api EXPOSE 8085 diff --git a/projeto-fsharp/Makefile b/projeto-fsharp/Makefile index 10819b3..a745ebb 100644 --- a/projeto-fsharp/Makefile +++ b/projeto-fsharp/Makefile @@ -5,6 +5,6 @@ run: @docker run -d -p 8085:8085 --name api-devops-challenge api-devops-challenge:latest compose: - #export DOCKER_DEFAULT_PLATFORM=linux/arm64 + # export DOCKER_DEFAULT_PLATFORM=linux/arm64 @docker compose build @docker compose up \ No newline at end of file diff --git a/projeto-fsharp/docker-compose.yaml b/projeto-fsharp/docker-compose.yaml index a2d9d50..28b3089 100644 --- a/projeto-fsharp/docker-compose.yaml +++ b/projeto-fsharp/docker-compose.yaml @@ -2,10 +2,9 @@ version: "3.8" services: api-devops-challenge: - image: vitorcostasilva/api-devops-challenge:1.0 - # build: - # context: . - # restart: always + # image: vitorcostasilva/api-devops-challenge:1.0 + build: + context: . container_name: api-devops-challenge ports: - 8085:8085 \ No newline at end of file From 1447b26fc9d0c5de4345867c0d23966869db3881 Mon Sep 17 00:00:00 2001 From: Vitor da Costa Silva Date: Mon, 13 Nov 2023 19:31:20 -0300 Subject: [PATCH 53/53] feat: Add Revision 2 --- README.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index c5b8c75..10b21a9 100644 --- a/README.md +++ b/README.md @@ -88,12 +88,14 @@ $ ./apply.sh Foram criados 2 workflows sendo eles: -- pipeline-build-push.yml - Pipeline responsável por fazer toda a automação build, gerar versão\tag, realizar o push da imagem para o repositório do `ghcr.io`. +- `pipeline-build-push.yml` + +Pipeline responsável por fazer toda a automação build, gerar versão\tag, realizar o push da imagem para o repositório do `ghcr.io`. ``` Obs: A imagem gerada é compatível com processadores x86(linux/amd64) e ARM(linux/arm64) e ambos estão disponíveis no repositório do `ghcr.io`. ``` -- pipeline-provision.yml - Pipeline responsável por fazer o provisionamento da infra infraestrutura na Azure Cloud. +- `pipeline-provision.yml` + +Pipeline responsável por fazer o provisionamento da infra infraestrutura na Azure Cloud.