Skip to content

Commit

Permalink
added k3d
Browse files Browse the repository at this point in the history
  • Loading branch information
rsteube committed Sep 25, 2023
1 parent 79709c1 commit bda51cc
Show file tree
Hide file tree
Showing 37 changed files with 772 additions and 0 deletions.
18 changes: 18 additions & 0 deletions completers/k3d_completer/cmd/cluster.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/spf13/cobra"
)

var clusterCmd = &cobra.Command{
Use: "cluster",
Short: "Manage cluster(s)",
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(clusterCmd).Standalone()

rootCmd.AddCommand(clusterCmd)
}
49 changes: 49 additions & 0 deletions completers/k3d_completer/cmd/cluster_create.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/spf13/cobra"
)

var cluster_createCmd = &cobra.Command{
Use: "create NAME",
Short: "Create a new cluster",
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(cluster_createCmd).Standalone()

cluster_createCmd.Flags().StringP("agents", "a", "", "Specify how many agents you want to create")
cluster_createCmd.Flags().String("agents-memory", "", "Memory limit imposed on the agents nodes [From docker]")
cluster_createCmd.Flags().String("api-port", "", "Specify the Kubernetes API server port exposed on the LoadBalancer (Format: `[HOST:]HOSTPORT`)")
cluster_createCmd.Flags().StringP("config", "c", "", "Path of a config file to use")
cluster_createCmd.Flags().StringSliceP("env", "e", []string{}, "Add environment variables to nodes (Format: `KEY[=VALUE][@NODEFILTER[;NODEFILTER...]]`")
cluster_createCmd.Flags().String("gpus", "", "GPU devices to add to the cluster node containers ('all' to pass all GPUs) [From docker]")
cluster_createCmd.Flags().StringSlice("host-alias", []string{}, "Add `ip:host[,host,...]` mappings")
cluster_createCmd.Flags().Bool("host-pid-mode", false, "Enable host pid mode of server(s) and agent(s)")
cluster_createCmd.Flags().StringP("image", "i", "", "Specify k3s image that you want to use for the nodes")
cluster_createCmd.Flags().StringSlice("k3s-arg", []string{}, "Additional args passed to k3s command (Format: `ARG@NODEFILTER[;@NODEFILTER]`)")
cluster_createCmd.Flags().StringSlice("k3s-node-label", []string{}, "Add label to k3s node (Format: `KEY[=VALUE][@NODEFILTER[;NODEFILTER...]]`")
cluster_createCmd.Flags().Bool("kubeconfig-switch-context", false, "Directly switch the default kubeconfig's current-context to the new cluster's context (requires --kubeconfig-update-default)")
cluster_createCmd.Flags().Bool("kubeconfig-update-default", false, "Directly update the default kubeconfig with the new cluster's context")
cluster_createCmd.Flags().StringSlice("lb-config-override", []string{}, "Use dotted YAML path syntax to override nginx loadbalancer settings")
cluster_createCmd.Flags().String("network", "", "Join an existing network")
cluster_createCmd.Flags().Bool("no-image-volume", false, "Disable the creation of a volume for importing images")
cluster_createCmd.Flags().Bool("no-lb", false, "Disable the creation of a LoadBalancer in front of the server nodes")
cluster_createCmd.Flags().Bool("no-rollback", false, "Disable the automatic rollback actions, if anything goes wrong")
cluster_createCmd.Flags().StringSliceP("port", "p", []string{}, "Map ports from the node containers (via the serverlb) to the host (Format: `[HOST:][HOSTPORT:]CONTAINERPORT[/PROTOCOL][@NODEFILTER]`)")
cluster_createCmd.Flags().String("registry-config", "", "Specify path to an extra registries.yaml file")
cluster_createCmd.Flags().String("registry-create", "", "Create a k3d-managed registry and connect it to the cluster (Format: `NAME[:HOST][:HOSTPORT]`")
cluster_createCmd.Flags().StringSlice("registry-use", []string{}, "Connect to one or more k3d-managed registries running locally")
cluster_createCmd.Flags().StringSlice("runtime-label", []string{}, "Add label to container runtime (Format: `KEY[=VALUE][@NODEFILTER[;NODEFILTER...]]`")
cluster_createCmd.Flags().StringSlice("runtime-ulimit", []string{}, "Add ulimit to container runtime (Format: `NAME[=SOFT]:[HARD]`")
cluster_createCmd.Flags().StringP("servers", "s", "", "Specify how many servers you want to create")
cluster_createCmd.Flags().String("servers-memory", "", "Memory limit imposed on the server nodes [From docker]")
cluster_createCmd.Flags().String("subnet", "", "[Experimental: IPAM] Define a subnet for the newly created container network (Example: `172.28.0.0/16`)")
cluster_createCmd.Flags().String("timeout", "", "Rollback changes if cluster couldn't be created in specified duration.")
cluster_createCmd.Flags().String("token", "", "Specify a cluster token. By default, we generate one.")
cluster_createCmd.Flags().StringSliceP("volume", "v", []string{}, "Mount volumes into the nodes (Format: `[SOURCE:]DEST[@NODEFILTER[;NODEFILTER...]]`")
cluster_createCmd.Flags().Bool("wait", false, "Wait for the server(s) to be ready before returning. Use '--timeout DURATION' to not wait forever.")
clusterCmd.AddCommand(cluster_createCmd)
}
21 changes: 21 additions & 0 deletions completers/k3d_completer/cmd/cluster_delete.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/spf13/cobra"
)

var cluster_deleteCmd = &cobra.Command{
Use: "delete [NAME [NAME ...] | --all]",
Short: "Delete cluster(s).",
Aliases: []string{"del", "rm"},
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(cluster_deleteCmd).Standalone()

cluster_deleteCmd.Flags().BoolP("all", "a", false, "Delete all existing clusters")
cluster_deleteCmd.Flags().StringP("config", "c", "", "Path of a config file to use")
clusterCmd.AddCommand(cluster_deleteCmd)
}
20 changes: 20 additions & 0 deletions completers/k3d_completer/cmd/cluster_edit.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/spf13/cobra"
)

var cluster_editCmd = &cobra.Command{
Use: "edit CLUSTER",
Short: "[EXPERIMENTAL] Edit cluster(s).",
Aliases: []string{"update"},
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(cluster_editCmd).Standalone()

cluster_editCmd.Flags().StringSlice("port-add", []string{}, "[EXPERIMENTAL] Map ports from the node containers (via the serverlb) to the host (Format: `[HOST:][HOSTPORT:]CONTAINERPORT[/PROTOCOL][@NODEFILTER]`)")
clusterCmd.AddCommand(cluster_editCmd)
}
22 changes: 22 additions & 0 deletions completers/k3d_completer/cmd/cluster_list.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/spf13/cobra"
)

var cluster_listCmd = &cobra.Command{
Use: "list [NAME [NAME...]]",
Short: "List cluster(s)",
Aliases: []string{"ls", "get"},
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(cluster_listCmd).Standalone()

cluster_listCmd.Flags().Bool("no-headers", false, "Disable headers")
cluster_listCmd.Flags().StringP("output", "o", "", "Output format. One of: json|yaml")
cluster_listCmd.Flags().Bool("token", false, "Print k3s cluster token")
clusterCmd.AddCommand(cluster_listCmd)
}
21 changes: 21 additions & 0 deletions completers/k3d_completer/cmd/cluster_start.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/spf13/cobra"
)

var cluster_startCmd = &cobra.Command{
Use: "start [NAME [NAME...] | --all]",
Short: "Start existing k3d cluster(s)",
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(cluster_startCmd).Standalone()

cluster_startCmd.Flags().BoolP("all", "a", false, "Start all existing clusters")
cluster_startCmd.Flags().String("timeout", "", "Maximum waiting time for '--wait' before canceling/returning.")
cluster_startCmd.Flags().Bool("wait", false, "Wait for the server(s) (and loadbalancer) to be ready before returning.")
clusterCmd.AddCommand(cluster_startCmd)
}
19 changes: 19 additions & 0 deletions completers/k3d_completer/cmd/cluster_stop.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/spf13/cobra"
)

var cluster_stopCmd = &cobra.Command{
Use: "stop [NAME [NAME...] | --all]",
Short: "Stop existing k3d cluster(s)",
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(cluster_stopCmd).Standalone()

cluster_stopCmd.Flags().BoolP("all", "a", false, "Stop all existing clusters")
clusterCmd.AddCommand(cluster_stopCmd)
}
18 changes: 18 additions & 0 deletions completers/k3d_completer/cmd/completion.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/spf13/cobra"
)

var completionCmd = &cobra.Command{
Use: "completion SHELL",
Short: "Generate completion scripts for [bash, zsh, fish, powershell | psh]",
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(completionCmd).Standalone()

rootCmd.AddCommand(completionCmd)
}
18 changes: 18 additions & 0 deletions completers/k3d_completer/cmd/config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/spf13/cobra"
)

var configCmd = &cobra.Command{
Use: "config",
Short: "Work with config file(s)",
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(configCmd).Standalone()

rootCmd.AddCommand(configCmd)
}
21 changes: 21 additions & 0 deletions completers/k3d_completer/cmd/config_init.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/spf13/cobra"
)

var config_initCmd = &cobra.Command{
Use: "init",
Short: "",
Aliases: []string{"create"},
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(config_initCmd).Standalone()

config_initCmd.Flags().BoolP("force", "f", false, "Force overwrite of target file")
config_initCmd.Flags().StringP("output", "o", "", "Write a default k3d config")
configCmd.AddCommand(config_initCmd)
}
19 changes: 19 additions & 0 deletions completers/k3d_completer/cmd/config_migrate.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/spf13/cobra"
)

var config_migrateCmd = &cobra.Command{
Use: "migrate INPUT [OUTPUT]",
Short: "",
Aliases: []string{"update"},
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(config_migrateCmd).Standalone()

configCmd.AddCommand(config_migrateCmd)
}
19 changes: 19 additions & 0 deletions completers/k3d_completer/cmd/debug.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/spf13/cobra"
)

var debugCmd = &cobra.Command{
Use: "debug",
Short: "Debug k3d cluster(s)",
Hidden: true,
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(debugCmd).Standalone()

rootCmd.AddCommand(debugCmd)
}
19 changes: 19 additions & 0 deletions completers/k3d_completer/cmd/debug_loadbalancer.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/spf13/cobra"
)

var debug_loadbalancerCmd = &cobra.Command{
Use: "loadbalancer",
Short: "Debug the loadbalancer",
Aliases: []string{"lb"},
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(debug_loadbalancerCmd).Standalone()

debugCmd.AddCommand(debug_loadbalancerCmd)
}
18 changes: 18 additions & 0 deletions completers/k3d_completer/cmd/debug_loadbalancer_getConfig.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/spf13/cobra"
)

var debug_loadbalancer_getConfigCmd = &cobra.Command{
Use: "get-config CLUSTERNAME",
Short: "",
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(debug_loadbalancer_getConfigCmd).Standalone()

debug_loadbalancerCmd.AddCommand(debug_loadbalancer_getConfigCmd)
}
18 changes: 18 additions & 0 deletions completers/k3d_completer/cmd/help.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/spf13/cobra"
)

var helpCmd = &cobra.Command{
Use: "help [command]",
Short: "Help about any command",
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(helpCmd).Standalone()

rootCmd.AddCommand(helpCmd)
}
19 changes: 19 additions & 0 deletions completers/k3d_completer/cmd/image.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/spf13/cobra"
)

var imageCmd = &cobra.Command{
Use: "image",
Short: "Handle container images.",
Aliases: []string{"images"},
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(imageCmd).Standalone()

rootCmd.AddCommand(imageCmd)
}
23 changes: 23 additions & 0 deletions completers/k3d_completer/cmd/image_import.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/spf13/cobra"
)

var image_importCmd = &cobra.Command{
Use: "import [IMAGE | ARCHIVE [IMAGE | ARCHIVE...]]",
Short: "Import image(s) from docker into k3d cluster(s).",
Aliases: []string{"load"},
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(image_importCmd).Standalone()

image_importCmd.Flags().StringSliceP("cluster", "c", []string{}, "Select clusters to load the image to.")
image_importCmd.Flags().BoolP("keep-tarball", "k", false, "Do not delete the tarball containing the saved images from the shared volume")
image_importCmd.Flags().BoolP("keep-tools", "t", false, "Do not delete the tools node after import")
image_importCmd.Flags().StringP("mode", "m", "", "Which method to use to import images into the cluster [auto, direct, tools]. See https://k3d.io/stable/usage/importing_images/")
imageCmd.AddCommand(image_importCmd)
}
18 changes: 18 additions & 0 deletions completers/k3d_completer/cmd/kubeconfig.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/spf13/cobra"
)

var kubeconfigCmd = &cobra.Command{
Use: "kubeconfig",
Short: "Manage kubeconfig(s)",
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(kubeconfigCmd).Standalone()

rootCmd.AddCommand(kubeconfigCmd)
}
Loading

0 comments on commit bda51cc

Please sign in to comment.