Skip to content

Commit

Permalink
Add NGINX ingress
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewgardner committed Sep 10, 2024
1 parent af0265b commit 546ae21
Show file tree
Hide file tree
Showing 15 changed files with 103 additions and 128 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ The following are instructions to build and deploy all TraderX apps to your loca
## 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

Expand Down
2 changes: 1 addition & 1 deletion gitops/base/account-service/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ metadata:
spec:
ports:
- name: "18088"
port: 18088
port: 8080
targetPort: 18088
selector:
app: account-service
88 changes: 0 additions & 88 deletions gitops/base/ingress/deployment.yaml

This file was deleted.

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
3 changes: 1 addition & 2 deletions gitops/base/ingress/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
resources:
- service.yaml
- deployment.yaml
- ingress.yaml
13 changes: 0 additions & 13 deletions gitops/base/ingress/service.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion gitops/base/people-service/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ metadata:
spec:
ports:
- name: "18089"
port: 18089
port: 8080
targetPort: 18089
selector:
app: people-service
2 changes: 1 addition & 1 deletion gitops/base/position-service/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ metadata:
spec:
ports:
- name: "18090"
port: 18090
port: 8080
targetPort: 18090

selector:
Expand Down
4 changes: 2 additions & 2 deletions gitops/base/reference-data/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ spec:
app: reference-data
spec:
containers:
- image: traderx/reference-data
- name: reference-data
image: traderx/reference-data
imagePullPolicy: IfNotPresent
name: reference-data
ports:
- containerPort: 18085
protocol: TCP
Expand Down
3 changes: 1 addition & 2 deletions gitops/base/reference-data/service.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
apiVersion: v1
kind: Service
metadata:
annotations:
labels:
app: reference-data
name: reference-data
spec:
ports:
- name: "18085"
port: 18085
port: 8080
targetPort: 18085
selector:
app: reference-data
2 changes: 1 addition & 1 deletion gitops/base/trade-feed/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ metadata:
spec:
ports:
- name: "18086"
port: 18086
port: 8080
targetPort: 18086
selector:
app: trade-feed
2 changes: 1 addition & 1 deletion gitops/base/trade-service/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ metadata:
spec:
ports:
- name: "18092"
port: 18092
port: 8080
targetPort: 18092
selector:
app: trade-service
2 changes: 1 addition & 1 deletion gitops/base/web-front-end/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ spec:
name: web-front-end-angular
env:
- name: WEB_FRONT_END_START_MODE
value: "start"
value: "start-prod"
ports:
- containerPort: 18093
protocol: TCP
Expand Down
3 changes: 2 additions & 1 deletion gitops/base/web-front-end/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ metadata:
spec:
ports:
- name: "18093"
port: 18093
port: 8080
targetPort: 18093
protocol: TCP
selector:
app: web-front-end-angular
15 changes: 1 addition & 14 deletions gitops/local/Tiltfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
docker_build('traderx/database', './../../database/.')
#docker_build('traderx/ingress', './../../ingress/.')
docker_build('traderx/account-service', './../../account-service/.')
docker_build('traderx/people-service', './../../people-service/.')
docker_build('traderx/position-service', './../../position-service/.')
Expand All @@ -8,18 +7,6 @@ docker_build('traderx/trade-feed', './../../trade-feed/.')
docker_build('traderx/trade-processor', './../../trade-processor/.')
docker_build('traderx/trade-service', './../../trade-service/.')
docker_build('traderx/web-front-end-angular', './../../web-front-end/angular/.')

yaml = kustomize(('./traderx'))
print(yaml)
k8s_yaml(yaml)

# Forward port 8080 on localhost to the Ingress service
k8s_resource('database-deployment', port_forwards=[18084])
k8s_resource('web-front-end-angular', port_forwards=[18093])
k8s_resource('people-service', port_forwards=[18089])
k8s_resource('position-service', port_forwards=[18090])
k8s_resource('account-service', port_forwards=[18088])
k8s_resource('trade-service', port_forwards=[18092])
k8s_resource('trade-processor-deployment', port_forwards=[18091])
k8s_resource('trade-feed', port_forwards=[18086])
k8s_resource('reference-data', port_forwards=[18085])
k8s_yaml(yaml)

0 comments on commit 546ae21

Please sign in to comment.