@leverege/build-tools 2.2.9 → 2.2.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/server/helmify/helm.js +40 -13
- package/package.json +1 -1
- package/src/helminit-svc +1 -1
|
@@ -35,20 +35,27 @@ function transformGoFormat(input) {
|
|
|
35
35
|
return input.replace(/-/g, '_');
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
38
|
+
function mapServiceToType(service) {
|
|
39
|
+
switch (service) {
|
|
40
|
+
case 'none':
|
|
41
|
+
return null;
|
|
42
|
+
|
|
43
|
+
case 'internal':
|
|
44
|
+
return 'ClusterIP';
|
|
45
|
+
|
|
46
|
+
case 'external':
|
|
47
|
+
return 'NodePort';
|
|
48
|
+
|
|
49
|
+
default:
|
|
50
|
+
return null;
|
|
44
51
|
}
|
|
45
52
|
}
|
|
46
53
|
|
|
47
|
-
async function createValuesYAML(name, version, redisAccess, securityContext, preemptible,
|
|
54
|
+
async function createValuesYAML(name, version, redisAccess, securityContext, preemptible, serviceType) {
|
|
48
55
|
const openPort = service !== 'none';
|
|
49
56
|
const portFromEnv = process.env.PORT || process.env.SERVER_PORT;
|
|
50
57
|
const portNumber = parseInt(portFromEnv) || 8080;
|
|
51
|
-
|
|
58
|
+
let values = {
|
|
52
59
|
[name]: {
|
|
53
60
|
"VERSION": version,
|
|
54
61
|
"PREMPTIBLE": preemptible,
|
|
@@ -69,6 +76,17 @@ async function createValuesYAML(name, version, redisAccess, securityContext, pre
|
|
|
69
76
|
"sqlInstance": ""
|
|
70
77
|
}
|
|
71
78
|
};
|
|
79
|
+
const scalerValues = {
|
|
80
|
+
"horizontalScaler": {
|
|
81
|
+
"minReplicas": 1,
|
|
82
|
+
"maxReplicas": 3,
|
|
83
|
+
"maxCPU": 75
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
if (serviceType) {
|
|
88
|
+
values = Object.assign(values, scalerValues);
|
|
89
|
+
}
|
|
72
90
|
|
|
73
91
|
try {
|
|
74
92
|
await fsp.writeFile('helm/values.yaml', yaml.safeDump(values), 'utf8');
|
|
@@ -78,6 +96,15 @@ async function createValuesYAML(name, version, redisAccess, securityContext, pre
|
|
|
78
96
|
}
|
|
79
97
|
}
|
|
80
98
|
|
|
99
|
+
async function createChartYAML(chart) {
|
|
100
|
+
try {
|
|
101
|
+
await fsp.writeFile('helm/Chart.yaml', yaml.safeDump(chart), 'utf8');
|
|
102
|
+
} catch (err) {
|
|
103
|
+
console.error('Failed to create Chart.yaml file', chalk.red.bold('ERROR'));
|
|
104
|
+
process.exit(1);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
81
108
|
async function createServiceYAML(name, serviceType) {
|
|
82
109
|
try {
|
|
83
110
|
await execa('helminit-svc', [name, serviceType]);
|
|
@@ -177,7 +204,7 @@ module.exports = {
|
|
|
177
204
|
console.log(chalk.green(`\nBootstrapping a new Helm chart for ${name}...\n`));
|
|
178
205
|
const chart = {
|
|
179
206
|
name,
|
|
180
|
-
version:
|
|
207
|
+
version: '1.0.0',
|
|
181
208
|
appVersion
|
|
182
209
|
};
|
|
183
210
|
const chartSafeName = transformGoFormat(name);
|
|
@@ -190,7 +217,7 @@ module.exports = {
|
|
|
190
217
|
process.exit(1);
|
|
191
218
|
}
|
|
192
219
|
|
|
193
|
-
await
|
|
220
|
+
await createChartYAML(chart);
|
|
194
221
|
const templateOpts = await createTemplates();
|
|
195
222
|
const {
|
|
196
223
|
service,
|
|
@@ -200,9 +227,9 @@ module.exports = {
|
|
|
200
227
|
securityContext,
|
|
201
228
|
preemptible
|
|
202
229
|
} = templateOpts;
|
|
230
|
+
const serviceType = mapServiceToType(service);
|
|
203
231
|
|
|
204
|
-
if (
|
|
205
|
-
const serviceType = service === 'internal' ? 'ClusterIP' : 'NodePort';
|
|
232
|
+
if (serviceType) {
|
|
206
233
|
await createServiceYAML(chartSafeName, serviceType);
|
|
207
234
|
}
|
|
208
235
|
|
|
@@ -213,7 +240,7 @@ module.exports = {
|
|
|
213
240
|
const enableFirebase = cloudServices.includes('firebase');
|
|
214
241
|
const enableBigQuery = cloudServices.includes('bigquery');
|
|
215
242
|
await createDeploymentYAML(name, enableFirebase, enableBigQuery);
|
|
216
|
-
await createValuesYAML(chartSafeName, appVersion, redisAccess, securityContext, preemptible,
|
|
243
|
+
await createValuesYAML(chartSafeName, appVersion, redisAccess, securityContext, preemptible, serviceType);
|
|
217
244
|
console.log(chalk.green.bold(`\n\n Helm chart for ${name} is now ready \n`));
|
|
218
245
|
console.log(chalk.yellow.bold('Add any additional env vars to value.yaml and deployment.yaml prior to deployment'));
|
|
219
246
|
}
|
package/package.json
CHANGED