212 lines
4 KiB
YAML
212 lines
4 KiB
YAML
#########################################################
|
|
# Common Environment variables ConfigMap
|
|
#########################################################
|
|
apiVersion: v1
|
|
kind: ConfigMap
|
|
metadata:
|
|
name: common-env
|
|
data:
|
|
NAMESPACE: ""
|
|
LOGLEVEL: info
|
|
SERVICEDIR: dist/services
|
|
CACHER: Memory
|
|
MONGO_URI: mongodb://mongo/redplateaus
|
|
|
|
---
|
|
#########################################################
|
|
# Service for Moleculer API Gateway service
|
|
#########################################################
|
|
apiVersion: v1
|
|
kind: Service
|
|
metadata:
|
|
name: api
|
|
spec:
|
|
selector:
|
|
app: api
|
|
ports:
|
|
- port: 3000
|
|
targetPort: 3000
|
|
|
|
---
|
|
#########################################################
|
|
# Ingress for Moleculer API Gateway
|
|
#########################################################
|
|
apiVersion: networking.k8s.io/v1beta1
|
|
kind: Ingress
|
|
metadata:
|
|
name: ingress
|
|
spec:
|
|
rules:
|
|
- host: redplateaus.127.0.0.1.nip.io
|
|
http:
|
|
paths:
|
|
- path: /
|
|
backend:
|
|
serviceName: api
|
|
servicePort: 3000
|
|
|
|
---
|
|
#########################################################
|
|
# API Gateway service
|
|
#########################################################
|
|
apiVersion: apps/v1
|
|
kind: Deployment
|
|
metadata:
|
|
name: api
|
|
spec:
|
|
selector:
|
|
matchLabels:
|
|
app: api
|
|
replicas: 2
|
|
template:
|
|
metadata:
|
|
labels:
|
|
app: api
|
|
spec:
|
|
containers:
|
|
- name: api
|
|
image: redplateaus
|
|
envFrom:
|
|
- configMapRef:
|
|
name: common-env
|
|
env:
|
|
- name: SERVICES
|
|
value: api
|
|
- name: PORT
|
|
value: "3000"
|
|
ports:
|
|
- containerPort: 3000
|
|
|
|
---
|
|
#########################################################
|
|
# Greeter service
|
|
#########################################################
|
|
apiVersion: apps/v1
|
|
kind: Deployment
|
|
metadata:
|
|
name: greeter
|
|
spec:
|
|
selector:
|
|
matchLabels:
|
|
app: greeter
|
|
replicas: 2
|
|
template:
|
|
metadata:
|
|
labels:
|
|
app: greeter
|
|
spec:
|
|
containers:
|
|
- name: greeter
|
|
image: redplateaus
|
|
envFrom:
|
|
- configMapRef:
|
|
name: common-env
|
|
env:
|
|
- name: SERVICES
|
|
value: greeter
|
|
|
|
---
|
|
#########################################################
|
|
# Products service
|
|
#########################################################
|
|
apiVersion: apps/v1
|
|
kind: Deployment
|
|
metadata:
|
|
name: products
|
|
spec:
|
|
selector:
|
|
matchLabels:
|
|
app: products
|
|
replicas: 2
|
|
template:
|
|
metadata:
|
|
labels:
|
|
app: products
|
|
spec:
|
|
containers:
|
|
- name: products
|
|
image: redplateaus
|
|
envFrom:
|
|
- configMapRef:
|
|
name: common-env
|
|
env:
|
|
- name: SERVICES
|
|
value: products
|
|
|
|
---
|
|
#########################################################
|
|
# MongoDB server
|
|
#########################################################
|
|
apiVersion: apps/v1
|
|
kind: StatefulSet
|
|
metadata:
|
|
name: mongo
|
|
labels:
|
|
app: mongo
|
|
spec:
|
|
selector:
|
|
matchLabels:
|
|
app: mongo
|
|
replicas: 1
|
|
serviceName: mongo
|
|
template:
|
|
metadata:
|
|
labels:
|
|
app: mongo
|
|
spec:
|
|
containers:
|
|
- image: mongo
|
|
name: mongo
|
|
ports:
|
|
- containerPort: 27017
|
|
resources: {}
|
|
volumeMounts:
|
|
- mountPath: /data/db
|
|
name: mongo-data
|
|
volumes:
|
|
- name: mongo-data
|
|
persistentVolumeClaim:
|
|
claimName: mongo-data
|
|
|
|
---
|
|
#########################################################
|
|
# Persistent volume for MongoDB
|
|
#########################################################
|
|
apiVersion: v1
|
|
kind: PersistentVolumeClaim
|
|
metadata:
|
|
name: mongo-data
|
|
labels:
|
|
name: mongo-data
|
|
spec:
|
|
accessModes:
|
|
- ReadWriteOnce
|
|
resources:
|
|
requests:
|
|
storage: 100Mi
|
|
|
|
---
|
|
#########################################################
|
|
# MongoDB service
|
|
#########################################################
|
|
apiVersion: v1
|
|
kind: Service
|
|
metadata:
|
|
name: mongo
|
|
labels:
|
|
app: mongo
|
|
spec:
|
|
ports:
|
|
- port: 27017
|
|
targetPort: 27017
|
|
selector:
|
|
app: mongo
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|