-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmanifest.yaml
169 lines (168 loc) · 3.87 KB
/
manifest.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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
apiVersion: apps/v1
kind: Deployment
metadata:
name: pinkfloyd
labels:
app: pinkfloyd
spec:
replicas: 3
selector:
matchLabels:
deployment: pinkfloyd
strategy:
rollingUpdate:
maxSurge: 1
maxUnavailable: 1
type: RollingUpdate
selector:
matchLabels:
app: pinkfloyd
template:
metadata:
labels:
app: pinkfloyd
spec:
volumes:
- name: shared-files
emptyDir: {}
- name: nginx-config-volume
configMap:
name: nginx-config
- name: sa-secret-volume
secret:
secretName: gcp-sa
containers:
- name: php
image: eu.gcr.io/epam-project-316707/cicd_app:__TAG__
env:
- name: DB_USER
valueFrom:
secretKeyRef:
name: db-user
key: db_user
- name: DB_PASS
valueFrom:
secretKeyRef:
name: db-password
key: db_password
- name: DB_NAME
valueFrom:
secretKeyRef:
name: db-name
key: db_name
volumeMounts:
- name: shared-files
mountPath: /var/www/html
lifecycle:
postStart:
exec:
command: ["/bin/sh", "-c", "cp -r /app/. /var/www/html"]
resources:
limits:
memory: 40Mi
requests:
cpu: "10m"
memory: 20Mi
- image: nginx:1.20.0-alpine
name: nginx
volumeMounts:
- name: shared-files
mountPath: /var/www/html
- name: nginx-config-volume
mountPath: /etc/nginx/nginx.conf
subPath: nginx.conf
resources:
limits:
memory: 40Mi
requests:
cpu: "10m"
memory: 20Mi
- name: cloud-sql-proxy
image: gcr.io/cloudsql-docker/gce-proxy:1.17
command:
- "/cloud_sql_proxy"
- "-instances=epam-project-316707:europe-north1:mysql-dev=tcp:3306"
- "-credential_file=/secrets/service_account.json"
securityContext:
runAsNonRoot: true
volumeMounts:
- name: sa-secret-volume
mountPath: /secrets/
readOnly: true
resources:
limits:
memory: 40Mi
requests:
cpu: "10m"
memory: 20Mi
---
apiVersion: v1
kind: Service
metadata:
name: pinkfloyd
spec:
type: LoadBalancer
selector:
app: pinkfloyd
ports:
- protocol: TCP
port: 80
targetPort: 80
---
kind: ConfigMap
apiVersion: v1
metadata:
name: nginx-config
data:
nginx.conf: |
events {
}
http {
server {
listen 80 default_server;
listen [::]:80 default_server;
# Set nginx to serve files from the shared volume!
root /var/www/html;
index index.php index.html;
server_name _;
location / {
try_files $uri $uri/ =404;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
include fastcgi_params;
fastcgi_index index.php;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_pass 127.0.0.1:9000;
}
}
}
---
apiVersion: autoscaling/v2beta2
kind: HorizontalPodAutoscaler
metadata:
name: autoscale
spec:
maxReplicas: 4
minReplicas: 2
behavior:
scaleDown:
stabilizationWindowSeconds: 30
policies:
- type: Percent
value: 50
periodSeconds: 15
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: pinkfloyd
metrics:
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: 80