@@ -1072,6 +1072,22 @@ def _get_request_memory(size):
10721072 raise DryccException ('Units are represented in Megabytes(M), or Gigabytes (G)' )
10731073 return "{num}{unit}" .format (num = math .ceil (num ), unit = unit )
10741074
1075+ def _get_volumes_and_mounts (self , process_type , volumes ):
1076+ k8s_volumes , k8s_volume_mounts = [], []
1077+ if volumes :
1078+ for volume in volumes :
1079+ k8s_volumes .append ({
1080+ "name" : volume .name ,
1081+ "claimName" : volume .name
1082+ })
1083+ k8s_volume_mounts .append ({
1084+ "name" : volume .name ,
1085+ "mount_path" : volume .path .get (process_type )
1086+ })
1087+ k8s_volumes .extend (json .loads (settings .KUBERNETES_POD_DEFAULT_VOLUMES ))
1088+ k8s_volume_mounts .extend (json .loads (settings .KUBERNETES_POD_DEFAULT_VOLUME_MOUNTS ))
1089+ return k8s_volumes , k8s_volume_mounts
1090+
10751091 def _gather_app_settings (self , release , app_settings , process_type , replicas , volumes = None ):
10761092 """
10771093 Gathers all required information needed in one easy place for passing into
@@ -1113,17 +1129,7 @@ def _gather_app_settings(self, release, app_settings, process_type, replicas, vo
11131129 healthcheck = config .get_healthcheck ().get (process_type , {})
11141130 if not healthcheck and process_type == 'web' :
11151131 healthcheck = config .get_healthcheck ().get ('web' , {})
1116- volumes_info = [{
1117- "name" : _ .name ,
1118- "claimName" : _ .name ,
1119- } for _ in volumes ] if volumes else []
1120- volumes_info .extend (json .loads (settings .KUBERNETES_POD_DEFAULT_VOLUMES ))
1121- volume_mounts_info = [{
1122- "name" : _ .name ,
1123- "mount_path" : _ .path .get (process_type ),
1124- } for _ in volumes ] if volumes else []
1125- volume_mounts_info .extend (json .loads (settings .KUBERNETES_POD_DEFAULT_VOLUME_MOUNTS ))
1126-
1132+ volumes , volume_mounts = self ._get_volumes_and_mounts (process_type , volumes )
11271133 return {
11281134 'memory' : memory ,
11291135 'cpu' : cpu ,
@@ -1151,7 +1157,7 @@ def _gather_app_settings(self, release, app_settings, process_type, replicas, vo
11511157 'pod_termination_grace_period_each' : config .termination_grace_period ,
11521158 'image_pull_secret_name' : image_pull_secret_name ,
11531159 'image_pull_policy' : image_pull_policy ,
1154- 'volumes' : volumes_info ,
1155- 'volume_mounts' : volume_mounts_info ,
1160+ 'volumes' : volumes ,
1161+ 'volume_mounts' : volume_mounts ,
11561162 'security_context' : json .loads (settings .KUBERNETES_POD_DEFAULT_SECURITY_CONTEXT ),
11571163 }
0 commit comments