From 5f1965e1fe83afaddaacde4eece758f43b4c5fd5 Mon Sep 17 00:00:00 2001 From: magnomct Date: Wed, 3 Aug 2022 21:35:48 -0300 Subject: [PATCH 01/16] Iniciativa devops030822 Iniciativa devops030822 --- k8s/deployment.yaml | 77 +++++++++++++++++++++++++++++++++++ src/Dockerfile | 7 ++++ src/views/partial/nav-bar.ejs | 2 +- 3 files changed, 85 insertions(+), 1 deletion(-) create mode 100644 k8s/deployment.yaml create mode 100644 src/Dockerfile diff --git a/k8s/deployment.yaml b/k8s/deployment.yaml new file mode 100644 index 000000000..07e146af5 --- /dev/null +++ b/k8s/deployment.yaml @@ -0,0 +1,77 @@ +# 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: + replicas: 5 + 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: NodePort diff --git a/src/Dockerfile b/src/Dockerfile new file mode 100644 index 000000000..7e45e0fb9 --- /dev/null +++ b/src/Dockerfile @@ -0,0 +1,7 @@ +FROM node:16.13.2 +WORKDIR /app +COPY package*.json ./ +RUN npm install +COPY . . +EXPOSE 8080 +CMD ["node", "server.js"] \ No newline at end of file diff --git a/src/views/partial/nav-bar.ejs b/src/views/partial/nav-bar.ejs index bed961c34..d0158e64d 100644 --- a/src/views/partial/nav-bar.ejs +++ b/src/views/partial/nav-bar.ejs @@ -2,7 +2,7 @@