diff --git a/app/kubernetes/converters/application.js b/app/kubernetes/converters/application.js index 71e94329d..0dc7d3bc9 100644 --- a/app/kubernetes/converters/application.js +++ b/app/kubernetes/converters/application.js @@ -30,6 +30,7 @@ import KubernetesPersistentVolumeClaimConverter from 'Kubernetes/converters/pers import PortainerError from 'Portainer/error'; import { KubernetesIngressHelper } from 'Kubernetes/ingress/helper'; import KubernetesCommonHelper from 'Kubernetes/helpers/commonHelper'; +import { KubernetesConfigurationKinds } from 'Kubernetes/models/configuration/models'; function _apiPortsToPublishedPorts(pList, pRefs) { const ports = _.map(pList, (item) => { @@ -213,6 +214,7 @@ class KubernetesApplicationConverter { configurationVolume.fileMountPath = matchingVolumeMount.mountPath; configurationVolume.rootMountPath = matchingVolumeMount.mountPath; configurationVolume.configurationName = configurationName; + configurationVolume.configurationType = volume.configMap ? KubernetesConfigurationKinds.CONFIGMAP : KubernetesConfigurationKinds.SECRET; acc.push(configurationVolume); } else { @@ -222,6 +224,7 @@ class KubernetesApplicationConverter { configurationVolume.rootMountPath = matchingVolumeMount.mountPath; configurationVolume.configurationKey = item.key; configurationVolume.configurationName = configurationName; + configurationVolume.configurationType = volume.configMap ? KubernetesConfigurationKinds.CONFIGMAP : KubernetesConfigurationKinds.SECRET; acc.push(configurationVolume); }); @@ -294,12 +297,17 @@ class KubernetesApplicationConverter { res.DataAccessPolicy = app.DataAccessPolicy; res.EnvironmentVariables = KubernetesApplicationHelper.generateEnvVariablesFromEnv(app.Env); res.PersistedFolders = KubernetesApplicationHelper.generatePersistedFoldersFormValuesFromPersistedFolders(app.PersistedFolders, persistentVolumeClaims); // generate from PVC and app.PersistedFolders - res.Secrets = KubernetesApplicationHelper.generateConfigurationFormValuesFromEnvAndVolumes(app.Env, app.ConfigurationVolumes, configurations, 'valueFrom.secretKeyRef.name'); + res.Secrets = KubernetesApplicationHelper.generateConfigurationFormValuesFromEnvAndVolumes( + app.Env, + app.ConfigurationVolumes, + configurations, + KubernetesConfigurationKinds.SECRET + ); res.ConfigMaps = KubernetesApplicationHelper.generateConfigurationFormValuesFromEnvAndVolumes( app.Env, app.ConfigurationVolumes, configurations, - 'valueFrom.configMapKeyRef.name' + KubernetesConfigurationKinds.CONFIGMAP ); res.AutoScaler = KubernetesApplicationHelper.generateAutoScalerFormValueFromHorizontalPodAutoScaler(app.AutoScaler, res.ReplicaCount); res.PublishedPorts = KubernetesApplicationHelper.generatePublishedPortsFormValuesFromPublishedPorts(app.ServiceType, app.PublishedPorts, ingresses); diff --git a/app/kubernetes/helpers/application/index.js b/app/kubernetes/helpers/application/index.js index 826aa1fe6..fec22a199 100644 --- a/app/kubernetes/helpers/application/index.js +++ b/app/kubernetes/helpers/application/index.js @@ -145,10 +145,11 @@ class KubernetesApplicationHelper { /* #endregion */ /* #region CONFIGURATIONS FV <> ENV & VOLUMES */ - static generateConfigurationFormValuesFromEnvAndVolumes(env, volumes, configurations, filterCondition) { + static generateConfigurationFormValuesFromEnvAndVolumes(env, volumes, configurations, configurationKind) { + const filterCondition = configurationKind === KubernetesConfigurationKinds.CONFIGMAP ? 'valueFrom.configMapKeyRef.name' : 'valueFrom.secretKeyRef.name'; const finalRes = _.flatMap(configurations, (cfg) => { const cfgEnv = _.filter(env, [filterCondition, cfg.Name]); - const cfgVol = _.filter(volumes, { configurationName: cfg.Name }); + const cfgVol = volumes.filter((volume) => volume.configurationName === cfg.Name && volume.configurationType === configurationKind); if (!cfgEnv.length && !cfgVol.length) { return; } diff --git a/app/kubernetes/views/applications/create/createApplication.html b/app/kubernetes/views/applications/create/createApplication.html index 07f565f97..456807c0e 100644 --- a/app/kubernetes/views/applications/create/createApplication.html +++ b/app/kubernetes/views/applications/create/createApplication.html @@ -483,14 +483,21 @@