-
Notifications
You must be signed in to change notification settings - Fork 88
/
velero.go
136 lines (120 loc) · 6.33 KB
/
velero.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
package print
import (
"fmt"
"strings"
"github.com/fatih/color"
"github.com/replicatedhq/kots/pkg/imageutil"
kotsadmtypes "github.com/replicatedhq/kots/pkg/kotsadm/types"
kotsadmversion "github.com/replicatedhq/kots/pkg/kotsadm/version"
"github.com/replicatedhq/kots/pkg/logger"
snapshottypes "github.com/replicatedhq/kots/pkg/snapshot/types"
)
func VeleroInstallationInstructionsForCLI(log *logger.CLILogger, plugin snapshottypes.VeleroPlugin, registryConfig *kotsadmtypes.RegistryConfig, kotsConfigureCommand string) {
blue := color.New(color.FgHiBlue).SprintFunc()
red := color.New(color.FgHiRed).SprintFunc()
if registryConfig.OverrideRegistry == "" {
// this is an online installation
veleroOnlineCommand := fmt.Sprintf(`velero install \
--no-default-backup-location \
--no-secret \
--use-node-agent \
--uploader-type=restic \
--use-volume-snapshots=false \
--plugins %s`, plugin)
log.ActionWithoutSpinner("No Velero installation has been detected.")
log.ActionWithoutSpinner("Follow these instructions to set up Velero:\n")
log.Info("[1] Install the latest Velero CLI: %s", blue("https://velero.io/docs/v1.10/basic-install/#install-the-cli"))
log.Info("[2] Install Velero: \n\n%s", veleroOnlineCommand)
log.Info("[3] If you're using RancherOS, OpenShift, Microsoft Azure, or VMware Tanzu Kubernetes Grid Integrated Edition (formerly VMware Enterprise PKS), please refer to the following Velero doc to complete node agent configuration: %s", blue("https://velero.io/docs/v1.10/file-system-backup/#configure-node-agent-daemonset-spec"))
log.Info("[4] Configure the backup storage location: \n\n%s", kotsConfigureCommand)
log.ActionWithoutSpinner("")
return
}
// this is an airgapped installation
registry := kotsadmversion.KotsadmRegistry(*registryConfig)
pluginName := strings.Split(strings.Split(string(plugin), "/")[1], ":")[0]
pluginTag, _ := imageutil.GetTag(string(plugin))
veleroAirgapCommand := fmt.Sprintf(`velero install \
--no-default-backup-location \
--no-secret \
--use-node-agent \
--uploader-type=restic \
--use-volume-snapshots=false \
--image %s/velero:%s \
--plugins %s/%s:%s`, registry, red("<velero-version>"), registry, pluginName, pluginTag)
log.ActionWithoutSpinner("No Velero installation has been detected.")
log.ActionWithoutSpinner("Follow these instructions to set up Velero:\n")
log.Info("[1] Install the latest Velero CLI: %s", blue("https://velero.io/docs/v1.10/basic-install/#install-the-cli"))
log.Info("[2] Install Velero")
log.Info(" * Prepare velero images (you will need %s for plugins): %s", red(plugin), blue("https://velero.io/docs/v1.10/on-premises/#air-gapped-deployments"))
log.Info(" * Install velero (replace <velero-version> with actual version): \n\n%s", veleroAirgapCommand)
log.Info(" * Configure the restore helper to use the prepared image: %s", blue("https://velero.io/docs/v1.10/file-system-backup/#customize-restore-helper-container"))
log.Info("[3] If you're using RancherOS, OpenShift, Microsoft Azure, or VMware Tanzu Kubernetes Grid Integrated Edition (formerly VMware Enterprise PKS), please refer to the following Velero doc to complete node agent configuration: %s", blue("https://velero.io/docs/v1.10/file-system-backup/#configure-node-agent-daemonset-spec"))
log.Info("[4] Configure the backup storage location: \n\n%s", kotsConfigureCommand)
log.ActionWithoutSpinner("")
}
type VeleroInstallationInstruction struct {
Title string `json:"title"`
Action string `json:"action"`
Type VeleroInstallationInstructionType `json:"type"`
}
type VeleroInstallationInstructionType string
const (
VeleroInstallationInstructionCommand VeleroInstallationInstructionType = "command"
VeleroInstallationInstructionLink VeleroInstallationInstructionType = "link"
)
func VeleroInstallationInstructionsForUI(plugin snapshottypes.VeleroPlugin, registryConfig *kotsadmtypes.RegistryConfig, kotsConfigureCommand string) []VeleroInstallationInstruction {
if registryConfig.OverrideRegistry == "" {
// this is an online installation
veleroOnlineCommand := fmt.Sprintf(`velero install --no-default-backup-location --no-secret --use-node-agent --uploader-type=restic --use-volume-snapshots=false --plugins %s`, plugin)
return []VeleroInstallationInstruction{
{
Title: "Install Velero",
Action: veleroOnlineCommand,
Type: "command",
},
{
Title: "If you're using RancherOS, OpenShift, Microsoft Azure, or VMware Tanzu Kubernetes Grid Integrated Edition (formerly VMware Enterprise PKS), please refer to the following Velero doc to complete node agent configuration",
Action: "https://velero.io/docs/v1.10/file-system-backup/#configure-node-agent-daemonset-spec",
Type: "link",
},
{
Title: "Configure the backup storage location",
Action: kotsConfigureCommand,
Type: "command",
},
}
}
// this is an airgapped installation
registry := kotsadmversion.KotsadmRegistry(*registryConfig)
pluginName := strings.Split(strings.Split(string(plugin), "/")[1], ":")[0]
pluginTag, _ := imageutil.GetTag(string(plugin))
veleroAirgapCommand := fmt.Sprintf(`velero install --no-default-backup-location --no-secret --use-node-agent --uploader-type=restic --use-volume-snapshots=false --image %s/velero:%s --plugins %s/%s:%s`, registry, "<velero-version>", registry, pluginName, pluginTag)
return []VeleroInstallationInstruction{
{
Title: fmt.Sprintf("Prepare velero images (you will need %s for plugins)", plugin),
Action: "https://velero.io/docs/v1.10/on-premises/#air-gapped-deployments",
Type: "link",
},
{
Title: "Install velero (replace <velero-version> with actual version)",
Action: veleroAirgapCommand,
Type: "command",
},
{
Title: "Configure the restore helper to use the prepared image",
Action: "https://velero.io/docs/v1.10/file-system-backup/#customize-restore-helper-container",
Type: "link",
},
{
Title: "If you're using RancherOS, OpenShift, Microsoft Azure, or VMware Tanzu Kubernetes Grid Integrated Edition (formerly VMware Enterprise PKS), please refer to the following Velero doc to complete node agent configuration",
Action: "https://velero.io/docs/v1.10/file-system-backup/#configure-node-agent-daemonset-spec",
Type: "link",
},
{
Title: "Configure the backup storage location",
Action: kotsConfigureCommand,
Type: "command",
},
}
}