agregando clase 4

This commit is contained in:
Alejandro Lembke Barrientos 2022-09-13 15:32:50 -06:00
parent f9c606c6b9
commit c902a9fee0
12 changed files with 139 additions and 1 deletions

BIN
.DS_Store vendored

Binary file not shown.

3
.gitignore vendored
View File

@ -2,4 +2,5 @@ CuestionarioKubernetes.docx
Videos de Clase
Hojas de Asistencia
Clase 3/Clase 3.pptx
Clase 3/Ejercicio/nginx-app
Clase 3/Ejercicio/nginx-app
Clase 4/Clase 4.pptx

BIN
Clase 1/.DS_Store vendored

Binary file not shown.

Binary file not shown.

BIN
Clase 2/.DS_Store vendored

Binary file not shown.

Binary file not shown.

BIN
Clase 4/.DS_Store vendored Normal file

Binary file not shown.

View File

@ -0,0 +1,42 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: node-app-configmap
namespace: node-app
data:
# Mensaje personalizado
message: "Este es un mensaje personalizado."
# file-like keys
# Archivo de app (Código)
app.js: |
const express = require('express')
const app = express()
const port = process.env.PORT ? process.env.PORT : 80
app.get('/', (req, res) => {
res.send(process.env.MESSAGE ? process.env.MESSAGE : 'Hello World!')
})
app.get('/secret', (req, res) => {
res.send(process.env.SECRET ? process.env.SECRET : 'Hello Secret World!')
})
app.listen(port, () => {
console.log(`Example app listening on port ${port}`)
})
package.json: |
{
"name": "show-text-app",
"version": "1.0.0",
"description": "example app",
"main": "app.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Alejandro Lembke Barrientos",
"license": "MIT",
"dependencies": {
"express": "^4.18.1"
}
}

View File

@ -0,0 +1,69 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: node-app
namespace: node-app
spec:
replicas: 1
selector:
matchLabels:
app: node-app
template:
metadata:
labels:
app: node-app
spec:
containers:
- name: node-app
image: ubuntu
command:
- "/bin/sh"
- "-c"
- "tail -f /dev/null"
env:
- name: PORT
value: "3000"
- name: SECRET
valueFrom:
secretKeyRef:
name: node-app-secret
key: secret
- name: MESSAGE
valueFrom:
configMapKeyRef:
name: node-app-configmap
key: message
resources:
limits:
memory: "128Mi"
cpu: "500m"
ports:
- containerPort: 3000
lifecycle:
postStart:
exec:
command:
- "/bin/sh"
- "-c"
- "apt-get update"
- "&&"
- "apt-get install curl -y"
- "&&"
- "curl -sL https://deb.nodesource.com/setup_16.x -o nodesource_setup.sh"
- "&&"
- "bash nodesource_setup.sh"
- "&&"
- "apt install nodejs"
- "&&"
- "cd /app && npm install && node app.js"
volumeMounts:
- name: app-files
mountPath: /app/app.js
subPath: app.js
- name: app-files
mountPath: /app/package.json
subPath: package.json
volumes:
- name: app-files
configMap:
name: node-app-configmap

View File

@ -0,0 +1,4 @@
apiVersion: v1
kind: Namespace
metadata:
name: node-app

View File

@ -0,0 +1,8 @@
apiVersion: v1
kind: Secret
metadata:
name: node-app-secret
namespace: node-app
type: Opaque
data:
secret: RXN0ZSBlcyB1biB0ZXh0byBzZWNyZXRvLg==

View File

@ -0,0 +1,14 @@
apiVersion: v1
kind: Service
metadata:
name: node-app-svc
namespace: node-app
labels:
app: node-app
spec:
type: ClusterIP
selector:
app: node-app
ports:
- port: 80
targetPort: 3000