Skip to content

Commit 0f99f0e

Browse files
authored
Merge pull request #6 from Lemoncode/feature/k8s-exercise
Feature/k8s exercise
2 parents 1d38b14 + dd372c3 commit 0f99f0e

File tree

129 files changed

+53390
-3
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

129 files changed

+53390
-3
lines changed

.gitignore

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,19 @@
1-
.DS_Store
1+
# environments
2+
.env
23

3-
# code Jenkins demos
4+
# dependencies
45
node_modules/
56

6-
.env
7+
# build
8+
wwwroot
9+
dist/
10+
11+
# vs code
12+
.DS_Store
13+
14+
# exercise solution
15+
exercise-solution/
16+
.DS_Store
17+
18+
# code Jenkins demos
719
app/
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Todo App React
2+
3+
## Run solution locally
4+
5+
First we need to install dependencies change directory to `todo-app/frontend` and run `npm install`, then change directory to `/todo-app` and run `npm install`. Once that all dependencies are installed, we can run the solution locally by changing directory to `todo-app/frontend` and running `npm run run-p -l start:server start:dev`.
6+
7+
## Environment Variables
8+
9+
```ini
10+
NODE_ENV=
11+
PORT=
12+
```
13+
14+
## Running the Application with Docker on Local
15+
16+
```bash
17+
$ docker build -t jaimesalas/lc-todo-monolith .
18+
```
19+
20+
Start app without database
21+
22+
```bash
23+
$ docker run -d -p 3000:3000 \
24+
-e NODE_ENV=production \
25+
-e PORT=3000 \
26+
jaimesalas/lc-todo-monolith
27+
```
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Monolito en memoria
2+
3+
## Enunciado
4+
5+
Construir los distintos recursos de Kubernetes para generar un clúster, como el de la siguiente imagen:
6+
7+
![monolith in memory](./monolith-in-mem.png)
8+
9+
### Para ello seguir los siguientes pasos:
10+
11+
### Paso 1. Crear todo-app
12+
13+
Crear un `Deployment` para `todo-app`, usar el `Dockerfile` de este direetorio **todo-app**, para generar la imagen necesaria.
14+
15+
Al ejecutar un contenedor a partir de la imagen anaterior, el puerto por defecto es el 3000, pero se lo podemos alimentar a partir de variables de entorono, las variables de entorno serían las siguientes
16+
17+
* **NODE_ENV** : El entorno en que se está ejecutando el contenedor, nos vale cualquier valor que no sea `test`
18+
* **PORT** : El puerto por el que va a escuchar el contenedor.
19+
20+
### Paso 2. Acceder a todo-app desde fuera del clúster
21+
22+
Crear un `LoadBalancer service` para acceder al `Deployment` anteriormente creado desde fuera del clúster. Para poder utilizar un `LoadBalancer` con minikube seguir las instrucciones de este [artículo](https://minikube.sigs.k8s.io/docs/handbook/accessing/)
23+
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<mxfile modified="2020-12-06T19:04:03.748Z" host="app.diagrams.net" agent="5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36" etag="7qDEBO5y6vxC52D70SB4" version="13.10.9" type="device"><diagram id="WI9T0HZ2pTsCkuznbFz-" name="Page-1">3Vlbb6M4FP41eSwyBgI8pmnTXXUqVVOtdmfeHHDALWBknIbsr99jMAmXXJqoSWc2rRT8+fh2znc+G2dkTdPyQZA8fuIhTUYYheXIuhthbKIxgi+FrGvEcZwaiAQLtdEWeGH/0qalRpcspEXHUHKeSJZ3wYBnGQ1kByNC8FXXbMGT7qg5iegAeAlIMkT/ZqGMNWqO/W3FH5RFsR7aw25dkZLGWK+kiEnIVy3Iuh9ZU8G5rJ/SckoT5bzGL3W72Z7azcQEzeRHGkyCMnwij48o/ct5+8necZKJG9PTk5PrZsU0BAfoIhcy5hHPSHK/RW8FX2YhVd0iKG1tvnGeA2gC+EqlXOtokqXkAMUyTXQtzFis/4HCDTKQbTfID9WjYY3dBrgr9Rh1ad0uPVPBUiqp0GAhBX+jU55wUa3D8pD6g5qhoxoiERFRecA7mqrKI62G2r0PlMP4Yg0GgiZE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aeinwg7/78qEM9wPxe3vMfXhZ/urlnX/Hw==</diagram></mxfile>
Loading
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# local installed dependenies
2+
node_modules/
3+
dist/
4+
5+
# local build
6+
wwwroot/
7+
8+
# local development
9+
nodemon.json
10+
11+
12+
# environment variables
13+
.env
14+
.env.template
15+
.env.test
16+
17+
# tools configuration
18+
.prettierrc
19+
20+
# project info
21+
README.md
22+
23+
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
NODE_ENV=
2+
PORT=
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
NODE_ENV=test
2+
PORT=3001
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"printWidth": 120,
3+
"tabWidth": 2,
4+
"endOfLine": "lf",
5+
"trailingComma": "all",
6+
"singleQuote": true,
7+
"arrowParens": "always"
8+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
FROM node:alpine3.12 as builder
2+
3+
WORKDIR /build
4+
5+
# Copy backend app files
6+
COPY ./src ./src
7+
8+
# Copy frontend app files
9+
COPY ./frontend ./frontend
10+
11+
# Copy dependencies manifest
12+
COPY package*.json ./
13+
14+
# Copy compile configuration
15+
COPY tsconfig.json ./
16+
17+
# Build apps
18+
RUN npm install
19+
20+
RUN cd ./frontend && npm install
21+
22+
RUN npm run build
23+
24+
# Packaging app
25+
FROM node:alpine3.12 as app
26+
27+
WORKDIR /app
28+
29+
COPY --from=builder ./build/wwwroot ./
30+
31+
# Install production dependencies
32+
COPY package*.json ./
33+
34+
RUN npm ci --only=production
35+
36+
CMD [ "node", "app.js" ]

0 commit comments

Comments
 (0)