-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathfull-stack.yaml
More file actions
128 lines (128 loc) · 3.02 KB
/
Copy pathfull-stack.yaml
File metadata and controls
128 lines (128 loc) · 3.02 KB
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
# --- THE API SERVICE (Load Balancer) ---
apiVersion: v1
kind: Service
metadata:
name: eshopping-api-service
spec:
type: LoadBalancer
selector:
app: eshopping-api
ports:
- protocol: TCP
port: 8081 # Port you use in the browser
targetPort: 8080 # Port inside the .NET container
---
# --- THE INGRESS (Domain Router) ---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: eshopping-ingress
spec:
ingressClassName: nginx
rules:
- host: eshopping.local
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: eshopping-api-service
port:
number: 8081
---
# --- THE DATABASE SERVICE ---
apiVersion: v1
kind: Service
metadata:
name: sql-service
spec:
selector:
app: mssql
ports:
- protocol: TCP
port: 1433
targetPort: 1433
---
# --- THE DATABASE (StatefulSet with Persistent Storage) ---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: mssql
spec:
serviceName: "sql-service"
replicas: 1
selector:
matchLabels:
app: mssql
template:
metadata:
labels:
app: mssql
spec:
containers:
- name: mssql
image: mcr.microsoft.com/mssql/server:2022-latest
ports:
- containerPort: 1433
env:
- name: ACCEPT_EULA
value: "Y"
- name: MSSQL_SA_PASSWORD
value: "YourStrong@Passw0rd"
volumeMounts:
- name: mssql-storage
mountPath: /var/opt/mssql # SQL Server's internal data directory
volumeClaimTemplates:
- metadata:
name: mssql-storage
spec:
accessModes: [ "ReadWriteOnce" ]
resources:
requests:
storage: 1Gi # This creates a permanent disk on your host
---
# --- THE API DEPLOYMENT (3 Replicas) ---
apiVersion: apps/v1
kind: Deployment
metadata:
name: eshopping-api
spec:
replicas: 3
selector:
matchLabels:
app: eshopping-api
template:
metadata:
labels:
app: eshopping-api
spec:
initContainers:
- name: wait-for-sql
image: busybox:latest
command: ['sh', '-c', "until nc -z sql-service 1433; do echo waiting for sql; sleep 2; done;"]
containers:
- name: api
image: eshopping-api:v1 # Uses the tag we successfully built
imagePullPolicy: IfNotPresent
ports:
- containerPort: 8080
env:
- name: ASPNETCORE_ENVIRONMENT
value: "Development"
- name: ASPNETCORE_URLS
value: "http://0.0.0.0:8080"
- name: ConnectionStrings__EShoppingTutorialDB
value: "Server=sql-service;Database=EShoppingTutorialDB;User Id=sa;Password=YourStrong@Passw0rd;TrustServerCertificate=True"
livenessProbe:
httpGet:
path: /index.html
port: 8080
initialDelaySeconds: 40
periodSeconds: 15
readinessProbe:
httpGet:
path: /index.html
port: 8080
initialDelaySeconds: 30
periodSeconds: 10