Skip to content

Commit

Permalink
Merge pull request #57 from AnglesHQ/kubernetes-manifests
Browse files Browse the repository at this point in the history
Kubernetes manifests to deploy Angles Dashboard
  • Loading branch information
snevesbarros authored Jan 14, 2023
2 parents 14f4285 + e1fb5aa commit 704e498
Show file tree
Hide file tree
Showing 7 changed files with 305 additions and 0 deletions.
7 changes: 7 additions & 0 deletions setup/kubernetes/01-angles-namespace.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: v1
kind: Namespace
metadata:
name: angles
labels:
name: angles
---
66 changes: 66 additions & 0 deletions setup/kubernetes/01-angles-storage.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# before creating a persistent volume have to create the disk.
# e.g. gcloud beta compute disks create --size=100GB angles-data-disk --region <region> --replica-zones <zones>

#apiVersion: v1
#kind: PersistentVolume
#metadata:
# name: angles-persistent-volume
# namespace: angles
#spec:
# accessModes:
# - ReadWriteOnce
# persistentVolumeReclaimPolicy: Retain
# capacity:
# storage: 100Gi
# gcePersistentDisk:
# fsType: ext4
# pdName: angles-data-disk
# storageClassName: gcp-disk
#
#---
#
#apiVersion: v1
#kind: PersistentVolumeClaim
#metadata:
# name: angles-persistent-volume-claim
# namespace: angles
#spec:
# accessModes:
# - ReadWriteOnce
# resources:
# requests:
# storage: 100Gi
# storageClassName: gcp-disk

---
# storage for local cluster e.g. k3d
apiVersion: v1
kind: PersistentVolume
metadata:
name: angles-persistent-volume
namespace: angles
labels:
type: local
spec:
storageClassName: manual
capacity:
storage: 5Gi
accessModes:
- ReadWriteOnce
persistentVolumeReclaimPolicy: Retain
hostPath:
path: "/tmp/k3dvol"
---

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: angles-persistent-volume-claim
namespace: angles
spec:
storageClassName: manual
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 5Gi
61 changes: 61 additions & 0 deletions setup/kubernetes/02-angles-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: angles-backend-config
namespace: angles
data:
REACT_APP_SWAGGER_ANGLES_API_URL: "127.0.0.1:3002"
REACT_APP_SWAGGER_SCHEMES: "http"
PORT: "3002"
BUILD_CLEAN_UP_AGE_IN_DAYS: "90"
# change these credentials
MONGO_ANGLES_USERNAME: "angleshq"
MONGO_ANGLES_PASSWORD: "Password123"

---

apiVersion: v1
kind: ConfigMap
metadata:
name: angles-mongo-config
namespace: angles
data:
MONGO_INITDB_ROOT_USERNAME: "admin"
# change the admin password
MONGO_INITDB_ROOT_PASSWORD: "@nglesPassword"
MONGO_INITDB_DATABASE: "angles"

---

apiVersion: v1
kind: ConfigMap
metadata:
name: mongo-init
namespace: angles
data:
mongo-init.sh: |
mongo -- "$MONGO_INITDB_DATABASE" <<EOF
db.createUser({ user: '$MONGO_ANGLES_USERNAME', pwd: '$MONGO_ANGLES_PASSWORD', roles: ['readWrite'] });
db.auth('$MONGO_ANGLES_USERNAME', '$MONGO_ANGLES_PASSWORD');
db.createCollection('builds');
db.createCollection('testexecutions');
db.createCollection('teams');
db.createCollection('phase');
db.createCollection('environments');
db.createCollection('baselines');
db.createCollection('screenshots');
db.testexecutions.createIndex({ build: 1 });
db.testexecutions.createIndex({ suite: 1, title: 1 });
db.build.createIndex({ team: 1 });
db.team.createIndex({ name: 1 });
db.phase.createIndex({ name: 1 });
db.environment.createIndex({ name: 1 });
db.screenshots.createIndex({ build: 1 });
db.screenshots.createIndex({ view: 1 });
EOF
---
54 changes: 54 additions & 0 deletions setup/kubernetes/03-mongo-pod.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
apiVersion: v1
kind: Pod
metadata:
name: angles-mongo-database
namespace: angles
labels:
app.kubernetes.io/name: angles-mongo-database
spec:
containers:
- name: angles-mongo
image: mongo:4.4.13
imagePullPolicy: IfNotPresent
resources:
limits:
cpu: '1500m'
memory: '1000Mi'
requests:
cpu: '1000m'
memory: '800Mi'
ports:
- containerPort: 27017
hostPort: 27017
envFrom:
- configMapRef:
name: angles-mongo-config
env:
- name: MONGO_ANGLES_PASSWORD
valueFrom:
configMapKeyRef:
name: angles-backend-config
key: MONGO_ANGLES_PASSWORD
- name: MONGO_ANGLES_USERNAME
valueFrom:
configMapKeyRef:
name: angles-backend-config
key: MONGO_ANGLES_USERNAME
volumeMounts:
- name: mongo-init
mountPath: /docker-entrypoint-initdb.d/mongo-init.sh
subPath: mongo-init.sh
- mountPath: "/data/db"
subPath: "./db"
name: angles-persistent-volume
- mountPath: "/data/config"
subPath: "./config"
name: angles-persistent-volume
volumes:
- name: mongo-init
configMap:
name: mongo-init
- name: angles-persistent-volume
persistentVolumeClaim:
claimName: angles-persistent-volume-claim

14 changes: 14 additions & 0 deletions setup/kubernetes/03-mongo-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: v1
kind: Service
metadata:
name: angles-database-service
namespace: angles
spec:
selector:
app.kubernetes.io/name: angles-mongo-database
type: ClusterIP
ports:
- name: mongo
protocol: TCP
port: 27017
targetPort: 27017
72 changes: 72 additions & 0 deletions setup/kubernetes/04-angles-pod.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
apiVersion: v1
kind: Pod
metadata:
name: angles-dashboard-backend
namespace: angles
labels:
app.kubernetes.io/name: angles-dashboard-backend
spec:
containers:
- name: angles
image: angleshq/angles:latest
imagePullPolicy: IfNotPresent
resources:
limits:
cpu: '1500m'
memory: '1500Mi'
requests:
cpu: '1000m'
memory: '1000Mi'
ports:
- containerPort: 3002
hostPort: 3002
envFrom:
- configMapRef:
name: angles-backend-config
env:
- name: MONGO_URL
value: "mongodb://$(MONGO_ANGLES_USERNAME):$(MONGO_ANGLES_PASSWORD)@$(ANGLES_DATABASE_SERVICE_SERVICE_HOST):$(ANGLES_DATABASE_SERVICE_SERVICE_PORT)/angles"

volumeMounts:
- mountPath: "/app/screenshots"
subPath: "./screenshots"
name: angles-persistent-volume
- mountPath: "/app/compares"
subPath: "./compares"
name: angles-persistent-volume
volumes:
- name: angles-persistent-volume
persistentVolumeClaim:
claimName: angles-persistent-volume-claim

---

apiVersion: v1
kind: Pod
metadata:
name: angles-dashboard-frontend
namespace: angles
labels:
app.kubernetes.io/name: angles-dashboard-frontend
spec:
containers:
- name: angles-ui
image: angleshq/angles-ui:latest
imagePullPolicy: IfNotPresent
resources:
limits:
cpu: '2000m'
memory: '1500Mi'
requests:
cpu: '1500m'
memory: '1000Mi'
ports:
- containerPort: 3003
hostPort: 3003
env:
- name: REACT_APP_ANGLES_API_URL
# this url is what the front-end app should call.
# value: "http://$(ANGLES_BACKEND_SERVICE_SERVICE_HOST):$(ANGLES_BACKEND_SERVICE_SERVICE_PORT)"
value: "http://127.0.0.1:$(ANGLES_BACKEND_SERVICE_SERVICE_PORT)"
- name: PORT
value: "3003"
31 changes: 31 additions & 0 deletions setup/kubernetes/04-angles-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
apiVersion: v1
kind: Service
metadata:
name: angles-backend-service
namespace: angles
spec:
selector:
app.kubernetes.io/name: angles-dashboard-backend
type: ClusterIP
ports:
- name: webservice
protocol: TCP
port: 3002
targetPort: 3002

---

apiVersion: v1
kind: Service
metadata:
name: angles-frontend-service
namespace: angles
spec:
selector:
app.kubernetes.io/name: angles-dashboard-frontend
type: ClusterIP
ports:
- name: web
protocol: TCP
port: 3003
targetPort: 3003

0 comments on commit 704e498

Please sign in to comment.