Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Acompanhamento das aulas #5

Open
wants to merge 21 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: CI-CD

on:
push:
branches: ["main"]
workflow_dispatch:
jobs:
ci:
runs-on: ubuntu-latest
steps:
- name: Obter o código do projeto
uses: actions/checkout@v4

-
name: Autenticar no Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

-
name: Construção e envio da imagem Docker
uses: docker/build-push-action@v6
with:
context: ./src
push: true
file: ./src/Dockerfile
tags: |
alexsilvarj/fake-shop:latest
alexsilvarj/fake-shop:v${{ github.run_number }}


cd:
runs-on: ubuntu-latest
needs: [ci]
permissions:
id-token: write
contents: read
actions: read
steps:
- name: Obter o código do projeto
uses: actions/checkout@v4

- name: Autenticar na AWS
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1

- name: Configurar o kubectl
run: aws eks update-kubeconfig --name eks-aula

- name: Deploy dos manifestos no Kubernetes
uses: Azure/k8s-deploy@v5
with:
manifests: |
./k8s/deployment.yaml
images: |
alexsilvarj/fake-shop:v${{ github.run_number }}
Binary file added grafana/CICD_rodando.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added grafana/dashboard_aplicacao.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added grafana/grafana_rodando.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added grafana/main.yaml.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added grafana/prometheus_rodando.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added grafana/site_rodando.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
96 changes: 96 additions & 0 deletions k8s/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: postgre
labels:
app: postgre
spec:
selector:
matchLabels:
app: postgre
template:
metadata:
name: postgre
labels:
app: postgre
spec:
containers:
- name: postgre
image: postgres:13.16
ports:
- containerPort: 5432
env:
- name: POSTGRES_DB
value: fakeshop
- name: POSTGRES_USER
value: fakeshop
- name: POSTGRES_PASSWORD
value: Pg1234

---

apiVersion: v1
kind: Service
metadata:
name: postgre
spec:
selector:
app: postgre
ports:
- port: 5432
targetPort: 5432

---
#Deployment da aplicação web

apiVersion: apps/v1
kind: Deployment
metadata:
name: fakeshop
labels:
app: fakeshop
spec:
replicas: 4
selector:
matchLabels:
app: fakeshop
template:
metadata:
annotations:
prometheus.io/scrape: 'true'
prometheus.io/port: '5000'
prometheus.io/path: '/metrics'
name: fakeshop
labels:
app: fakeshop
spec:
containers:
- name: fakeshop
image: alexsilvarj/fake-shop:v2
ports:
- containerPort: 5000
env:
- name: DB_HOST
value: postgre
- name: DB_USER
value: fakeshop
- name: DB_PASSWORD
value: Pg1234
- name: DB_NAME
value: fakeshop
- name: FLASK_APP
value: index.py

---

apiVersion: v1
kind: Service
metadata:
name: fakeshop
spec:
selector:
app: fakeshop
ports:
- port: 80
targetPort: 5000
type: LoadBalancer
Loading