diff --git a/cmd/k3s/command.go b/cmd/k3s/command.go index 7b840987a..1ae74c7c1 100644 --- a/cmd/k3s/command.go +++ b/cmd/k3s/command.go @@ -19,6 +19,8 @@ var ( ciFlag bool clusterNameFlag string clusterTypeFlag string + k3sIpServersFlag []string + k3sIpAgentsFlag []string dnsProviderFlag string domainNameFlag string githubOrgFlag string @@ -74,6 +76,9 @@ func Create() *cobra.Command { createCmd.Flags().BoolVar(&ciFlag, "ci", false, "if running kubefirst in ci, set this flag to disable interactive features") createCmd.Flags().StringVar(&clusterNameFlag, "cluster-name", "kubefirst", "the name of the cluster to create") createCmd.Flags().StringVar(&clusterTypeFlag, "cluster-type", "mgmt", "the type of cluster to create (i.e. mgmt|workload)") + createCmd.Flags().StringSliceVar(&k3sIpServersFlag, "ip-servers", []string{}, "the list of k3s (servers) ip x.x.x.x y.y.y.y space separated (required)") + createCmd.MarkFlagRequired("k3s-ips-servers") + createCmd.Flags().StringSliceVar(&k3sIpAgentsFlag, "k3s-ip-agents", []string{}, "the list of k3s (agents) ip x.x.x.x y.y.y.y space separated (required)") createCmd.Flags().StringVar(&dnsProviderFlag, "dns-provider", "cloudflare", fmt.Sprintf("the dns provider - one of: %s", supportedDNSProviders)) createCmd.Flags().StringVar(&domainNameFlag, "domain-name", "", "the cloudProvider DNS Name to use for DNS records (i.e. your-domain.com|subdomain.your-domain.com) (required)") createCmd.Flags().StringVar(&gitProviderFlag, "git-provider", "github", fmt.Sprintf("the git provider - one of: %s", supportedGitProviders)) diff --git a/internal/types/flags.go b/internal/types/flags.go index 743001cae..c37d07137 100644 --- a/internal/types/flags.go +++ b/internal/types/flags.go @@ -22,6 +22,8 @@ type CliFlags struct { GitopsTemplateBranch string GitopsTemplateURL string GoogleProject string + K3sIpServers []string + K3sIpAgents []string UseTelemetry bool Ecr bool } diff --git a/internal/utilities/flags.go b/internal/utilities/flags.go index 76165de28..495870ac1 100644 --- a/internal/utilities/flags.go +++ b/internal/utilities/flags.go @@ -94,6 +94,22 @@ func GetFlags(cmd *cobra.Command, cloudProvider string) (types.CliFlags, error) } cliFlags.CloudRegion = cloudRegionFlag } + if cloudProvider == "k3s" { + k3sIpServers, err := cmd.Flags().GetStringSlice("k3s-ip-servers") + if err != nil { + progress.Error(err.Error()) + return cliFlags, err + } + cliFlags.K3sIpServers = k3sIpServers + } + if cloudProvider == "k3s" { + k3sIpAgents, err := cmd.Flags().GetStringSlice("k3s-ip-servers") + if err != nil { + progress.Error(err.Error()) + return cliFlags, err + } + cliFlags.K3sIpAgents = k3sIpAgents + } if cloudProvider == "aws" { ecrFlag, err := cmd.Flags().GetBool("ecr")