mirror of
https://github.com/vmware-tanzu/velero.git
synced 2026-07-28 11:02:43 +00:00
Add --namespace parameter to install command (#1380)
Signed-off-by: Nolan Brubaker <brubakern@vmware.com>
This commit is contained in:
committed by
KubeKween
parent
0750b2c789
commit
f8f0d15da2
@@ -58,6 +58,7 @@ func (o *InstallOptions) BindFlags(flags *pflag.FlagSet) {
|
||||
flags.StringVar(&o.SecretFile, "secret-file", o.SecretFile, "file containing credentials for backup and volume provider")
|
||||
flags.StringVar(&o.Image, "image", o.Image, "image to use for the Velero and restic server pods. Optional.")
|
||||
flags.StringVar(&o.Prefix, "prefix", o.Prefix, "prefix under which all Velero data should be stored within the bucket. Optional.")
|
||||
flags.StringVar(&o.Namespace, "namespace", o.Namespace, "namespace to install Velero and associated data into. Optional.")
|
||||
flags.Var(&o.BackupStorageConfig, "backup-location-config", "configuration to use for the backup storage location. Format is key1=value1,key2=value2")
|
||||
flags.Var(&o.VolumeSnapshotConfig, "snapshot-location-config", "configuration to use for the volume snapshot location. Format is key1=value1,key2=value2")
|
||||
flags.BoolVar(&o.RestoreOnly, "restore-only", o.RestoreOnly, "run the server in restore-only mode. Optional.")
|
||||
@@ -177,18 +178,20 @@ func (o *InstallOptions) Run(c *cobra.Command) error {
|
||||
}
|
||||
factory := client.NewDynamicFactory(dynamicClient)
|
||||
|
||||
errorMsg := fmt.Sprintf("\n\nError installing Velero. Use `kubectl logs deploy/velero -n %s` to check the deploy logs", o.Namespace)
|
||||
|
||||
err = install.Install(factory, resources, os.Stdout)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "\n\nError installing Velero. Use `kubectl logs deploy/velero -n velero` to check the deploy logs")
|
||||
return errors.Wrap(err, errorMsg)
|
||||
}
|
||||
|
||||
if o.Wait {
|
||||
fmt.Println("Waiting for Velero to be ready.")
|
||||
if _, err = install.DeploymentIsReady(factory); err != nil {
|
||||
return errors.Wrap(err, "\n\nError installing Velero. Use `kubectl logs deploy/velero -n velero` to check the deploy logs")
|
||||
if _, err = install.DeploymentIsReady(factory, o.Namespace); err != nil {
|
||||
return errors.Wrap(err, errorMsg)
|
||||
}
|
||||
}
|
||||
fmt.Println("Velero is installed! ⛵ Use 'kubectl logs deployment/velero -n velero' to view the status.")
|
||||
fmt.Printf("Velero is installed! ⛵ Use 'kubectl logs deployment/velero -n %s' to view the status.\n", o.Namespace)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -133,13 +133,13 @@ func isAvailable(c appsv1beta1.DeploymentCondition) bool {
|
||||
}
|
||||
|
||||
// DeploymentIsReady will poll the kubernetes API server to see if the velero deployment is ready to service user requests.
|
||||
func DeploymentIsReady(factory client.DynamicFactory) (bool, error) {
|
||||
func DeploymentIsReady(factory client.DynamicFactory, namespace string) (bool, error) {
|
||||
gvk := schema.FromAPIVersionAndKind(appsv1beta1.SchemeGroupVersion.String(), "Deployment")
|
||||
apiResource := metav1.APIResource{
|
||||
Name: "deployments",
|
||||
Namespaced: true,
|
||||
}
|
||||
c, err := factory.ClientForGroupVersionResource(gvk.GroupVersion(), apiResource, "velero")
|
||||
c, err := factory.ClientForGroupVersionResource(gvk.GroupVersion(), apiResource, namespace)
|
||||
if err != nil {
|
||||
return false, errors.Wrapf(err, "Error creating client for deployment polling")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user