Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add BackupConfiguration Controller (#671)
- [x] Add `BackupConfiguration` Controller - [x] Ensure Sidecar and CronJob - [x] Ensure RBAC for CronJob - [x] Create a CronJob which will create `BackupInstance` crd - [x] Rename BackupInstance to BackupSession Fixes: stashed/stash#649
- Loading branch information
Showing
2 changed files
with
51 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package cmds | ||
|
||
import ( | ||
"github.com/appscode/go/log" | ||
cs "github.com/appscode/stash/client/clientset/versioned" | ||
"github.com/appscode/stash/pkg/backupsession" | ||
"github.com/spf13/cobra" | ||
"k8s.io/client-go/kubernetes" | ||
"k8s.io/client-go/tools/clientcmd" | ||
"kmodules.xyz/client-go/meta" | ||
) | ||
|
||
func NewBackupSession() *cobra.Command { | ||
var ( | ||
masterURL string | ||
kubeconfigPath string | ||
|
||
opt = backupsession.Options{ | ||
Namespace: meta.Namespace(), | ||
} | ||
) | ||
|
||
cmd := &cobra.Command{ | ||
Use: "backup-session", | ||
Short: "create a BackupSession", | ||
DisableAutoGenTag: true, | ||
Run: func(cmd *cobra.Command, args []string) { | ||
config, err := clientcmd.BuildConfigFromFlags(masterURL, kubeconfigPath) | ||
if err != nil { | ||
log.Fatalf("Could not get Kubernetes config: %s", err) | ||
} | ||
kubeClient := kubernetes.NewForConfigOrDie(config) | ||
stashClient := cs.NewForConfigOrDie(config) | ||
|
||
ctrl := backupsession.New(kubeClient, stashClient, opt) | ||
err = ctrl.CreateBackupSession() | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
}, | ||
} | ||
|
||
cmd.Flags().StringVar(&masterURL, "master", "", "The address of the Kubernetes API server (overrides any value in kubeconfig)") | ||
cmd.Flags().StringVar(&kubeconfigPath, "kubeconfig", "", "Path to kubeconfig file with authorization information (the master location is set by the master flag).") | ||
cmd.Flags().StringVar(&opt.Name, "backupsession.name", "", "Set BackupSession Name") | ||
cmd.Flags().StringVar(&opt.Namespace, "backupsession.namespace", opt.Namespace, "Set BackupSession Namespace") | ||
|
||
return cmd | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters