mirror of
https://github.com/portainer/portainer.git
synced 2025-08-05 05:45:22 +02:00
feat(application): Add the ability to use existing volumes when creating an application (#4044)
* feat(applications): update UI to use existing volumes * feat(application): Add the ability to use existing volumes when creating an application * feat(application): Existing persisted folders should default to associated volumes * feat(application): add form validation to existing volume * feat(application): remove the ability to use an existing volume with statefulset application * feat(k8s/applications): minor UI update * feat(k8s/application): minor UI update * feat(volume): allow to increase volume size and few other things * feat(volumes): add the ability to allow volume expansion * fix(storage): fix the storage patch request * fix(k8s/applications): remove conflict leftover * feat(k8s/configure): minor UI update * feat(k8s/volume): minor UI update * fix(storage): change few things Co-authored-by: Anthony Lapenna <lapenna.anthony@gmail.com>
This commit is contained in:
parent
b9c2bf487b
commit
61f97469ab
16 changed files with 436 additions and 40 deletions
|
@ -28,16 +28,28 @@ class KubernetesPersistentVolumeClaimConverter {
|
|||
_.remove(formValues.PersistedFolders, (item) => item.NeedsDeletion);
|
||||
const res = _.map(formValues.PersistedFolders, (item) => {
|
||||
const pvc = new KubernetesPersistentVolumeClaim();
|
||||
if (item.PersistentVolumeClaimName) {
|
||||
pvc.Name = item.PersistentVolumeClaimName;
|
||||
pvc.PreviousName = item.PersistentVolumeClaimName;
|
||||
if (!_.isEmpty(item.ExistingVolume)) {
|
||||
const existantPVC = item.ExistingVolume.PersistentVolumeClaim;
|
||||
pvc.Name = existantPVC.Name;
|
||||
if (item.PersistentVolumeClaimName) {
|
||||
pvc.PreviousName = item.PersistentVolumeClaimName;
|
||||
}
|
||||
pvc.StorageClass = existantPVC.StorageClass;
|
||||
pvc.Storage = existantPVC.Storage.charAt(0) + 'i';
|
||||
pvc.CreationDate = existantPVC.CreationDate;
|
||||
pvc.Id = existantPVC.Id;
|
||||
} else {
|
||||
pvc.Name = formValues.Name + '-' + pvc.Name;
|
||||
if (item.PersistentVolumeClaimName) {
|
||||
pvc.Name = item.PersistentVolumeClaimName;
|
||||
pvc.PreviousName = item.PersistentVolumeClaimName;
|
||||
} else {
|
||||
pvc.Name = formValues.Name + '-' + pvc.Name;
|
||||
}
|
||||
pvc.Storage = '' + item.Size + item.SizeUnit.charAt(0) + 'i';
|
||||
pvc.StorageClass = item.StorageClass;
|
||||
}
|
||||
pvc.MountPath = item.ContainerPath;
|
||||
pvc.Namespace = formValues.ResourcePool.Namespace.Name;
|
||||
pvc.Storage = '' + item.Size + item.SizeUnit.charAt(0) + 'i';
|
||||
pvc.StorageClass = item.StorageClass;
|
||||
pvc.ApplicationOwner = formValues.ApplicationOwner;
|
||||
pvc.ApplicationName = formValues.Name;
|
||||
return pvc;
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
import { KubernetesStorageClass } from 'Kubernetes/models/storage-class/models';
|
||||
import { KubernetesStorageClassCreatePayload } from 'Kubernetes/models/storage-class/payload';
|
||||
import * as JsonPatch from 'fast-json-patch';
|
||||
|
||||
class KubernetesStorageClassConverter {
|
||||
/**
|
||||
|
@ -8,8 +10,24 @@ class KubernetesStorageClassConverter {
|
|||
const res = new KubernetesStorageClass();
|
||||
res.Name = data.metadata.name;
|
||||
res.Provisioner = data.provisioner;
|
||||
res.AllowVolumeExpansion = data.allowVolumeExpansion;
|
||||
return res;
|
||||
}
|
||||
|
||||
static createPayload(storageClass) {
|
||||
const res = new KubernetesStorageClassCreatePayload();
|
||||
res.metadata.name = storageClass.Name;
|
||||
res.provisioner = storageClass.Provisioner;
|
||||
res.allowVolumeExpansion = storageClass.AllowVolumeExpansion;
|
||||
return res;
|
||||
}
|
||||
|
||||
static patchPayload(oldStorageClass, newStorageClass) {
|
||||
const oldPayload = KubernetesStorageClassConverter.createPayload(oldStorageClass);
|
||||
const newPayload = KubernetesStorageClassConverter.createPayload(newStorageClass);
|
||||
const payload = JsonPatch.compare(oldPayload, newPayload);
|
||||
return payload;
|
||||
}
|
||||
}
|
||||
|
||||
export default KubernetesStorageClassConverter;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue