-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbackend-service.yaml
80 lines (73 loc) · 4.32 KB
/
backend-service.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
# This is the backend service file that uses a NodePort type of service. A NodePort service reserves a port on the node machine,
# allowing us to access the service using the node's IP address and the reserved port. ex: http://<node-public-ip>:port
# For simplicity, I chose the NodePort type of service. However, if you prefer to use a ClusterIP type of service,
# it will work just as it is currently working.
apiVersion: v1
kind: Service
metadata:
name: backend-service
spec:
selector:
app: node-backend
ports:
- port: 8000
targetPort: 8000
nodePort: 30007
type: NodePort
## 1. It represents a single node and service. Accessing http://192.168.1.2:30006 will provide a response.
# +----------------+
# | User |
# +----------------+
# ||
# ||
# ||
# +-----------------//------------------+
# | Node |
# | IP: 192.168.1.2 |
# | 3. NodePort: 30006 |
# | |
# | |
# | |
# | 2. Port |
# | +------------------+ |
# | | Service | |
# | | IP: 10.106.1.12 | |
# | | Port: 80 | |
# | +------------------+ |
# | |
# | |
# | |
# | 1. TargetPort |
# | +-----------------+ |
# | | POD | |
# | | IP: 10.244.0.2 | |
# | | Port: 80 | |
# | +-----------------+ |
# | |
# ++-----------------------------------++
# 2. It represents multiple nodes with a single service distributed across them. When a user makes a request using the domain name,
# the response can be served from any instance.
# +----------------+
# | User |
# +----------------+
# ||
# ||
# -----------------------||------------------------
# | || |
# | || |
# ᐯ ᐯ ᐯ
# +-----------------+|//|+--------------------+|//|+--------------------+|//|
# | Node 1 |//| Node 2 |//| Node 3 |//|
# | 192.168.1.2 |//| 192.168.1.3 |//| 192.168.1.4 |//|
# | Targetport:3006 |//| Targetport:3006 |//| Targetport:3006 |//|
# | +------------------------------------------------------+ |//|
# | | Service | |//|
# | +------------------------------------------------------+ |//|
# | |//| |//| |//|
# | +--------------+ |//| +---------------+ |//| +---------------+ |//|
# | | POD | |//| | POD | |//| | POD | |//|
# | | 10.244.0.2 | |//| | 10.244.0.3 | |//| | 10.244.0.4 | |//|
# | +-------------++ |//| +---------------+ |//| +---------------+ |//|
# | |//| |//| |//|
# | |//| |//| |//|
# +------------------+\\+----------------------+\\+----------------------+\\+