forked from LaconicNetwork/kompose
Merge pull request #867 from abitrolly/master
Set PVC volume size with kompose.volume.size
This commit is contained in:
commit
d7c515b0cb
@ -142,4 +142,5 @@ type Volumes struct {
|
||||
Container string // Mountpath
|
||||
Mode string // access mode for volume
|
||||
PVCName string // name of PVC
|
||||
PVCSize string // PVC size
|
||||
}
|
||||
|
||||
@ -217,7 +217,7 @@ func dockerComposeToKomposeMapping(composeObject *types.Config) (kobject.Kompose
|
||||
LoadedFrom: "compose",
|
||||
}
|
||||
|
||||
// Step 2. Parse through the object and conver it to kobject.KomposeObject!
|
||||
// Step 2. Parse through the object and convert it to kobject.KomposeObject!
|
||||
// Here we "clean up" the service configuration so we return something that includes
|
||||
// all relevant information as well as avoid the unsupported keys as well.
|
||||
for _, composeServiceConfig := range composeObject.Services {
|
||||
@ -240,6 +240,7 @@ func dockerComposeToKomposeMapping(composeObject *types.Config) (kobject.Kompose
|
||||
serviceConfig.ContainerName = composeServiceConfig.ContainerName
|
||||
serviceConfig.Command = composeServiceConfig.Entrypoint
|
||||
serviceConfig.Args = composeServiceConfig.Command
|
||||
serviceConfig.Labels = composeServiceConfig.Labels
|
||||
|
||||
//
|
||||
// Deploy keys
|
||||
|
||||
@ -267,8 +267,8 @@ func (k *Kubernetes) initIngress(name string, service kobject.ServiceConfig, por
|
||||
}
|
||||
|
||||
// CreatePVC initializes PersistentVolumeClaim
|
||||
func (k *Kubernetes) CreatePVC(name string, mode string) (*api.PersistentVolumeClaim, error) {
|
||||
size, err := resource.ParseQuantity(PVCRequestSize)
|
||||
func (k *Kubernetes) CreatePVC(name string, mode string, size string) (*api.PersistentVolumeClaim, error) {
|
||||
volsize, err := resource.ParseQuantity(size)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "resource.ParseQuantity failed, Error parsing size")
|
||||
}
|
||||
@ -285,7 +285,7 @@ func (k *Kubernetes) CreatePVC(name string, mode string) (*api.PersistentVolumeC
|
||||
Spec: api.PersistentVolumeClaimSpec{
|
||||
Resources: api.ResourceRequirements{
|
||||
Requests: api.ResourceList{
|
||||
api.ResourceStorage: size,
|
||||
api.ResourceStorage: volsize,
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -448,7 +448,15 @@ func (k *Kubernetes) ConfigVolumes(name string, service kobject.ServiceConfig) (
|
||||
|
||||
volsource = k.ConfigPVCVolumeSource(volumeName, readonly)
|
||||
if volume.VFrom == "" {
|
||||
createdPVC, err := k.CreatePVC(volumeName, volume.Mode)
|
||||
defaultSize := PVCRequestSize
|
||||
|
||||
for key, value := range service.Labels {
|
||||
if key == "kompose.volume.size" {
|
||||
defaultSize = value
|
||||
}
|
||||
}
|
||||
|
||||
createdPVC, err := k.CreatePVC(volumeName, volume.Mode, defaultSize)
|
||||
|
||||
if err != nil {
|
||||
return nil, nil, nil, errors.Wrap(err, "k.CreatePVC failed")
|
||||
|
||||
Loading…
Reference in New Issue
Block a user