-
Notifications
You must be signed in to change notification settings - Fork 771
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added support for tmpfs #484
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -375,7 +375,7 @@ func (c *Compose) LoadFile(files []string) (kobject.KomposeObject, error) { | |
serviceConfig.Stdin = composeServiceConfig.StdinOpen | ||
serviceConfig.Tty = composeServiceConfig.Tty | ||
serviceConfig.MemLimit = composeServiceConfig.MemLimit | ||
|
||
serviceConfig.TmpFs = composeServiceConfig.Tmpfs | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
komposeObject.ServiceConfigs[name] = serviceConfig | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -324,6 +324,36 @@ func (k *Kubernetes) ConfigServicePorts(name string, service kobject.ServiceConf | |
return servicePorts | ||
} | ||
|
||
// ConfigTmpfs configure the tmpfs. | ||
func (k *Kubernetes) ConfigTmpfs(name string, service kobject.ServiceConfig) ([]api.VolumeMount, []api.Volume) { | ||
//initializing volumemounts and volumes | ||
volumeMounts := []api.VolumeMount{} | ||
volumes := []api.Volume{} | ||
|
||
for index, volume := range service.TmpFs { | ||
//naming volumes if multiple tmpfs are provided | ||
volumeName := fmt.Sprintf("%s-tmpfs%d", name, index) | ||
|
||
// create a new volume mount object and append to list | ||
volMount := api.VolumeMount{ | ||
Name: volumeName, | ||
MountPath: volume, | ||
} | ||
volumeMounts = append(volumeMounts, volMount) | ||
|
||
//create tmpfs specific empty volumes | ||
volSource := k.ConfigEmptyVolumeSource("tmpfs") | ||
|
||
// create a new volume object using the volsource and add to list | ||
vol := api.Volume{ | ||
Name: volumeName, | ||
VolumeSource: *volSource, | ||
} | ||
volumes = append(volumes, vol) | ||
} | ||
return volumeMounts, volumes | ||
} | ||
|
||
// ConfigVolumes configure the container volumes. | ||
func (k *Kubernetes) ConfigVolumes(name string, service kobject.ServiceConfig) ([]api.VolumeMount, []api.Volume, []*api.PersistentVolumeClaim, error) { | ||
volumeMounts := []api.VolumeMount{} | ||
|
@@ -369,7 +399,7 @@ func (k *Kubernetes) ConfigVolumes(name string, service kobject.ServiceConfig) ( | |
// For PVC we will also create a PVC object and add to list | ||
var volsource *api.VolumeSource | ||
if useEmptyVolumes { | ||
volsource = k.ConfigEmptyVolumeSource() | ||
volsource = k.ConfigEmptyVolumeSource("volume") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. again, can be implied, using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we can't implied here, because volsource is used in |
||
} else { | ||
volsource = k.ConfigPVCVolumeSource(volumeName, readonly) | ||
|
||
|
@@ -396,10 +426,21 @@ func (k *Kubernetes) ConfigVolumes(name string, service kobject.ServiceConfig) ( | |
} | ||
|
||
// ConfigEmptyVolumeSource is helper function to create an EmptyDir api.VolumeSource | ||
func (k *Kubernetes) ConfigEmptyVolumeSource() *api.VolumeSource { | ||
//either for Tmpfs or for emptyvolumes | ||
func (k *Kubernetes) ConfigEmptyVolumeSource(key string) *api.VolumeSource { | ||
//if key is tmpfs | ||
if key == "tmpfs" { | ||
return &api.VolumeSource{ | ||
EmptyDir: &api.EmptyDirVolumeSource{Medium: api.StorageMediumMemory}, | ||
} | ||
|
||
} | ||
|
||
//if key is volume | ||
return &api.VolumeSource{ | ||
EmptyDir: &api.EmptyDirVolumeSource{}, | ||
} | ||
|
||
} | ||
|
||
// ConfigPVCVolumeSource is helper function to create an api.VolumeSource with a PVC | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There may be some issues with this, see https://github.com/docker/libcompose/blob/f12d14623f73a0ca0d7fc37253a99165ae48d39f/config/types.go
It can either be a slice of a string, see: https://docs.docker.com/compose/compose-file/compose-file-v2/#tmpfs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nevermind! I confirmed that both work regardless of string slice or normal string.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it is ok
[]string
is hidden underyaml.Stringorslice
;-)