Skip to content

Commit

Permalink
initial conversion of main services - build and deploy (#206)
Browse files Browse the repository at this point in the history
* Initial conversion of main services - build and deploy
* Add NGINX ingress
---------
Co-authored-by: @DovOps
  • Loading branch information
matthewgardner authored Sep 12, 2024
1 parent 00684f1 commit b5a53b2
Show file tree
Hide file tree
Showing 33 changed files with 573 additions and 0 deletions.
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,35 @@ cd .corp
./gradlew account-service:bootRun
```

## Usage (K8s)

The following are instructions to build and deploy all TraderX apps to your local enviroment using [tilt](https://tilt.dev) and kustomize files.

## Prerequistes
- Running [Docker](https://www.docker.com/products/docker-desktop/) or similar
- Running K8s - [Kind](https://kind.sigs.k8s.io/) /[Minikube](https://minikube.sigs.k8s.io/docs/start/)/[k3s](https://k3s.io/) or similar
- Install an [Ingress Controller](https://kubernetes.github.io/ingress-nginx/deploy/)

### Preflight checks

```
kubectl get pods
```

or

Check your cluster is running using the epic tool `k9s` - https://k9scli.io/

### Start Tilt

This command will build and start all locally built applications and deploy them to your local K8s environment.

```
cd ./gitops/local/
tilt up
```


# Getting Involved

### Project Meetings
Expand Down
31 changes: 31 additions & 0 deletions gitops/base/account-service/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: account-service
name: account-service
spec:
replicas: 1
selector:
matchLabels:
app: account-service
strategy:
type: Recreate
template:
metadata:
labels:
app: account-service
spec:
containers:
- name: account-service
env:
- name: ACCOUNT_SERVICE_PORT
value: "18088"
- name: DATABASE_TCP_HOST
value: database
image: traderx/account-service
imagePullPolicy: IfNotPresent
ports:
- containerPort: 18088
protocol: TCP
restartPolicy: Always
3 changes: 3 additions & 0 deletions gitops/base/account-service/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
resources:
- service.yaml
- deployment.yaml
13 changes: 13 additions & 0 deletions gitops/base/account-service/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: v1
kind: Service
metadata:
labels:
app: account-service
name: account-service
spec:
ports:
- name: "18088"
port: 8080
targetPort: 18088
selector:
app: account-service
27 changes: 27 additions & 0 deletions gitops/base/database/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: database-deployment
labels:
app: database
spec:
replicas: 2
selector:
matchLabels:
app: database
template:
metadata:
labels:
app: database
spec:
containers:
- name: database-app
image: traderx/database
imagePullPolicy: IfNotPresent
ports:
- containerPort: 18082
protocol: TCP
- containerPort: 18083
protocol: TCP
- containerPort: 18084
protocol: TCP
3 changes: 3 additions & 0 deletions gitops/base/database/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
resources:
- service.yaml
- deployment.yaml
17 changes: 17 additions & 0 deletions gitops/base/database/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: v1
kind: Service
metadata:
name: database
spec:
selector:
app: database
ports:
- name: "18082"
port: 18082
targetPort: 18082
- name: "18083"
port: 18083
targetPort: 18083
- name: "18084"
port: 18084
targetPort: 18084
89 changes: 89 additions & 0 deletions gitops/base/ingress/ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: traderx-ingress
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /$2
spec:
ingressClassName: nginx
rules:
- host: localhost
http:
paths:
- path: /account-service(/|$)(.*)
pathType: Prefix
backend:
service:
name: account-service
port:
number: 8080
- path: /db-web(/|$)(.*)
pathType: Prefix
backend:
service:
name: database
port:
number: 18084
- path: /ng-cli-ws
pathType: Prefix
backend:
service:
name: web-front-end-angular
port:
number: 8080
- path: /people-service(/|$)(.*)
pathType: Prefix
backend:
service:
name: people-service
port:
number: 8080
- path: /position-service(/|$)(.*)
pathType: Prefix
backend:
service:
name: position-service
port:
number: 8080
- path: /reference-data(/|$)(.*)
pathType: Prefix
backend:
service:
name: reference-data
port:
number: 8080
- path: /socket.io/
pathType: Prefix
backend:
service:
name: trade-feed
port:
number: 8080
- path: /trade-feed(/|$)(.*)
pathType: Prefix
backend:
service:
name: trade-feed
port:
number: 8080
- path: /trade-service(/|$)(.*)
pathType: Prefix
backend:
service:
name: trade-service
port:
number: 8080
- path: /trade-processor(/|$)(.*)
pathType: Prefix
backend:
service:
name: trade-processor
port:
number: 8080
- path: /traderx(/|$)(.*)
pathType: Prefix
backend:
service:
name: web-front-end-angular
port:
number: 8080
2 changes: 2 additions & 0 deletions gitops/base/ingress/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
resources:
- ingress.yaml
26 changes: 26 additions & 0 deletions gitops/base/people-service/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: people-service
name: people-service
spec:
replicas: 1
selector:
matchLabels:
app: people-service
strategy:
type: Recreate
template:
metadata:
labels:
app: people-service
spec:
containers:
- name: people-service
image: traderx/people-service
imagePullPolicy: IfNotPresent
ports:
- containerPort: 18089
protocol: TCP
restartPolicy: Always
3 changes: 3 additions & 0 deletions gitops/base/people-service/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
resources:
- service.yaml
- deployment.yaml
13 changes: 13 additions & 0 deletions gitops/base/people-service/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: v1
kind: Service
metadata:
labels:
app: people-service
name: people-service
spec:
ports:
- name: "18089"
port: 8080
targetPort: 18089
selector:
app: people-service
33 changes: 33 additions & 0 deletions gitops/base/position-service/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: position-service
name: position-service
spec:
replicas: 1
selector:
matchLabels:
app: position-service
strategy:
type: Recreate
template:
metadata:
labels:
app: position-service
spec:
containers:
- name: position-service
env:
- name: DATABASE_TCP_HOST
value: database
- name: POSITION_SERVICE_PORT
value: "18090"
image: traderx/position-service
imagePullPolicy: IfNotPresent
ports:
- containerPort: 18090
protocol: TCP
workingDir: /position-service
restartPolicy: Always

3 changes: 3 additions & 0 deletions gitops/base/position-service/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
resources:
- service.yaml
- deployment.yaml
14 changes: 14 additions & 0 deletions gitops/base/position-service/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: v1
kind: Service
metadata:
labels:
app: position-service
name: position-service
spec:
ports:
- name: "18090"
port: 8080
targetPort: 18090

selector:
app: position-service
30 changes: 30 additions & 0 deletions gitops/base/reference-data/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: reference-data
name: reference-data
spec:
replicas: 1
selector:
matchLabels:
app: reference-data
strategy:
type: Recreate
template:
metadata:
labels:
app: reference-data
spec:
containers:
- name: reference-data
env:
- name: REFERENCE_DATA_SERVICE_PORT
value: "18095"
image: traderx/reference-data
imagePullPolicy: IfNotPresent
ports:
- containerPort: 18085
protocol: TCP
workingDir: /reference-data
restartPolicy: Always
3 changes: 3 additions & 0 deletions gitops/base/reference-data/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
resources:
- service.yaml
- deployment.yaml
13 changes: 13 additions & 0 deletions gitops/base/reference-data/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: v1
kind: Service
metadata:
labels:
app: reference-data
name: reference-data
spec:
ports:
- name: "18085"
port: 8080
targetPort: 18085
selector:
app: reference-data
Loading

0 comments on commit b5a53b2

Please sign in to comment.