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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
apiVersion: apps/v1
|
| 2 |
+
kind: StatefulSet
|
| 3 |
+
metadata:
|
| 4 |
+
name: redis
|
| 5 |
+
namespace: ml-intern
|
| 6 |
+
labels:
|
| 7 |
+
app: redis
|
| 8 |
+
spec:
|
| 9 |
+
serviceName: redis
|
| 10 |
+
replicas: 1
|
| 11 |
+
selector:
|
| 12 |
+
matchLabels:
|
| 13 |
+
app: redis
|
| 14 |
+
template:
|
| 15 |
+
metadata:
|
| 16 |
+
labels:
|
| 17 |
+
app: redis
|
| 18 |
+
spec:
|
| 19 |
+
containers:
|
| 20 |
+
- name: redis
|
| 21 |
+
image: redis:7-alpine
|
| 22 |
+
ports:
|
| 23 |
+
- containerPort: 6379
|
| 24 |
+
name: redis
|
| 25 |
+
command:
|
| 26 |
+
- redis-server
|
| 27 |
+
- --appendonly
|
| 28 |
+
- "yes"
|
| 29 |
+
- --maxmemory
|
| 30 |
+
- 1gb
|
| 31 |
+
- --maxmemory-policy
|
| 32 |
+
- allkeys-lru
|
| 33 |
+
resources:
|
| 34 |
+
requests:
|
| 35 |
+
memory: "256Mi"
|
| 36 |
+
cpu: "100m"
|
| 37 |
+
limits:
|
| 38 |
+
memory: "1Gi"
|
| 39 |
+
cpu: "500m"
|
| 40 |
+
volumeMounts:
|
| 41 |
+
- name: redis-data
|
| 42 |
+
mountPath: /data
|
| 43 |
+
livenessProbe:
|
| 44 |
+
exec:
|
| 45 |
+
command:
|
| 46 |
+
- redis-cli
|
| 47 |
+
- ping
|
| 48 |
+
initialDelaySeconds: 30
|
| 49 |
+
periodSeconds: 10
|
| 50 |
+
readinessProbe:
|
| 51 |
+
exec:
|
| 52 |
+
command:
|
| 53 |
+
- redis-cli
|
| 54 |
+
- ping
|
| 55 |
+
initialDelaySeconds: 5
|
| 56 |
+
periodSeconds: 5
|
| 57 |
+
volumeClaimTemplates:
|
| 58 |
+
- metadata:
|
| 59 |
+
name: redis-data
|
| 60 |
+
spec:
|
| 61 |
+
accessModes: ["ReadWriteOnce"]
|
| 62 |
+
resources:
|
| 63 |
+
requests:
|
| 64 |
+
storage: 5Gi
|
| 65 |
+
---
|
| 66 |
+
apiVersion: v1
|
| 67 |
+
kind: Service
|
| 68 |
+
metadata:
|
| 69 |
+
name: redis
|
| 70 |
+
namespace: ml-intern
|
| 71 |
+
labels:
|
| 72 |
+
app: redis
|
| 73 |
+
spec:
|
| 74 |
+
type: ClusterIP
|
| 75 |
+
ports:
|
| 76 |
+
- port: 6379
|
| 77 |
+
targetPort: 6379
|
| 78 |
+
selector:
|
| 79 |
+
app: redis
|
| 80 |
+
---
|
| 81 |
+
apiVersion: apps/v1
|
| 82 |
+
kind: StatefulSet
|
| 83 |
+
metadata:
|
| 84 |
+
name: postgres
|
| 85 |
+
namespace: ml-intern
|
| 86 |
+
labels:
|
| 87 |
+
app: postgres
|
| 88 |
+
spec:
|
| 89 |
+
serviceName: postgres
|
| 90 |
+
replicas: 1
|
| 91 |
+
selector:
|
| 92 |
+
matchLabels:
|
| 93 |
+
app: postgres
|
| 94 |
+
template:
|
| 95 |
+
metadata:
|
| 96 |
+
labels:
|
| 97 |
+
app: postgres
|
| 98 |
+
spec:
|
| 99 |
+
containers:
|
| 100 |
+
- name: postgres
|
| 101 |
+
image: postgres:16-alpine
|
| 102 |
+
ports:
|
| 103 |
+
- containerPort: 5432
|
| 104 |
+
name: postgres
|
| 105 |
+
env:
|
| 106 |
+
- name: POSTGRES_USER
|
| 107 |
+
value: "ml_intern"
|
| 108 |
+
- name: POSTGRES_PASSWORD
|
| 109 |
+
valueFrom:
|
| 110 |
+
secretKeyRef:
|
| 111 |
+
name: ml-intern-secrets
|
| 112 |
+
key: POSTGRES_PASSWORD
|
| 113 |
+
- name: POSTGRES_DB
|
| 114 |
+
value: "ml_intern"
|
| 115 |
+
- name: PGDATA
|
| 116 |
+
value: /var/lib/postgresql/data/pgdata
|
| 117 |
+
resources:
|
| 118 |
+
requests:
|
| 119 |
+
memory: "256Mi"
|
| 120 |
+
cpu: "100m"
|
| 121 |
+
limits:
|
| 122 |
+
memory: "1Gi"
|
| 123 |
+
cpu: "500m"
|
| 124 |
+
volumeMounts:
|
| 125 |
+
- name: postgres-data
|
| 126 |
+
mountPath: /var/lib/postgresql/data
|
| 127 |
+
livenessProbe:
|
| 128 |
+
exec:
|
| 129 |
+
command:
|
| 130 |
+
- pg_isready
|
| 131 |
+
- -U
|
| 132 |
+
- ml_intern
|
| 133 |
+
initialDelaySeconds: 30
|
| 134 |
+
periodSeconds: 10
|
| 135 |
+
readinessProbe:
|
| 136 |
+
exec:
|
| 137 |
+
command:
|
| 138 |
+
- pg_isready
|
| 139 |
+
- -U
|
| 140 |
+
- ml_intern
|
| 141 |
+
initialDelaySeconds: 5
|
| 142 |
+
periodSeconds: 5
|
| 143 |
+
volumeClaimTemplates:
|
| 144 |
+
- metadata:
|
| 145 |
+
name: postgres-data
|
| 146 |
+
spec:
|
| 147 |
+
accessModes: ["ReadWriteOnce"]
|
| 148 |
+
resources:
|
| 149 |
+
requests:
|
| 150 |
+
storage: 10Gi
|
| 151 |
+
---
|
| 152 |
+
apiVersion: v1
|
| 153 |
+
kind: Service
|
| 154 |
+
metadata:
|
| 155 |
+
name: postgres
|
| 156 |
+
namespace: ml-intern
|
| 157 |
+
labels:
|
| 158 |
+
app: postgres
|
| 159 |
+
spec:
|
| 160 |
+
type: ClusterIP
|
| 161 |
+
ports:
|
| 162 |
+
- port: 5432
|
| 163 |
+
targetPort: 5432
|
| 164 |
+
selector:
|
| 165 |
+
app: postgres
|