2019-01-09 16:54:15 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2021-09-08 17:56:18 +00:00
|
|
|
"context"
|
|
|
|
"errors"
|
2019-01-09 16:54:15 +00:00
|
|
|
"os"
|
|
|
|
"path/filepath"
|
|
|
|
|
|
|
|
"github.com/docker/docker/pkg/reexec"
|
2022-03-02 23:47:27 +00:00
|
|
|
"github.com/k3s-io/k3s/pkg/cli/agent"
|
|
|
|
"github.com/k3s-io/k3s/pkg/cli/cert"
|
|
|
|
"github.com/k3s-io/k3s/pkg/cli/cmds"
|
2022-04-29 19:53:34 +00:00
|
|
|
"github.com/k3s-io/k3s/pkg/cli/completion"
|
2022-03-02 23:47:27 +00:00
|
|
|
"github.com/k3s-io/k3s/pkg/cli/crictl"
|
|
|
|
"github.com/k3s-io/k3s/pkg/cli/ctr"
|
|
|
|
"github.com/k3s-io/k3s/pkg/cli/etcdsnapshot"
|
|
|
|
"github.com/k3s-io/k3s/pkg/cli/kubectl"
|
|
|
|
"github.com/k3s-io/k3s/pkg/cli/secretsencrypt"
|
|
|
|
"github.com/k3s-io/k3s/pkg/cli/server"
|
2022-12-07 01:44:53 +00:00
|
|
|
"github.com/k3s-io/k3s/pkg/cli/token"
|
2022-03-02 23:47:27 +00:00
|
|
|
"github.com/k3s-io/k3s/pkg/configfilearg"
|
|
|
|
"github.com/k3s-io/k3s/pkg/containerd"
|
|
|
|
ctr2 "github.com/k3s-io/k3s/pkg/ctr"
|
|
|
|
kubectl2 "github.com/k3s-io/k3s/pkg/kubectl"
|
2019-02-08 04:08:10 +00:00
|
|
|
crictl2 "github.com/kubernetes-sigs/cri-tools/cmd/crictl"
|
2019-01-09 16:54:15 +00:00
|
|
|
"github.com/sirupsen/logrus"
|
2020-08-29 19:46:55 +00:00
|
|
|
"github.com/urfave/cli"
|
2019-01-09 16:54:15 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
reexec.Register("containerd", containerd.Main)
|
|
|
|
reexec.Register("kubectl", kubectl2.Main)
|
2019-02-08 04:08:10 +00:00
|
|
|
reexec.Register("crictl", crictl2.Main)
|
2019-06-30 16:30:25 +00:00
|
|
|
reexec.Register("ctr", ctr2.Main)
|
2019-01-09 16:54:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
cmd := os.Args[0]
|
|
|
|
os.Args[0] = filepath.Base(os.Args[0])
|
|
|
|
if reexec.Init() {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
os.Args[0] = cmd
|
|
|
|
|
|
|
|
app := cmds.NewApp()
|
2020-08-29 19:46:55 +00:00
|
|
|
app.Commands = []cli.Command{
|
2019-01-09 16:54:15 +00:00
|
|
|
cmds.NewServerCommand(server.Run),
|
|
|
|
cmds.NewAgentCommand(agent.Run),
|
|
|
|
cmds.NewKubectlCommand(kubectl.Run),
|
2019-02-08 04:08:10 +00:00
|
|
|
cmds.NewCRICTL(crictl.Run),
|
2019-06-30 16:30:25 +00:00
|
|
|
cmds.NewCtrCommand(ctr.Run),
|
2022-12-07 01:44:53 +00:00
|
|
|
cmds.NewTokenCommands(
|
|
|
|
token.Create,
|
|
|
|
token.Delete,
|
|
|
|
token.Generate,
|
|
|
|
token.List,
|
2023-10-09 17:58:49 +00:00
|
|
|
token.Rotate,
|
2022-12-07 01:44:53 +00:00
|
|
|
),
|
2022-12-05 23:28:01 +00:00
|
|
|
cmds.NewEtcdSnapshotCommands(
|
|
|
|
etcdsnapshot.Delete,
|
|
|
|
etcdsnapshot.List,
|
|
|
|
etcdsnapshot.Prune,
|
|
|
|
etcdsnapshot.Save,
|
2021-05-13 20:36:33 +00:00
|
|
|
),
|
2022-12-05 23:28:01 +00:00
|
|
|
cmds.NewSecretsEncryptCommands(
|
|
|
|
secretsencrypt.Status,
|
|
|
|
secretsencrypt.Enable,
|
|
|
|
secretsencrypt.Disable,
|
|
|
|
secretsencrypt.Prepare,
|
|
|
|
secretsencrypt.Rotate,
|
|
|
|
secretsencrypt.Reencrypt,
|
2023-08-01 17:20:21 +00:00
|
|
|
secretsencrypt.RotateKeys,
|
2021-12-07 22:31:32 +00:00
|
|
|
),
|
2023-10-09 17:58:49 +00:00
|
|
|
cmds.NewCertCommands(
|
2024-03-23 00:13:08 +00:00
|
|
|
cert.Check,
|
2023-10-09 17:58:49 +00:00
|
|
|
cert.Rotate,
|
|
|
|
cert.RotateCA,
|
2021-12-02 21:19:16 +00:00
|
|
|
),
|
2022-04-29 19:53:34 +00:00
|
|
|
cmds.NewCompletionCommand(completion.Run),
|
2019-01-09 16:54:15 +00:00
|
|
|
}
|
|
|
|
|
2021-09-08 17:56:18 +00:00
|
|
|
if err := app.Run(configfilearg.MustParse(os.Args)); err != nil && !errors.Is(err, context.Canceled) {
|
2019-01-09 16:54:15 +00:00
|
|
|
logrus.Fatal(err)
|
|
|
|
}
|
|
|
|
}
|