Skip to content

Commit 7d50cb1

Browse files
committed
Add volumes, working but needs improvement
1 parent d669b6e commit 7d50cb1

File tree

7 files changed

+143
-3
lines changed

7 files changed

+143
-3
lines changed

client/src/components/apps/new.vue

+124
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,96 @@
366366
</v-col>
367367
</v-row>
368368

369+
<v-divider class="ma-5"></v-divider>
370+
<!-- EXTRAVOLUMES -->
371+
372+
<!--
373+
# - name: "test-volume"
374+
# emptyDir: false
375+
# storageClass: "standard"
376+
# size: "1Gi"
377+
# accessModes:
378+
# - "ReadWriteMany"
379+
# mountPath: "/test-volume"
380+
-->
381+
<h4 class="text-uppercase">Volumes</h4>
382+
<div v-for="volume in extraVolumes" v-bind:key="volume.id">
383+
<v-row>
384+
<v-col
385+
cols="12"
386+
md="3"
387+
>
388+
<v-text-field
389+
v-model="volume.name"
390+
label="name"
391+
:readonly="app!='new'"
392+
></v-text-field>
393+
</v-col>
394+
<v-col
395+
cols="12"
396+
md="2"
397+
>
398+
<v-text-field
399+
v-model="volume.size"
400+
label="size"
401+
></v-text-field>
402+
</v-col>
403+
<v-col
404+
cols="12"
405+
md="1"
406+
>
407+
<v-btn
408+
elevation="2"
409+
icon
410+
small
411+
@click="removeVolumeLine(volume.name)"
412+
>
413+
<v-icon dark >
414+
mdi-minus
415+
</v-icon>
416+
</v-btn>
417+
</v-col>
418+
</v-row>
419+
420+
<v-row>
421+
<v-col
422+
cols="12"
423+
md="3"
424+
>
425+
<v-text-field
426+
v-model="volume.storageClass"
427+
label="Storage Class"
428+
></v-text-field>
429+
</v-col>
430+
<v-col
431+
cols="12"
432+
md="3"
433+
>
434+
<v-text-field
435+
v-model="volume.mountPath"
436+
label="Mount Path"
437+
></v-text-field>
438+
</v-col>
439+
</v-row>
440+
</div>
441+
442+
<v-row>
443+
<v-col
444+
cols="12"
445+
>
446+
<v-btn
447+
elevation="2"
448+
icon
449+
small
450+
@click="addVolumeLine()"
451+
>
452+
<v-icon dark >
453+
mdi-plus
454+
</v-icon>
455+
</v-btn>
456+
</v-col>
457+
</v-row>
458+
369459
<v-divider class="ma-5"></v-divider>
370460
<!-- CRONJOBS -->
371461
<h4 class="text-uppercase">Cronjobs</h4>
@@ -615,6 +705,18 @@ export default {
615705
},
616706
*/
617707
],
708+
extraVolumes: [
709+
/*
710+
{
711+
name: 'example-volume',
712+
emptyDir: false,
713+
storageClass: 'standard',
714+
size: '1Gi',
715+
accessMode: ['ReadWriteOnce']
716+
mountPath: '/example/path',
717+
},
718+
*/
719+
],
618720
addons: [
619721
/*
620722
{
@@ -786,6 +888,7 @@ export default {
786888
this.autodeploy = response.data.spec.autodeploy;
787889
this.domain = response.data.spec.domain;
788890
this.envvars = response.data.spec.envVars;
891+
this.extraVolumes = response.data.spec.extraVolumes;
789892
this.containerPort = response.data.spec.image.containerPort;
790893
this.podsize = response.data.spec.podsize;
791894
this.autoscale = response.data.spec.autoscale;
@@ -838,6 +941,7 @@ export default {
838941
targetMemoryUtilizationPercentage : 80,
839942
},
840943
},
944+
extraVolumes: this.extraVolumes,
841945
cronjobs: this.cronjobFormat(this.cronjobs),
842946
addons: this.addons,
843947
@@ -899,6 +1003,7 @@ export default {
8991003
targetMemoryUtilizationPercentage : 80,
9001004
},
9011005
},
1006+
extraVolumes: this.extraVolumes,
9021007
cronjobs: this.cronjobFormat(this.cronjobs),
9031008
addons: this.addons,
9041009
})
@@ -924,6 +1029,25 @@ export default {
9241029
}
9251030
}
9261031
},
1032+
addVolumeLine() {
1033+
this.extraVolumes.push({
1034+
name: 'example-volume',
1035+
emptyDir: false,
1036+
storageClass: 'standard',
1037+
size: '1Gi',
1038+
accessModes: [
1039+
'ReadWriteOnce',
1040+
],
1041+
mountPath: '/example/path',
1042+
});
1043+
},
1044+
removeVolumeLine(index) {
1045+
for (let i = 0; i < this.extraVolumes.length; i++) {
1046+
if (this.extraVolumes[i].name === index) {
1047+
this.extraVolumes.splice(i, 1);
1048+
}
1049+
}
1050+
},
9271051
addCronjobLine() {
9281052
this.cronjobs.push({
9291053
name: 'hello world',

src/kubero.ts

+1
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,7 @@ export class Kubero {
497497
podsize: this.config.podSizeList[0], //TODO select from podsizelist
498498
autoscale: false,
499499
envVars: [], //TODO use custom env vars,
500+
extraVolumes: [], //TODO Not sure how to handlle extra Volumes on PR Apps
500501
image: {
501502
containerPort: 8080, //TODO use custom containerport
502503
repository: pipeline.dockerimage, // FIXME: Maybe needs a lookup into buildpack

src/modules/application.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { IApp, IKubectlMetadata, IKubectlApp, IGithubRepository, ICronjob, IPodSize} from '../types';
1+
import { IApp, IKubectlMetadata, IKubectlApp, IGithubRepository, ICronjob, IPodSize, IExtraVolume} from '../types';
22
import { IAddon } from './addons';
33

44
export class KubectlApp implements IKubectlApp{
@@ -34,6 +34,7 @@ export class App implements IApp{
3434
public autoscale: boolean
3535
//public envVars: {[key: string]: string} = {}
3636
public envVars: {}[] = []
37+
public extraVolumes: IExtraVolume[] = []
3738
public cronjobs: ICronjob[] = []
3839
public addons: IAddon[] = []
3940

@@ -156,6 +157,8 @@ export class App implements IApp{
156157

157158
this.envVars = app.envVars
158159

160+
this.extraVolumes = app.extraVolumes
161+
159162
this.cronjobs = app.cronjobs
160163

161164
this.addons = app.addons

src/routes/apps.ts

+1
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ function createApp(req: Request,) : IApp {
184184
podsize: req.body.podsize,
185185
autoscale: req.body.autoscale,
186186
envVars: req.body.envvars,
187+
extraVolumes: req.body.extraVolumes,
187188
image: {
188189
containerPort: req.body.image.containerport,
189190
repository: req.body.image.repository,

src/routes/pipelines.ts

+1
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ Router.put('/pipelines/:pipeline/:phase/:app', authMiddleware, async function (r
201201
domain: req.body.domain,
202202
podsize: req.body.podsize,
203203
autoscale: req.body.autoscale,
204+
extraVolumes: req.body.extraVolumes,
204205
envVars: req.body.envvars,
205206
image: {
206207
containerPort: req.body.image.containerport,

src/types.ts

+10
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ export interface IApp {
7878
}
7979
}
8080

81+
extraVolumes: IExtraVolume[],
8182
cronjobs: ICronjob[]
8283
addons: IAddon[]
8384
/*
@@ -123,6 +124,15 @@ export interface IApp {
123124
*/
124125
}
125126

127+
export interface IExtraVolume {
128+
name: string,
129+
mountPath: string,
130+
emptyDir: boolean,
131+
size: string,
132+
storageClass: string,
133+
accessModes: string[],
134+
}
135+
126136
export interface ICronjob {
127137
name: string,
128138
schedule: string,

tsconfig.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@
2626

2727
/* Modules */
2828
"module": "commonjs", /* Specify what module code is generated. */
29-
"rootDir": "./src/", /* Specify the root folder within your source files. */
29+
//"rootDir": "./src/", /* Specify the root folder within your source files. */
3030
// "moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */
3131
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
3232
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
33-
// "rootDirs": ["./src/", "./client/src/"], /* Allow multiple folders to be treated as one when resolving modules. */
33+
"rootDirs": ["./src/", "./client/src/"], /* Allow multiple folders to be treated as one when resolving modules. */
3434
// "typeRoots": [], /* Specify multiple folders that act like `./node_modules/@types`. */
3535
// "types": [], /* Specify type package names to be included without being referenced in a source file. */
3636
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */

0 commit comments

Comments
 (0)