-
Notifications
You must be signed in to change notification settings - Fork 6
/
base.py
127 lines (117 loc) · 3.09 KB
/
base.py
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
import vindaloo
from vindaloo.objects import Deployment, Service
versions = vindaloo.app.versions
CONFIG = {
'maintainer': "Avengers <[email protected]>",
'version': versions['avengers/server'],
'image_name': 'avengers/server',
}
ENV_PUBLIC = {
'ENVIRONMENT': "avengers-stable",
'WEB_CONCURRENCY': "15",
'VERSION': CONFIG['version'],
}
ENV_PRIVATE = {
**ENV_PUBLIC,
'WEB_CONCURRENCY': "40",
'REGISTER_PRIVATE_METHODS': "1",
}
DEPLOYMENT_PUBLIC = Deployment(
name="avengers-server",
replicas=4,
annotations={
'team': "[email protected]",
},
volumes={
'localconfig': {
'secret': {
'secretName': "avengers-local-conf",
}
}
},
containers={
'avengers-server': {
'image': "{}:{}".format(CONFIG['image_name'], CONFIG['version']),
'ports': {
'proxy': 3550,
},
'env': ENV_PUBLIC,
'volumeMounts': {
'localconfig': {
'mountPath': "/local.conf",
'subPath': "local.conf",
}
},
'lifecycle': {
'preStop': {
'exec': {
'command': ["/bin/sh", "-c", "sleep 20; kill -s TERM `cat /gunicorn.pid`"]
}
}
},
'livenessProbe': {
'initialDelaySeconds': 15,
'periodSeconds': 10,
'timeoutSeconds': 3,
'httpGet': {
'path': "/selfcheck",
'port': 3550,
}
},
'readinessProbe': {
'initialDelaySeconds': 15,
'periodSeconds': 10,
'timeoutSeconds': 3,
'httpGet': {
'path': "/ready",
'port': 3550,
}
},
'resources': {
'limits': {
'cpu': "6",
'memory': "6000Mi",
},
'requests': {
'cpu': "3",
'memory': "3000Mi",
}
},
},
},
)
DEPLOYMENT_PRIVATE = DEPLOYMENT_PUBLIC.clone()
DEPLOYMENT_PRIVATE.set_name("avengers-server-private")
DEPLOYMENT_PRIVATE.spec.template.spec.containers['avengers-server']['env'] = ENV_PRIVATE
SERVICE_PUBLIC = Service(
name="avengers-server",
service_type="NodePort",
selector={
'app': "avengers-server",
},
ports={
'rpc': {'port': 3550, 'protocol': 'TCP'},
}
)
SERVICE_PRIVATE = SERVICE_PUBLIC.clone()
SERVICE_PRIVATE.set_name("avengers-server-private")
DOCKER_FILES = [
{
'context_dir': "..",
'config': CONFIG,
'template': "Dockerfile",
'includes': {
'base_image': "../k8s-includes/BaseImage.include",
},
},
]
K8S_OBJECTS = {
"deployment": [
DEPLOYMENT_PUBLIC,
DEPLOYMENT_PRIVATE,
],
"service": [
SERVICE_PUBLIC,
SERVICE_PRIVATE,
]
}