Agregando Clase 6

This commit is contained in:
Alejandro Lembke Barrientos 2022-09-19 19:18:01 -06:00
parent 1746097811
commit 1742333d1b
19 changed files with 209 additions and 0 deletions

BIN
.DS_Store vendored

Binary file not shown.

View File

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

View File

@ -0,0 +1,6 @@
kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
name: my-local-storage
provisioner: kubernetes.io/no-provisioner
volumeBindingMode: WaitForFirstConsumer

View File

@ -0,0 +1,21 @@
apiVersion: v1
kind: PersistentVolume
metadata:
name: my-local-pv
spec:
capacity:
storage: 3Gi
accessModes:
- ReadWriteOnce
persistentVolumeReclaimPolicy: Retain
storageClassName: my-local-storage
local:
path: /mnt
nodeAffinity:
required:
nodeSelectorTerms:
- matchExpressions:
- key: kubernetes.io/hostname
operator: In
values:
- docker-desktop

View File

@ -0,0 +1,12 @@
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: node-app-mongodb-pvc
namespace: node-app
spec:
storageClassName: my-local-storage
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 3Gi

View File

@ -0,0 +1,13 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: node-app-configmap
namespace: node-app
data:
#WHITELIST URLS Default to http://localhost
WHITELIST_URLS: http://localhost,http://localhost:4000
PORT: "4000"
HOST_MONGO: mongodb-node-app-svc
PORT_MONGO: "27017"
DB_MONGO: app_db

View File

@ -0,0 +1,9 @@
apiVersion: v1
kind: Secret
metadata:
name: node-app-secret
namespace: node-app
type: Opaque
data:
USER_MONGO: cm9vdA==
PASSWORD_MONGO: MTIzNA==

View File

@ -0,0 +1,16 @@
apiVersion: v1
kind: Service
metadata:
name: app-service
namespace: node-app
spec:
ports:
- name: 80-tcp
port: 80
protocol: TCP
targetPort: 4000
selector:
com.docker.project: node-app
type: LoadBalancer
status:
loadBalancer: {}

View File

@ -0,0 +1,13 @@
kind: Service
apiVersion: v1
metadata:
name: mongodb-node-app-svc
namespace: node-app
spec:
selector:
app: mongodb-node-app
ports:
- protocol: TCP
name: mongodb-node-app
port: 27017
targetPort: 27017

View File

@ -0,0 +1,58 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: node-app
namespace: node-app
spec:
replicas: 1
selector:
matchLabels:
com.docker.project: node-app
template:
metadata:
labels:
com.docker.project: node-app
spec:
containers:
- name: node-app
image: aleleba/example-app:2.0.1
imagePullPolicy: Always
env:
- name: PORT
valueFrom:
configMapKeyRef:
name: node-app-configmap
key: PORT
- name: WHITELIST_URLS
valueFrom:
configMapKeyRef:
name: node-app-configmap
key: WHITELIST_URLS
- name: HOST_MONGO
valueFrom:
configMapKeyRef:
name: node-app-configmap
key: HOST_MONGO
- name: PORT_MONGO
valueFrom:
configMapKeyRef:
name: node-app-configmap
key: PORT_MONGO
- name: DB_MONGO
valueFrom:
configMapKeyRef:
name: node-app-configmap
key: DB_MONGO
- name: USER_MONGO
valueFrom:
secretKeyRef:
name: node-app-secret
key: USER_MONGO
- name: PASSWORD_MONGO
valueFrom:
secretKeyRef:
name: node-app-secret
key: PASSWORD_MONGO
ports:
- containerPort: 80
protocol: TCP

View File

@ -0,0 +1,56 @@
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: mongodb-node-app
namespace: node-app
spec:
replicas: 1
serviceName: mongodb-node-app-svc
selector:
matchLabels:
app: mongodb-node-app
template:
metadata:
labels:
app: mongodb-node-app
spec:
containers:
- name: mongodb-node-app
image: mongo:5.0.12
imagePullPolicy: Always
ports:
- containerPort: 27017
env:
- name: MONGO_DATA_DIR
value: /data/db
- name: MONGO_LOG_DIR
value: /dev/null
- name: MONGODB_USER
valueFrom:
secretKeyRef:
name: node-app-secret
key: USER_MONGO
- name: MONGO_INITDB_ROOT_USERNAME
valueFrom:
secretKeyRef:
name: node-app-secret
key: USER_MONGO
- name: MONGODB_PASS
valueFrom:
secretKeyRef:
name: node-app-secret
key: PASSWORD_MONGO
- name: MONGO_INITDB_ROOT_PASSWORD
valueFrom:
secretKeyRef:
name: node-app-secret
key: PASSWORD_MONGO
- name: MONGO_INITDB_DATABASE
value: admin
volumeMounts:
- mountPath: /data/db
name: node-app-mongodb-pvc
volumes:
- name: node-app-mongodb-pvc
persistentVolumeClaim:
claimName: node-app-mongodb-pvc

View File

@ -0,0 +1 @@
kubectl delete all --all -n {namespace}