/
rsync.go
65 lines (59 loc) · 1.62 KB
/
rsync.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package rsync
import (
"github.com/backube/pvc-transfer/transfer"
corev1 "k8s.io/api/core/v1"
)
const (
RsyncContainer = "rsync"
)
const (
rsyncImage = "quay.io/konveyor/rsync-transfer:latest"
rsyncConfig = "rsync-config"
rsyncServiceAccount = "rsync-sa"
rsyncRole = "rsync-role"
rsyncCommunicationMountPath = "/usr/share/rsync"
rsyncRoleBinding = "rsync-rolebinding"
rsyncdLogDir = "rsyncd-logs"
rsyncdLogDirPath = "/var/log/rsyncd/"
)
// applyPodOptions take a PodSpec and PodOptions, applies
// each option to the given podSpec
// Following fields will be mutated:
// - spec.NodeSelector
// - spec.SecurityContext
// - spec.NodeName
// - spec.Containers[*].SecurityContext
// - spec.Containers[*].Resources
func applyPodOptions(podSpec *corev1.PodSpec, options transfer.PodOptions) {
podSpec.NodeSelector = options.NodeSelector
podSpec.NodeName = options.NodeName
podSpec.SecurityContext = &options.PodSecurityContext
for i := range podSpec.Containers {
c := &podSpec.Containers[i]
if options.Image != "" {
c.Image = options.Image
} else {
c.Image = rsyncImage
}
c.SecurityContext = &options.ContainerSecurityContext
c.Resources = options.Resources
}
}
func getTerminationVolumeMounts() []corev1.VolumeMount {
return []corev1.VolumeMount{
{
Name: "termination",
MountPath: "/mnt/termination",
},
}
}
func getTerminationVolumes() []corev1.Volume {
return []corev1.Volume{
{
Name: "termination",
VolumeSource: corev1.VolumeSource{
EmptyDir: &corev1.EmptyDirVolumeSource{},
},
},
}
}