feat(volume): add "exchange volumes"
This volumes are "emptyDir" and can have init command. For example, in a "same-pod", it allow the user to copy data from image to a directory that is mounted on others pods.
This commit is contained in:
@@ -32,6 +32,7 @@ const (
|
||||
LabelConfigMapFiles Label = KatenaryLabelPrefix + "/configmap-files"
|
||||
LabelCronJob Label = KatenaryLabelPrefix + "/cronjob"
|
||||
LabelEnvFrom Label = KatenaryLabelPrefix + "/env-from"
|
||||
LabelExchangeVolume Label = KatenaryLabelPrefix + "/exchange-volumes"
|
||||
)
|
||||
|
||||
var (
|
||||
|
@@ -284,4 +284,40 @@
|
||||
{{ .KatenaryPrefix }}/env-from: |-
|
||||
- myservice1
|
||||
|
||||
"exchange-volumes":
|
||||
short: Add exchange volumes (empty directory on the node) to share data
|
||||
type: "list of objects"
|
||||
long: |-
|
||||
This label allows sharing data between containres. The volume is created in
|
||||
the node and mounted in the pod. It is useful to share data between containers
|
||||
in a "same pod" logic. For example to let PHP-FPM and Nginx share the same direcotory.
|
||||
|
||||
This will create:
|
||||
- an `emptyDir` volume in the deployment
|
||||
- a `voumeMount` in the pod for **each container**
|
||||
- a `initContainer` for each definition
|
||||
|
||||
Fields:
|
||||
- name: the name of the volume (manadatory)
|
||||
- mountPath: the path where the volume is mounted in the pod (optional, default is `/opt`)
|
||||
- init: a command to run to initialize the volume with data (optional)
|
||||
|
||||
!!! Warning
|
||||
This is highly experimental. This is mainly useful when using the "same-pod" label.
|
||||
|
||||
example: |-
|
||||
nginx:
|
||||
# ...
|
||||
labels;
|
||||
{{ .KatenaryPrefix }}/exchange-volumes: |-
|
||||
- name: php-fpm
|
||||
mountPath: /var/www/html
|
||||
php:
|
||||
# ...
|
||||
labels:
|
||||
{{ .KatenaryPrefix }}/exchange-volumes: |-
|
||||
- name: php-fpm
|
||||
mountPath: /opt
|
||||
init: cp -ra /var/www/html/* /opt
|
||||
|
||||
# vim: ft=gotmpl.yaml
|
||||
|
20
generator/labels/labelStructs/exchangeVolume.go
Normal file
20
generator/labels/labelStructs/exchangeVolume.go
Normal file
@@ -0,0 +1,20 @@
|
||||
package labelStructs
|
||||
|
||||
import "gopkg.in/yaml.v3"
|
||||
|
||||
type ExchangeVolume struct {
|
||||
Name string `yaml:"name" json:"name"`
|
||||
MountPath string `yaml:"mountPath" json:"mountPath"`
|
||||
Type string `yaml:"type,omitempty" json:"type,omitempty"`
|
||||
Init string `yaml:"init,omitempty" json:"init,omitempty"`
|
||||
}
|
||||
|
||||
func NewExchangeVolumes(data string) ([]*ExchangeVolume, error) {
|
||||
mapping := []*ExchangeVolume{}
|
||||
|
||||
if err := yaml.Unmarshal([]byte(data), &mapping); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return mapping, nil
|
||||
}
|
Reference in New Issue
Block a user