@@ -80,7 +80,9 @@ function getFunctionDescription(
80
80
secrets ,
81
81
cpu ,
82
82
affinity ,
83
- tolerations
83
+ tolerations ,
84
+ volumes ,
85
+ volumeMounts
84
86
) {
85
87
const funcs = {
86
88
apiVersion : 'kubeless.io/v1beta1' ,
@@ -119,7 +121,8 @@ function getFunctionDescription(
119
121
if ( desc ) {
120
122
funcs . metadata . annotations [ 'kubeless.serverless.com/description' ] = desc ;
121
123
}
122
- if ( image || env || memory || secrets || cpu || affinity || tolerations ) {
124
+
125
+ if ( image || env || memory || secrets || cpu || affinity || tolerations || volumes ) {
123
126
const container = {
124
127
name : funcName ,
125
128
} ;
@@ -154,20 +157,37 @@ function getFunctionDescription(
154
157
} ,
155
158
} ,
156
159
} ;
160
+
161
+ // convert secretes to volumes and volume mounts
157
162
if ( secrets !== undefined && secrets . length > 0 ) {
158
- if ( container . volumeMounts === undefined ) {
159
- container . volumeMounts = [ ] ;
163
+ if ( volumes === undefined ) {
164
+ // eslint-disable-next-line no-param-reassign
165
+ volumes = [ ] ;
160
166
}
161
- if ( funcs . spec . deployment . spec . template . spec . volumes === undefined ) {
162
- funcs . spec . deployment . spec . template . spec . volumes = [ ] ;
167
+ if ( volumeMounts === undefined ) {
168
+ // eslint-disable-next-line no-param-reassign
169
+ volumeMounts = [ ] ;
163
170
}
164
171
secrets . forEach ( secret => {
165
- container . volumeMounts . push ( { name : `${ secret } -vol` , mountPath : `/${ secret } ` } ) ;
166
- funcs . spec . deployment . spec . template . spec . volumes
167
- . push ( { name : `${ secret } -vol` , secret : { secretName : secret } } ) ;
172
+ volumes . push ( {
173
+ name : `${ secret } -vol` ,
174
+ secret : { secretName : secret } ,
175
+ } ) ;
176
+ volumeMounts . push ( {
177
+ mountPath : `/${ secret } ` ,
178
+ name : `${ secret } -vol` ,
179
+ } ) ;
168
180
} ) ;
169
181
}
170
182
183
+ if ( volumes !== undefined && volumes . length > 0 ) {
184
+ funcs . spec . deployment . spec . template . spec . volumes = volumes ;
185
+ }
186
+
187
+ if ( volumeMounts !== undefined && volumeMounts . length > 0 ) {
188
+ container . volumeMounts = volumeMounts ;
189
+ }
190
+
171
191
if ( affinity ) {
172
192
funcs . spec . deployment . spec . template . spec . affinity = affinity ;
173
193
}
@@ -178,6 +198,7 @@ function getFunctionDescription(
178
198
return funcs ;
179
199
}
180
200
201
+
181
202
function waitForDeployment ( funcName , requestMoment , namespace , options ) {
182
203
const opts = _ . defaults ( { } , options , {
183
204
verbose : false ,
@@ -420,6 +441,7 @@ function deployFunction(f, namespace, runtime, contentType, options) {
420
441
const fenv = parseEnv ( f . environment ) ;
421
442
environment = environment ? environment . concat ( fenv ) : fenv ;
422
443
}
444
+
423
445
const funcs = getFunctionDescription (
424
446
f . id ,
425
447
namespace ,
@@ -441,8 +463,11 @@ function deployFunction(f, namespace, runtime, contentType, options) {
441
463
f . secrets ,
442
464
f . cpu || options . cpu ,
443
465
f . affinity || options . affinity ,
444
- f . tolerations || options . tolerations
466
+ f . tolerations || options . tolerations ,
467
+ f . volumes || options . volumes ,
468
+ f . volumeMounts || options . volumeMounts
445
469
) ;
470
+
446
471
return functionsApi . getItem ( funcs . metadata . name ) . then ( ( res ) => {
447
472
if ( res . code === 404 ) {
448
473
return deployFunctionAndWait (
0 commit comments