summaryrefslogtreecommitdiff
path: root/libpod
diff options
context:
space:
mode:
authorzhangguanzhang <zhangguanzhang@qq.com>2021-04-26 20:07:21 +0800
committerzhangguanzhang <zhangguanzhang@qq.com>2021-04-26 23:47:39 +0800
commit3bf0fbf6f6159107c0a2a120ee9f381675af53c0 (patch)
tree352f16a40ffd7a9f33ec9a130efa4d362e4df97e /libpod
parent9ca53cfb4fa137ef1fcfeaff4ab871c488a235f7 (diff)
downloadpodman-3bf0fbf6f6159107c0a2a120ee9f381675af53c0.tar.gz
podman-3bf0fbf6f6159107c0a2a120ee9f381675af53c0.tar.bz2
podman-3bf0fbf6f6159107c0a2a120ee9f381675af53c0.zip
Fixes generate kube incorrect when bind-mounting "/" and "/root"
Signed-off-by: zhangguanzhang <zhangguanzhang@qq.com>
Diffstat (limited to 'libpod')
-rw-r--r--libpod/kube.go9
1 files changed, 8 insertions, 1 deletions
diff --git a/libpod/kube.go b/libpod/kube.go
index 11ccaeadc..adcfe92c9 100644
--- a/libpod/kube.go
+++ b/libpod/kube.go
@@ -1,6 +1,7 @@
package libpod
import (
+ "fmt"
"math/rand"
"os"
"strconv"
@@ -539,11 +540,17 @@ func libpodMountsToKubeVolumeMounts(c *Container) ([]v1.VolumeMount, []v1.Volume
namedVolumes, mounts := c.sortUserVolumes(c.config.Spec)
vms := make([]v1.VolumeMount, 0, len(mounts))
vos := make([]v1.Volume, 0, len(mounts))
- for _, m := range mounts {
+
+ var suffix string
+ for index, m := range mounts {
vm, vo, err := generateKubeVolumeMount(m)
if err != nil {
return vms, vos, err
}
+ // Name will be the same, so use the index as suffix
+ suffix = fmt.Sprintf("-%d", index)
+ vm.Name += suffix
+ vo.Name += suffix
vms = append(vms, vm)
vos = append(vos, vo)
}