mirror of
https://git.vectorsigma.ru/public/k3s.git
synced 2026-08-01 20:39:52 +00:00
Add ability to perform an etcd on-demand snapshot via cli (#2819)
* add ability to perform an etcd on-demand snapshot via cli
(cherry picked from commit 13229019f8)
Signed-off-by: Brian Downs <brian.downs@gmail.com>
This commit is contained in:
22
cmd/etcdsnapshot/main.go
Normal file
22
cmd/etcdsnapshot/main.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"github.com/rancher/k3s/pkg/cli/cmds"
|
||||
"github.com/rancher/k3s/pkg/cli/etcdsnapshot"
|
||||
"github.com/rancher/k3s/pkg/configfilearg"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
func main() {
|
||||
app := cmds.NewApp()
|
||||
app.Commands = []cli.Command{
|
||||
cmds.NewEtcdSnapshotCommand(etcdsnapshot.Run),
|
||||
}
|
||||
|
||||
if err := app.Run(configfilearg.MustParse(os.Args)); err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
}
|
||||
@@ -33,10 +33,10 @@ func main() {
|
||||
cmds.NewCRICTL(externalCLIAction("crictl")),
|
||||
cmds.NewCtrCommand(externalCLIAction("ctr")),
|
||||
cmds.NewCheckConfigCommand(externalCLIAction("check-config")),
|
||||
cmds.NewEtcdSnapshotCommand(wrap(version.Program+"-"+cmds.EtcdSnapshotCommand, os.Args)),
|
||||
}
|
||||
|
||||
err := app.Run(os.Args)
|
||||
if err != nil {
|
||||
if err := app.Run(os.Args); err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
}
|
||||
@@ -85,7 +85,7 @@ func stageAndRunCLI(cli *cli.Context, cmd string, args []string) error {
|
||||
return stageAndRun(dataDir, cmd, args)
|
||||
}
|
||||
|
||||
func stageAndRun(dataDir string, cmd string, args []string) error {
|
||||
func stageAndRun(dataDir, cmd string, args []string) error {
|
||||
dir, err := extract(dataDir)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "extracting data")
|
||||
|
||||
@@ -10,6 +10,7 @@ import (
|
||||
"github.com/rancher/k3s/pkg/cli/cmds"
|
||||
"github.com/rancher/k3s/pkg/cli/crictl"
|
||||
"github.com/rancher/k3s/pkg/cli/ctr"
|
||||
"github.com/rancher/k3s/pkg/cli/etcdsnapshot"
|
||||
"github.com/rancher/k3s/pkg/cli/kubectl"
|
||||
"github.com/rancher/k3s/pkg/cli/server"
|
||||
"github.com/rancher/k3s/pkg/configfilearg"
|
||||
@@ -42,6 +43,7 @@ func main() {
|
||||
cmds.NewKubectlCommand(kubectl.Run),
|
||||
cmds.NewCRICTL(crictl.Run),
|
||||
cmds.NewCtrCommand(ctr.Run),
|
||||
cmds.NewEtcdSnapshotCommand(etcdsnapshot.Run),
|
||||
}
|
||||
|
||||
err := app.Run(configfilearg.MustParse(os.Args))
|
||||
|
||||
Reference in New Issue
Block a user