Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Client ID in Azure VM auto-discovery #32360

Merged
merged 1 commit into from Sep 29, 2023

Conversation

atburke
Copy link
Contributor

@atburke atburke commented Sep 21, 2023

This PR adds the client_id option to the Discovery Service for Azure VMs, which sets the client ID of the managed identity for discovered nodes to use when joining the cluster. This allows the discovered nodes to be discovered while having multiple managed identities assigned.

Resolves #28839.

@github-actions
Copy link

🤖 Vercel preview here: https://docs-943ksq91b-goteleport.vercel.app/docs/ver/14.x

lib/client/api.go Outdated Show resolved Hide resolved
lib/config/fileconf.go Outdated Show resolved Hide resolved
@atburke atburke force-pushed the atburke/azure-discovery-client-id branch from 0464480 to fda6e69 Compare September 27, 2023 23:17
@atburke atburke temporarily deployed to vercel September 27, 2023 23:17 — with GitHub Actions Inactive
@github-actions
Copy link

🤖 Vercel preview here: https://docs-a3qgfzw01-goteleport.vercel.app/docs/ver/14.x

@@ -110,6 +114,7 @@ on_gcp() {
sudo /usr/local/bin/teleport node configure \
--proxy="{{ .PublicProxyAddr }}" \
--join-method=${JOIN_METHOD} \
--join-params="${JOIN_PARAMS}" \
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we not introduce a basically free-form arbitrary "join params" field that's easy to abuse IMO, and instead add a specific field for the Azure client ID?

if err != nil {
return trace.Wrap(err)
}
for k, v := range params {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As mentioned above, I would just create a specific flag for the Azure client ID and avoid generic "join params".

publicProxyAddr, installerName, nonce)
if clientID != "" {
script = fmt.Sprintf("export AZURE_CLIENT_ID=%q ; %s", clientID, script)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we this passed to the installer web API as a parameter that would return the script with proper client ID baked in, instead of environment variable?

@@ -122,4 +122,7 @@ const (
# 1. license.pem: Retrieve a license from your Teleport account https://teleport.sh
# if you are an Enterprise customer.
#`

joinParamsUsage = `Comma-separated list of extra join parameters. Supported values:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's not introduce a custom join params "CLI protocol" with custom parsing format, it will quickly get very messy.

@atburke atburke force-pushed the atburke/azure-discovery-client-id branch from fda6e69 to df83661 Compare September 28, 2023 20:00
@atburke atburke temporarily deployed to vercel September 28, 2023 20:00 — with GitHub Actions Inactive
@github-actions
Copy link

🤖 Vercel preview here: https://docs-2eg5uwx3t-goteleport.vercel.app/docs/ver/14.x

PublicProxyAddr string `yaml:"public_proxy_addr,omitempty"`
// Azure is te set of installation parameters specific to Azure.
Azure *AzureInstallParams `yaml:"azure"`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Azure *AzureInstallParams `yaml:"azure"`
Azure *AzureInstallParams `yaml:"azure,omitempty"`

@@ -119,6 +121,7 @@ type azureInstanceFetcher struct {
ResourceGroup string
Labels types.Labels
Parameters map[string]string
ClientID string
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm probably just missing something but one thing I don't understand is how is this ClientID actually being used to pick the correct Azure identity client? In this PR I see that it's being passed to the install script and then to the join config, but where is it actually being used?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

func registerUsingAzureMethod(client joinServiceClient, token string, params RegisterParams) (*proto.Certs, error) {
ctx := context.Background()
certs, err := client.RegisterUsingAzureMethod(ctx, func(challenge string) (*proto.RegisterUsingAzureMethodRequest, error) {
imds := azure.NewInstanceMetadataClient()
if !imds.IsAvailable(ctx) {
return nil, trace.AccessDenied("could not reach instance metadata. Is Teleport running on an Azure VM?")
}
ad, err := imds.GetAttestedData(ctx, challenge)
if err != nil {
return nil, trace.Wrap(err)
}
accessToken, err := imds.GetAccessToken(ctx, params.AzureParams.ClientID)

It's been supported by the Azure join method for a while, this PR just makes it work for discovered nodes too.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok cool.

@atburke atburke temporarily deployed to vercel September 28, 2023 23:51 — with GitHub Actions Inactive
@github-actions
Copy link

🤖 Vercel preview here: https://docs-fkg28baez-goteleport.vercel.app/docs/ver/14.x

This change adds the `client_id` optio nto the Discovery Service for
Azure VMs, which sets the client ID of the managed identity for discovered
nodes to use when joining the cluster. This allows the discovered nodes
to be discovered while having multiple managed identities assigned.
@atburke atburke force-pushed the atburke/azure-discovery-client-id branch from da732ac to 40a30ab Compare September 29, 2023 16:05
@atburke atburke changed the title Specify Client ID in Azure VM auto-discovery Add support for Client ID in Azure VM auto-discovery Sep 29, 2023
@atburke atburke temporarily deployed to vercel September 29, 2023 16:05 — with GitHub Actions Inactive
@atburke atburke temporarily deployed to vercel September 29, 2023 16:05 — with GitHub Actions Inactive
@github-actions
Copy link

🤖 Vercel preview here: https://docs-c6q2otdkb-goteleport.vercel.app/docs/ver/14.x

@github-actions
Copy link

🤖 Vercel preview here: https://docs-6a0v4xmmd-goteleport.vercel.app/docs/ver/14.x

@atburke atburke added this pull request to the merge queue Sep 29, 2023
Merged via the queue into master with commit 15d190b Sep 29, 2023
36 checks passed
@atburke atburke deleted the atburke/azure-discovery-client-id branch September 29, 2023 16:39
@public-teleport-github-review-bot

@atburke See the table below for backport results.

Branch Result
branch/v14 Create PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Azure VM auto-discovery - specify managed identity client ID
4 participants