Adding --join-method flag to teleport configure command#52937
Merged
WilliamLoy merged 5 commits intomasterfrom Mar 13, 2025
Merged
Adding --join-method flag to teleport configure command#52937WilliamLoy merged 5 commits intomasterfrom
WilliamLoy merged 5 commits intomasterfrom
Conversation
Contributor
Author
|
@rosstimothy I'd appreciate a review if you have the time. |
rosstimothy
reviewed
Mar 10, 2025
rosstimothy
reviewed
Mar 11, 2025
Contributor
rosstimothy
left a comment
There was a problem hiding this comment.
This looks good, but I think we can future proof things a bit if we don't hardcode the join methods and instead leverage types.JoinMethods.
What do you think about the following change?
diff --git a/go.mod b/go.mod
index 89090133d3..eab9cbd704 100644
--- a/go.mod
+++ b/go.mod
@@ -592,3 +592,5 @@ replace (
github.com/redis/go-redis/v9 => github.com/gravitational/redis/v9 v9.6.1-teleport.1
github.com/vulcand/predicate => github.com/gravitational/predicate v1.3.2
)
+
+exclude google.golang.org/grpc/stats/opentelemetry v0.0.0-20241028142157-ada6787961b3
diff --git a/tool/teleport/common/teleport.go b/tool/teleport/common/teleport.go
index 4ab0ad433e..699da3468d 100644
--- a/tool/teleport/common/teleport.go
+++ b/tool/teleport/common/teleport.go
@@ -395,6 +395,11 @@ func Run(options Options) (app *kingpin.Application, executedCommand string, con
scpc.Flag("local-addr", "local address which accepted the request").StringVar(&scpFlags.LocalAddr)
scpc.Arg("target", "").StringsVar(&scpFlags.Target)
+ joinMethods := make([]string, 0, len(types.JoinMethods))
+ for _, m := range types.JoinMethods {
+ joinMethods = append(joinMethods, string(m))
+ }
+
// dump flags
dump.Flag("cluster-name",
"Unique cluster name, e.g. example.com.").StringVar(&dumpFlags.ClusterName)
@@ -412,7 +417,7 @@ func Run(options Options) (app *kingpin.Application, executedCommand string, con
dump.Flag("key-file", "Path to a TLS key file for the proxy.").ExistingFileVar(&dumpFlags.KeyFile)
dump.Flag("data-dir", "Path to a directory where Teleport keep its data.").Default(defaults.DataDir).StringVar(&dumpFlags.DataDir)
dump.Flag("token", "Invitation token or path to file with token value to register with an auth server.").StringVar(&dumpFlags.AuthToken)
- dump.Flag("join-method", "Method to use to join the cluster (token, iam, ec2, kubernetes, azure, gcp, oracle, github, circleci, gitlab, tpm)").Default("token").EnumVar(&dumpFlags.JoinMethod, "token", "iam", "ec2", "kubernetes", "azure", "gcp", "oracle", "github", "circleci", "tpm")
+ dump.Flag("join-method", fmt.Sprintf("Method to use to join the cluster (%s)", strings.Join(joinMethods, ", "))).Default("token").EnumVar(&dumpFlags.JoinMethod, joinMethods...)
dump.Flag("roles", "Comma-separated list of roles to create config with.").StringVar(&dumpFlags.Roles)
dump.Flag("auth-server", "Address of the auth server.").StringVar(&dumpFlags.AuthServer)
dump.Flag("proxy", "Address of the proxy.").StringVar(&dumpFlags.ProxyAddress)
@@ -430,6 +435,7 @@ func Run(options Options) (app *kingpin.Application, executedCommand string, con
dumpNodeConfigure.Flag("output",
`Write to stdout with "--output=stdout", default config file with "--output=file" or custom path with --output=file:///path`).Short('o').Default(
teleport.SchemeStdout).StringVar(&dumpFlags.output)
+
dumpNodeConfigure.Flag("version", "Teleport configuration version.").Default(defaults.TeleportConfigVersionV3).StringVar(&dumpFlags.Version)
dumpNodeConfigure.Flag("public-addr", "The hostport that the node advertises for the SSH endpoint.").StringVar(&dumpFlags.PublicAddr)
dumpNodeConfigure.Flag("data-dir", "Path to a directory where Teleport keep its data.").Default(defaults.DataDir).StringVar(&dumpFlags.DataDir)
@@ -438,7 +444,7 @@ func Run(options Options) (app *kingpin.Application, executedCommand string, con
dumpNodeConfigure.Flag("proxy", "Address of the proxy server.").StringVar(&dumpFlags.ProxyAddress)
dumpNodeConfigure.Flag("labels", "Comma-separated list of labels to add to newly created nodes ex) env=staging,cloud=aws.").StringVar(&dumpFlags.NodeLabels)
dumpNodeConfigure.Flag("ca-pin", "Comma-separated list of SKPI hashes for the CA used to verify the auth server.").StringVar(&dumpFlags.CAPin)
- dumpNodeConfigure.Flag("join-method", "Method to use to join the cluster (token, iam, ec2, kubernetes, azure, gcp, oracle, github, circleci, gitlab, tpm)").Default("token").EnumVar(&dumpFlags.JoinMethod, "token", "iam", "ec2", "kubernetes", "azure", "gcp", "oracle", "github", "circleci", "tpm")
+ dumpNodeConfigure.Flag("join-method", fmt.Sprintf("Method to use to join the cluster (%s)", strings.Join(joinMethods, ", "))).Default("token").EnumVar(&dumpFlags.JoinMethod, joinMethods...)
dumpNodeConfigure.Flag("node-name", "Name for the Teleport node.").StringVar(&dumpFlags.NodeName)
dumpNodeConfigure.Flag("silent", "Suppress user hint message.").BoolVar(&dumpFlags.Silent)
dumpNodeConfigure.Flag("azure-client-id", "Sets the client ID of the managed identity to join with. Only applies to the 'azure' join method.").StringVar(&dumpFlags.AzureClientID)
Contributor
Author
|
@rosstimothy I incorporated your suggestion. Thank you. |
rosstimothy
reviewed
Mar 11, 2025
rosstimothy
reviewed
Mar 11, 2025
Co-authored-by: rosstimothy <39066650+rosstimothy@users.noreply.github.com>
Co-authored-by: rosstimothy <39066650+rosstimothy@users.noreply.github.com>
rosstimothy
approved these changes
Mar 12, 2025
camscale
approved these changes
Mar 13, 2025
|
@WilliamLoy See the table below for backport results.
|
This was referenced Mar 14, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A customer requested the
--join-methodflag be made available as an option when using theteleport configurecommand.I didn't see a technical reason as to why this flag wasn't already available in the command so I've added it to this PR.
Changelog: Added a
--join-methodflag to theteleport configurecommand