-
Notifications
You must be signed in to change notification settings - Fork 82
Design For OADP CLI MVP #1797
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Design For OADP CLI MVP #1797
Changes from 4 commits
a18be57
12379c0
9d2de8c
5fd59fc
79db996
f0dea65
0cbdcb6
6414563
2c699c8
c40344d
c67cf83
ff3da2f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,71 @@ | ||||||||||||||||||||||||||||||||||||||
# Kubectl-oadp plugin design | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
## Abstract | ||||||||||||||||||||||||||||||||||||||
The purpose of this plugin is to allow the customer to create and delete backups, along with creating restores in OADP without needing to alias velero to do so. | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
## Background | ||||||||||||||||||||||||||||||||||||||
The current OADP cli is suboptimal as oc backup delete $foo deletes the k8 object instead of the backup but velero backup delete $foo deletes the backup, along with the backup files in storage. Currently, customers would need to alias velero in order to delete their backups, which is not ideal. The purpose of kubectl-oadp would be to make the cli experience better and easier to use along with enabling users to be able to get the logs of the backups. | ||||||||||||||||||||||||||||||||||||||
NicholasYancey marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
## Goals | ||||||||||||||||||||||||||||||||||||||
- Customers can create and delete backups | ||||||||||||||||||||||||||||||||||||||
- A non-cluster admin can create Non-Admin-Backups (NAB) | ||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would the non-admin backup/restore API calls be different? Since the CRDs are different, I imagine those would need different APIs here as well. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @sseago you are correct, however because we are limited in time based on the internship timeframe. This design is only going to cover NAB's. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is the CLI compatibility across different OADP versions in-scope ?
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @weshayutin Oh, wait -- this is for NABs and not Velero backups? Oh, that wasn't clear from the mention of backups and restores. In that case, we need to be clear by referencing NABs and NARs and not Backups and Restores elsewhere. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Changed doc to make it more clear to the reader |
||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
## Non-Goals | ||||||||||||||||||||||||||||||||||||||
- Non-Admin-Restore due to time constraints | ||||||||||||||||||||||||||||||||||||||
NicholasYancey marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lets add a use-case section too There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed |
||||||||||||||||||||||||||||||||||||||
## High-Level Design | ||||||||||||||||||||||||||||||||||||||
NicholasYancey marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||||||||
Creating a kubectl plugin (kubectl-oadp) will be a good solution to the problem at hand. It will be able to create/delete backups and restores. Non-cluster admin will be able to create NABs without the need for cluster admin to do it for them. | ||||||||||||||||||||||||||||||||||||||
NicholasYancey marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
## Detailed Design | ||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What plugin installation process will look like? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I will leave it out of the design doc for now, but using krew for installations would be nice in the future |
||||||||||||||||||||||||||||||||||||||
The kubectl plugin will have imports from velero to help with the creation/deletion of backups and restores. It will be written in Golang and be using cobra for command-line parsing. The non-admin cli can be a subset of some backup clis that already exist such as backup.go and create.go. | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
What we discovered with the regular commands such as version, backup, and restore we can just import the libraries | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
```sh | ||||||||||||||||||||||||||||||||||||||
NicholasYancey marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||||||||
package cmd | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
import ( | ||||||||||||||||||||||||||||||||||||||
"fmt" | ||||||||||||||||||||||||||||||||||||||
"os" | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
"github.com/spf13/cobra" | ||||||||||||||||||||||||||||||||||||||
"github.com/vmware-tanzu/velero/pkg/cmd/cli/backup" | ||||||||||||||||||||||||||||||||||||||
"github.com/vmware-tanzu/velero/pkg/cmd/cli/restore" | ||||||||||||||||||||||||||||||||||||||
"github.com/vmware-tanzu/velero/pkg/cmd/cli/version" | ||||||||||||||||||||||||||||||||||||||
) | ||||||||||||||||||||||||||||||||||||||
``` | ||||||||||||||||||||||||||||||||||||||
With non-admin, we would have to create the cli ourselves since there are no cli’s for it. | ||||||||||||||||||||||||||||||||||||||
NicholasYancey marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
```sh | ||||||||||||||||||||||||||||||||||||||
func NewCreateCommand(f client.Factory, use string) *cobra.Command { | ||||||||||||||||||||||||||||||||||||||
o := NewCreateOptions() | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
c := &cobra.Command{ | ||||||||||||||||||||||||||||||||||||||
Use: use + " NAME", | ||||||||||||||||||||||||||||||||||||||
Short: "Create a non-admin backup", | ||||||||||||||||||||||||||||||||||||||
Args: cobra.MaximumNArgs(1), | ||||||||||||||||||||||||||||||||||||||
Run: func(c *cobra.Command, args []string) { | ||||||||||||||||||||||||||||||||||||||
cmd.CheckError(o.Complete(args, f)) | ||||||||||||||||||||||||||||||||||||||
cmd.CheckError(o.Validate(c, args, f)) | ||||||||||||||||||||||||||||||||||||||
cmd.CheckError(o.Run(c, f)) | ||||||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
``` | ||||||||||||||||||||||||||||||||||||||
CLI Examples | ||||||||||||||||||||||||||||||||||||||
```sh | ||||||||||||||||||||||||||||||||||||||
oc oadp backup create | ||||||||||||||||||||||||||||||||||||||
oc oadp backup logs | ||||||||||||||||||||||||||||||||||||||
oc oadp restore create | ||||||||||||||||||||||||||||||||||||||
oc oadp restore logs | ||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would be nice to have some markdown
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The examples use
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. heh There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed. added more cli |
||||||||||||||||||||||||||||||||||||||
``` | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
## Alternatives Considered | ||||||||||||||||||||||||||||||||||||||
An alternative that was considered was creating our own CLI from scratch and not using a plugin. We can instead use the existing oc commands and just add on to them with a kubectl plugin. | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
Aliasing is another way in which you could access the velero command line. However, this is not ideal because some individuals do not have permission to use the velero cli, so the kubectl plugin would allow those people to use velero cli. | ||||||||||||||||||||||||||||||||||||||
NicholasYancey marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
## Security Considerations | ||||||||||||||||||||||||||||||||||||||
The user first enters in a command in which the plugin reads the command and creates a velero client factory. The client factory then creates a connection to the kubernetes server. | ||||||||||||||||||||||||||||||||||||||
NicholasYancey marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
## Compatibility | ||||||||||||||||||||||||||||||||||||||
This plugin would need to be updated so that it would be importing the right version of the velero backup and restore libraries. | ||||||||||||||||||||||||||||||||||||||
NicholasYancey marked this conversation as resolved.
Show resolved
Hide resolved
|
Uh oh!
There was an error while loading. Please reload this page.