From 541f506d9dfcdb2fde19096bfcb4bd3e8d0be276 Mon Sep 17 00:00:00 2001 From: jpgouin Date: Fri, 20 Jun 2025 17:13:47 +0200 Subject: [PATCH] [CLI] add storage-request-size flag (#372) [CLI] add storage-request-size flag --- cli/cmds/cluster_create.go | 6 ++++-- cli/cmds/cluster_create_flags.go | 12 ++++++++++++ docs/cli/cli-docs.md | 2 ++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/cli/cmds/cluster_create.go b/cli/cmds/cluster_create.go index 99fe162d..266a1bb2 100644 --- a/cli/cmds/cluster_create.go +++ b/cli/cmds/cluster_create.go @@ -33,6 +33,7 @@ type CreateConfig struct { agentEnvs cli.StringSlice persistenceType string storageClassName string + storageRequestSize string version string mode string kubeconfigServerHost string @@ -173,8 +174,9 @@ func newCluster(name, namespace string, config *CreateConfig) *v1alpha1.Cluster Version: config.version, Mode: v1alpha1.ClusterMode(config.mode), Persistence: v1alpha1.PersistenceConfig{ - Type: v1alpha1.PersistenceMode(config.persistenceType), - StorageClassName: ptr.To(config.storageClassName), + Type: v1alpha1.PersistenceMode(config.persistenceType), + StorageClassName: ptr.To(config.storageClassName), + StorageRequestSize: config.storageRequestSize, }, }, } diff --git a/cli/cmds/cluster_create_flags.go b/cli/cmds/cluster_create_flags.go index 972d9f9d..9771aa71 100644 --- a/cli/cmds/cluster_create_flags.go +++ b/cli/cmds/cluster_create_flags.go @@ -5,6 +5,7 @@ import ( "github.com/rancher/k3k/pkg/apis/k3k.io/v1alpha1" "github.com/urfave/cli/v2" + "k8s.io/apimachinery/pkg/api/resource" ) func newCreateFlags(config *CreateConfig) []cli.Flag { @@ -60,6 +61,17 @@ func newCreateFlags(config *CreateConfig) []cli.Flag { Usage: "storage class name for dynamic persistence type", Destination: &config.storageClassName, }, + &cli.StringFlag{ + Name: "storage-request-size", + Usage: "storage size for dynamic persistence type", + Destination: &config.storageRequestSize, + Action: func(ctx *cli.Context, value string) error { + if _, err := resource.ParseQuantity(value); err != nil { + return errors.New(`invalid storage size, should be a valid resource quantity e.g "10Gi"`) + } + return nil + }, + }, &cli.StringSliceFlag{ Name: "server-args", Usage: "servers extra arguments", diff --git a/docs/cli/cli-docs.md b/docs/cli/cli-docs.md index da3acd33..e42c292d 100644 --- a/docs/cli/cli-docs.md +++ b/docs/cli/cli-docs.md @@ -68,6 +68,8 @@ Create new cluster **--storage-class-name**="": storage class name for dynamic persistence type +**--storage-request-size**="": storage size for dynamic persistence type + **--token**="": token of the cluster **--version**="": k3s version