Skip to content

Commit

Permalink
k8s: route http traffic using ingress
Browse files Browse the repository at this point in the history
  • Loading branch information
tacerihsehc613 committed Dec 13, 2023
1 parent 2ab116d commit 8d39e49
Show file tree
Hide file tree
Showing 7 changed files with 134 additions and 0 deletions.
Binary file modified .DS_Store
Binary file not shown.
29 changes: 29 additions & 0 deletions deploy/bookings-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: bookings
spec:
replicas: 2
selector:
matchLabels:
myevents/app: bookings
myevents/tier: api
template:
metadata:
labels:
myevents/app: bookings
myevents/tier: api
spec:
containers:
- name: api
imagePullPolicy: Never
image: myevents/bookingservice
ports:
- containerPort: 8282
name: http
env:
- name: MONGO_URL
value: mongodb://events-db/users
- name: AMQP_BROKER_URL
value: amqp://guest:guest@amqp-broker:5672/

12 changes: 12 additions & 0 deletions deploy/bookings-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: v1
kind: Service
metadata:
name: bookings
spec:
selector:
myevents/app: bookings
myevents/tier: api
ports:
- port: 80
targetPort: 8282
name: http
1 change: 1 addition & 0 deletions deploy/events-service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ spec:
selector:
myevents/app: events
myevents/tier: api
# type: LoadBalancer
ports:
- port: 80
targetPort: 8181
Expand Down
33 changes: 33 additions & 0 deletions deploy/frontend.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: frontend
spec:
selector:
matchLabels:
myevents/app: frontend
template:
metadata:
labels:
myevents/app: frontend
spec:
containers:
- name: frontend
image: myevents/frontend
imagePullPolicy: Never
ports:
- containerPort: 80
name: http
---
apiVersion: v1
kind: Service
metadata:
name: frontend
spec:
type: NodePort
selector:
myevents/app: frontend
ports:
- port: 80
targetPort: 80
name: http
20 changes: 20 additions & 0 deletions deploy/ingress-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
apiVersion: v1
kind: Service
metadata:
name: myevents-controller
namespace: default
spec:
ports:
- name: http
protocol: TCP
port: 80
targetPort: 80
nodePort: 30100
- name: https
protocol: TCP
port: 443
targetPort: 443
nodePort: 30101
selector:
app.kubernetes.io/name: myevents
type: NodePort
39 changes: 39 additions & 0 deletions deploy/ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: myevents
namespace: default
annotations:
nginx.ingress.kubernetes.io/rewrite-path: /
# kubernetes.io/ingress.class: "nginx"
spec:
ingressClassName: nginx
rules:
- host: api.myevents.example
http:
paths:
- path: /events
pathType: Prefix
backend:
service:
name: events
port:
number: 80
- path: /bookings
pathType: Prefix
backend:
service:
name: bookings
port:
number: 80
- host: www.myevents.example
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: frontend
port:
number: 80

2 comments on commit 8d39e49

@tacerihsehc613
Copy link
Owner Author

@tacerihsehc613 tacerihsehc613 commented on 8d39e49 Dec 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tacerihsehc613
Copy link
Owner Author

@tacerihsehc613 tacerihsehc613 commented on 8d39e49 Dec 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.