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

Iniciativa devops030822 #19

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open
63 changes: 63 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# This is a basic workflow to help you get started with Actions

name: CI-CD

on:

# Triggers the workflow on push or pull request events but only for the "main" branch

push:
branches: [ "main" ]

workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
CI:
# The type of runner that the job will run on
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Autenticando o usuário no Docker
uses: docker/[email protected]
with:
username: ${{secrets.DOCKERHUB_USER}}
password: ${{secrets.DOCKERHUB_PWD}}

- name: Construindo a imagem e enviando para o Docker Hub
uses: docker/[email protected]
with:
file: ./src/Dockerfile
context: ./src
push: true
tags: |
carlosmagnogcs/kube-news:latest
carlosmagnogcs/kube-news:${{github.run_number}}
CD:
runs-on: ubuntu-latest
needs: [CI]
steps:
- uses: actions/checkout@v3

- name: Definindo o Kube config
uses: Azure/[email protected]
with:
method: kubeconfig
kubeconfig: ${{secrets.K8S_CONFIG}}

- name: Efetuando o deploy no Kubernetes no ambiente de teste
uses: Azure/[email protected]
with:
images: carlosmagnogcs/kube-news:${{github.run_number}}
manifests: |
k8s/deployment.yaml







212 changes: 106 additions & 106 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,106 +1,106 @@
# # Logs
# logs
# *.log
# npm-debug.log*
# yarn-debug.log*
# yarn-error.log*
# lerna-debug.log*

# # Diagnostic reports (https://nodejs.org/api/report.html)
# report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# # Runtime data
# pids
# *.pid
# *.seed
# *.pid.lock

# # Directory for instrumented libs generated by jscoverage/JSCover
# lib-cov

# # Coverage directory used by tools like istanbul
# coverage
# *.lcov

# # nyc test coverage
# .nyc_output

# # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
# .grunt

# # Bower dependency directory (https://bower.io/)
# bower_components

# # node-waf configuration
# .lock-wscript

# # Compiled binary addons (https://nodejs.org/api/addons.html)
# build/Release

# # Dependency directories
node_modules/
# jspm_packages/

# # TypeScript v1 declaration files
# typings/

# # TypeScript cache
# *.tsbuildinfo

# # Optional npm cache directory
# .npm

# # Optional eslint cache
# .eslintcache

# # Microbundle cache
# .rpt2_cache/
# .rts2_cache_cjs/
# .rts2_cache_es/
# .rts2_cache_umd/

# # Optional REPL history
# .node_repl_history

# # Output of 'npm pack'
# *.tgz

# # Yarn Integrity file
# .yarn-integrity

# # dotenv environment variables file
# .env
# .env.test

# # parcel-bundler cache (https://parceljs.org/)
# .cache

# # Next.js build output
# .next

# # Nuxt.js build / generate output
# .nuxt
# dist

# # Gatsby files
# .cache/
# # Comment in the public line in if your project uses Gatsby and *not* Next.js
# # https://nextjs.org/blog/next-9-1#public-directory-support
# # public

# # vuepress build output
# .vuepress/dist

# # Serverless directories
# .serverless/

# # FuseBox cache
# .fusebox/

# # DynamoDB Local files
# .dynamodb/

# # TernJS port file
# .tern-port

*.Identifier
# # Logs
# logs
# *.log
# npm-debug.log*
# yarn-debug.log*
# yarn-error.log*
# lerna-debug.log*
# # Diagnostic reports (https://nodejs.org/api/report.html)
# report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
# # Runtime data
# pids
# *.pid
# *.seed
# *.pid.lock
# # Directory for instrumented libs generated by jscoverage/JSCover
# lib-cov
# # Coverage directory used by tools like istanbul
# coverage
# *.lcov
# # nyc test coverage
# .nyc_output
# # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
# .grunt
# # Bower dependency directory (https://bower.io/)
# bower_components
# # node-waf configuration
# .lock-wscript
# # Compiled binary addons (https://nodejs.org/api/addons.html)
# build/Release
# # Dependency directories
node_modules/
# jspm_packages/
# # TypeScript v1 declaration files
# typings/
# # TypeScript cache
# *.tsbuildinfo
# # Optional npm cache directory
# .npm
# # Optional eslint cache
# .eslintcache
# # Microbundle cache
# .rpt2_cache/
# .rts2_cache_cjs/
# .rts2_cache_es/
# .rts2_cache_umd/
# # Optional REPL history
# .node_repl_history
# # Output of 'npm pack'
# *.tgz
# # Yarn Integrity file
# .yarn-integrity
# # dotenv environment variables file
# .env
# .env.test
# # parcel-bundler cache (https://parceljs.org/)
# .cache
# # Next.js build output
# .next
# # Nuxt.js build / generate output
# .nuxt
# dist
# # Gatsby files
# .cache/
# # Comment in the public line in if your project uses Gatsby and *not* Next.js
# # https://nextjs.org/blog/next-9-1#public-directory-support
# # public
# # vuepress build output
# .vuepress/dist
# # Serverless directories
# .serverless/
# # FuseBox cache
# .fusebox/
# # DynamoDB Local files
# .dynamodb/
# # TernJS port file
# .tern-port
*.Identifier
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
# kube-news
# kube-news
# projeto kube-news iniciativa devops 0822
# teste 07/08/22
# teste 07/08/22 - pasta actions
78 changes: 78 additions & 0 deletions k8s/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# Deployment do Postgre
apiVersion: apps/v1
kind: Deployment
metadata:
name: postgre
spec:
selector:
matchLabels:
app: postgre
template:
metadata:
labels:
app: postgre
spec:
containers:
- name: postgre
image: postgres:14.3
ports:
- containerPort: 5432
env:
- name: POSTGRES_PASSWORD
value: "Kubenews@1234"
- name: POSTGRES_USER
value: "kubenews"
- name: POSTGRES_DB
value: "kubenews"
---
apiVersion: v1
kind: Service
metadata:
name: postgre
spec:
selector:
app: postgre
ports:
- port: 5432
targetPort: 5432
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: kubenews
spec:
#mudando replicas novamente
replicas: 20
selector:
matchLabels:
app: kubenews
template:
metadata:
labels:
app: kubenews
spec:
containers:
- name: kubenews
image: carlosmagnogcs/kube-news:v2
env:
- name: DB_DATABASE
value: "kubenews"
- name: DB_USERNAME
value: "kubenews"
- name: DB_PASSWORD
value: "Kubenews@1234"
- name: DB_HOST
value: postgre
---
apiVersion: v1
kind: Service
metadata:
name: kube-news
spec:
selector:
app: kubenews
ports:
- port: 80
targetPort: 8080
nodePort: 30000
type: LoadBalancer
1 change: 1 addition & 0 deletions src/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules/
7 changes: 7 additions & 0 deletions src/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM node:16.13.2
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
EXPOSE 8080
CMD ["node", "server.js"]
Loading