-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmicronaut-multiple-services-kubernetes.yaml
93 lines (87 loc) · 2.26 KB
/
micronaut-multiple-services-kubernetes.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# This demonstrates how to run the image in Kubernetes and expose it via a load balancer
apiVersion: apps/v1
kind: Deployment
metadata:
name: micronaut-random-greetings
spec:
selector:
matchLabels:
app: micronaut-greetings-app
replicas:
template:
metadata:
labels:
app: micronaut-greetings-app
spec:
containers:
- name: greetings-app
image: greeting-service:latest
imagePullPolicy: IfNotPresent # important - otherwise Kubernetes will try to pull from DockerHub
livenessProbe:
httpGet:
path: /health
port: 8080
periodSeconds: 10
failureThreshold: 3
readinessProbe:
httpGet:
path: /health
port: 8080
periodSeconds: 5
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: micronaut-random-name
spec:
selector:
matchLabels:
app: micronaut-name-app
replicas:
template:
metadata:
labels:
app: micronaut-name-app
spec:
containers:
- name: name-app
image: name-service:latest
imagePullPolicy: IfNotPresent # important - otherwise Kubernetes will try to pull from DockerHub
livenessProbe:
httpGet:
path: /health
port: 8080
periodSeconds: 10
failureThreshold: 3
readinessProbe:
httpGet:
path: /health
port: 8080
periodSeconds: 5
---
# Create a load balancer for the app to expose it on localhost:8080
# $ curl localhost:8080/greetings
apiVersion: v1
kind: Service
metadata:
name: greetings-service-loadbalancer
spec:
selector:
app: micronaut-greetings-app
ports:
- port: 8080 # the localhost port that we will use to expose the service
targetPort: 8080 # the port on the container
type: LoadBalancer
---
# Allow the greeting service to find the name service
apiVersion: v1
kind: Service
metadata:
name: name-service-loadbalancer
spec:
selector:
app: micronaut-name-app
ports:
- port: 8080 # the localhost port that we will use to expose the service
targetPort: 8080 # the port on the container
type: NodePort