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

Deploymente kubernetes correcao #37

Open
wants to merge 6 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
47 changes: 47 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: CI+CD

on:
push:
branches: [ conf-kubernetes ]

workflow_dispatch:

jobs:
CI:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Docker Login
uses: docker/[email protected]
with:
username: ${{ secrets.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_PWD }}

- name: Docker build and Push
uses: docker/[email protected]
with:
context: ./src
file: ./src/Dockerfile
push: true
tags:
763ed2a0a734/conversao-temperatura:latest
CD:
needs: [CI]
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Kubernetes Set Context
uses: Azure/[email protected]
with:
method: kubeconfig
kubeconfig: ${{ secrets.K8S_CONFIG }}

- name: Deploy to Kubernetes cluster
uses: Azure/[email protected]
with:
images: 763ed2a0a734/conversao-temperatura:latest
manifests: |
src/kubernetes/deployment.yaml
7 changes: 7 additions & 0 deletions src/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM node:14.17.5
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
EXPOSE 8080
CMD ["node", "server.js"]
32 changes: 32 additions & 0 deletions src/kubernetes/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: meudeployment
spec:
replicas: 1
selector:
matchLabels:
app: web
template:
metadata:
labels:
app: web
spec:
containers:
- name: web
image: 763ed2a0a734/conversao-temperatura:v1
ports:
- containerPort: 8080
---
apiVersion: v1
kind: Service
metadata:
name: web
spec:
selector:
app: web
ports:
- protocol: TCP
port: 8080
nodePort: 30000
type: NodePort