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:
2024-11-22 14:54:36 +01:00
parent 3b51f41716
commit 95f3abfa74
7 changed files with 184 additions and 28 deletions

View File

@@ -209,10 +209,21 @@ func (chart *HelmChart) generateDeployment(service types.ServiceConfig, deployme
// generate the cronjob if needed
chart.setCronJob(service, appName)
if exchange, ok := service.Labels[labels.LabelExchangeVolume]; ok {
// we need to add a volume and a mount point
ex, err := labelStructs.NewExchangeVolumes(exchange)
if err != nil {
return err
}
for _, exchangeVolume := range ex {
d.AddLegacyVolume("exchange-"+exchangeVolume.Name, exchangeVolume.Type)
d.exchangesVolumes[service.Name] = exchangeVolume
}
}
// get the same-pod label if exists, add it to the list.
// We later will copy some parts to the target deployment and remove this one.
if samePod, ok := service.Labels[labels.LabelSamePod]; ok && samePod != "" {
log.Printf("Found same-pod label for %s", service.Name)
podToMerge[samePod] = &service
}