Skip to content

Commit bc0a4b7

Browse files
authored
Merge pull request #250 from kubero-dev/233-improve-external-buildpipeline
#233 improve external buildpipeline
2 parents 7ae5def + 28f5585 commit bc0a4b7

File tree

7 files changed

+461
-17
lines changed

7 files changed

+461
-17
lines changed

client/src/components/apps/new.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1331,7 +1331,7 @@ export default {
13311331
}
13321332
13331333
// Backward compatibility older v1.11.1
1334-
if (this.buildpack.run && this.buildpack.run.readOnlyAppStorage === undefined) {
1334+
if (this.buildpack && this.buildpack.run && this.buildpack.run.readOnlyAppStorage === undefined) {
13351335
this.buildpack.run.readOnlyAppStorage = true;
13361336
}
13371337
});
@@ -1374,7 +1374,7 @@ export default {
13741374
}
13751375
13761376
// Backward compatibility older v1.11.1
1377-
if (this.buildpack.run && this.buildpack.run.readOnlyAppStorage === undefined) {
1377+
if (this.buildpack && this.buildpack.run && this.buildpack.run.readOnlyAppStorage === undefined) {
13781378
this.buildpack.run.readOnlyAppStorage = true;
13791379
}
13801380
@@ -1508,7 +1508,7 @@ export default {
15081508
this.ingress = response.data.spec.ingress || {};
15091509
15101510
// Backward compatibility older v1.11.1
1511-
if (this.buildpack.run && this.buildpack.run.readOnlyAppStorage === undefined) {
1511+
if (this.buildpack && this.buildpack.run && this.buildpack.run.readOnlyAppStorage === undefined) {
15121512
this.buildpack.run.readOnlyAppStorage = true;
15131513
}
15141514
});

client/src/components/pipelines/new.vue

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,11 @@ export default {
506506
}
507507
}
508508
509+
// Bugfix: select a buildpack if none is selected, since it contains basic seciruty settings
510+
if (this.buildpack === undefined) {
511+
this.buildpack = this.buildpackList[0].value;
512+
}
513+
509514
axios.post(`/api/pipelines`, {
510515
pipelineName: this.pipelineName,
511516
domain: this.domain,

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "kubero",
3-
"version": "1.9.0",
3+
"version": "1.11",
44
"description": "Heroku clone on Kubernetes",
55
"main": "dist/index.js",
66
"author": "Gianni Carafa",

src/kubero.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1194,4 +1194,18 @@ export class Kubero {
11941194
public getClusterIssuer() {
11951195
return this.config.clusterissuer;
11961196
}
1197+
1198+
public deployApp(pipelineName: string, phaseName: string, appName: string, tag: string) {
1199+
debug.debug('deploy App: '+appName+' in '+ pipelineName+' phase: '+phaseName);
1200+
1201+
const contextName = this.getContext(pipelineName, phaseName);
1202+
const namespace = pipelineName+'-'+phaseName;
1203+
1204+
if (contextName) {
1205+
this.kubectl.setCurrentContext(contextName);
1206+
this.kubectl.deployApp(namespace, appName, tag);
1207+
this._io.emit('updatedApps', "deplyment_started");
1208+
}
1209+
}
1210+
11971211
}

src/modules/kubectl.ts

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import { IPipeline, IKubectlPipeline, IKubectlPipelineList, IKubectlAppList, IKu
2828
import { App, KubectlApp } from './application';
2929
import { KubectlPipeline } from './pipeline';
3030
import { IAddon, IAddonMinimal } from './addons';
31+
import { version } from 'os';
3132

3233

3334
export class Kubectl {
@@ -909,4 +910,49 @@ export class Kubectl {
909910
}
910911
}
911912

913+
public async deployAppDisabled(namespace: string, app: string, tag: string): Promise<any> {
914+
915+
console.log("deploy app: " + app, ",namespace: " + namespace, ",tag: " + tag);
916+
}
917+
918+
public async deployApp(namespace: string, appName: string, tag: string) {
919+
920+
let deploymentName = appName+'-kuberoapp-web';
921+
console.log("deploy app: " + appName, ",namespace: " + namespace, ",tag: " + tag, ",deploymentName: " + deploymentName);
922+
923+
// format : https://jsonpatch.com/
924+
const patch = [
925+
{
926+
op: 'replace',
927+
path: '/spec/image/tag',
928+
value: tag,
929+
},
930+
];
931+
932+
const apiVersion = "v1alpha1"
933+
const group = "application.kubero.dev"
934+
const plural = "kuberoapps"
935+
936+
const options = { "headers": { "Content-type": 'application/json-patch+json' } };
937+
this.customObjectsApi.patchNamespacedCustomObject(
938+
group,
939+
apiVersion,
940+
namespace,
941+
plural,
942+
appName,
943+
patch,
944+
undefined,
945+
undefined,
946+
undefined,
947+
options
948+
).then(() => {
949+
debug.log(`Deployment ${deploymentName} in Pipeline ${namespace} updated`);
950+
}).catch(error => {
951+
if (error.body.message) {
952+
debug.log('ERROR: '+error.body.message);
953+
}
954+
debug.log('ERROR: '+error);
955+
});
956+
};
957+
912958
}

src/routes/apps.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,3 +317,20 @@ Router.get('/apps', authMiddleware, async function (req: Request, res: Response)
317317
// #swagger.summary = 'Get a list of running apps'
318318
res.send(await req.app.locals.kubero.getAppStateList());
319319
});
320+
321+
// Used GET instead of POST to make it easier to use from the CLI
322+
// Not used in the UI yet
323+
Router.get('/cli/apps/:pipeline/:phase/:app/deploy/:tag', bearerMiddleware, async function (req: Request, res: Response) {
324+
// #swagger.tags = ['Apps']
325+
// #swagger.summary = 'Deploy a prebuilt app tag'
326+
/* #swagger.security = [{
327+
"bearerAuth": {
328+
"type": 'http',
329+
"scheme": 'bearer',
330+
"bearerFormat": 'JWT',
331+
}
332+
}] */
333+
334+
req.app.locals.kubero.deployApp(req.params.pipeline, req.params.phase, req.params.app, req.params.tag);
335+
res.send("deployed");
336+
});

0 commit comments

Comments
 (0)