-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexo3.yaml
130 lines (121 loc) · 2.75 KB
/
exo3.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
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
129
130
---
# creation of the namespace used within the file
apiVersion: v1
kind: Namespace
metadata:
name: exo3
labels:
name: exo3
---
# autoscaling for flask deployment
apiVersion: autoscaling/v1
kind: HorizontalPodAutoscaler
metadata:
name: scaling-exo3
namespace: exo3
spec:
scaleTargetRef: # which deployment want to scale
apiVersion: apps/v1
kind: Deployment
name: deploy-exo3
minReplicas: 1 # minimum number of replicas to uses
maxReplicas: 8 # maximum number of replicas to uses
targetCPUUtilizationPercentage: 70 # percentage usage of the CPU over which another replicas is created
---
# Flask, we use deployment because it is easily scalable
apiVersion: apps/v1
kind: Deployment
metadata:
name: deploy-exo3
namespace: exo3
spec:
replicas: 1 # single replica for a start, the autoscaling will add more as necessary
selector:
matchLabels:
target: exo3
template:
metadata:
labels:
target: exo3
spec:
containers:
- name: container-exo3
image: anthonyrouquier/ubuntu_flask:1.0.2 # custom image we created for flask
# resources limitations
resources:
requests:
memory: "128Mi"
cpu: "500m"
limits:
memory: "256Mi"
cpu: "750m"
---
# persistent volume to link to mariadb
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: mariadb-pvc
namespace: exo3
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 5Gi
---
# mariadb, not looking to scale it so a pod is sufficient
apiVersion: v1
kind: Pod
metadata:
name: mariadb-pod
namespace: exo3
spec:
containers:
- name: mariadb
image: mariadb:10.10-rc # one of the standard image from mariadb repository
# resource limitations for mariadb pod
resources:
requests:
memory: "128Mi"
cpu: "500m"
limits:
memory: "256Mi"
cpu: "750m"
env: # we need to specify a password to mariadb
- name: MARIADB_ROOT_PASSWORD
value: example
volumes: # link the previously created pvc to the pod
- name: mariadb-volume
persistentVolumeClaim:
claimName: mariadb-pvc
---
apiVersion: v1
kind: Service
metadata:
name: exo3-flask-svc
namespace: exo3
spec:
type: NodePort # accessible from outside network
selector:
target: exo3
ports:
- port: 80
targetPort: 80 #port ecouté par le pod ciblé
nodePort: 32700
protocol: TCP
selector:
app: exo3
---
apiVersion: v1
kind: Service
metadata:
name: exo3-mariadb-svc
namespace: exo3
labels:
run: exo3-mariadb
spec:
type: ClusterIP # default option, only accessible from within the cluster
selector:
run: exo3-mariadb
ports:
- port: 6379