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

Cluster #12

Merged
merged 3 commits into from
Oct 24, 2023
Merged

Cluster #12

merged 3 commits into from
Oct 24, 2023

Conversation

bigkevmcd
Copy link
Collaborator

@bigkevmcd bigkevmcd commented Oct 18, 2023

This adds support for determining a Cluster ID and getting the ID from the list of clusters.

This is then used to avoid reflecting the "current" cluster (the cluster the controller is running in) as a GitopsCluster which would lead to cluster duplication.

@bigkevmcd bigkevmcd force-pushed the cluster-id branch 2 times, most recently from da292f7 to d4dfe9d Compare October 19, 2023 10:14
@bigkevmcd bigkevmcd force-pushed the cluster-id branch 2 times, most recently from 3488dd8 to 1e7bd3e Compare October 20, 2023 09:57
Extract cluster ID from ConfigMap and the returned list of clusters.
@bigkevmcd bigkevmcd marked this pull request as ready for review October 24, 2023 09:22
@bigkevmcd bigkevmcd requested a review from foot October 24, 2023 09:22

id := fmt.Sprintf("/subscriptions/%s/resourcegroups/%s/providers/Microsoft.ContainerService/managedClusters/%s",
keys["AZURE_SUBSCRIPTION_ID"], keys["AZURE_RESOURCE_GROUP"],
keys["AZURE_RESOURCE_NAME"])
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we bail if some of the values here are missing? ... or maybe just log something?

Worst case we accidentally load the current cluster. Which is not that awful.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good question, this is designed so that if the ConfigMap doesn't exist, it will basically match an incomplete string, that is unlikely to match the ID that comes from the ProviderCluster.

func (p *AzureProvider) ClusterID(ctx context.Context, kubeClient client.Reader) (string, error) {
configMap := &corev1.ConfigMap{}
if err := kubeClient.Get(ctx, client.ObjectKey{Name: "extension-manager-config", Namespace: "kube-system"}, configMap); err != nil {
return "", client.IgnoreNotFound(err)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Right.. if its missing we don't bail either. I'm not so stressed for now.

Copy link
Collaborator

@foot foot left a comment

Choose a reason for hiding this comment

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

Nice!

@bigkevmcd bigkevmcd merged commit 2c151c1 into main Oct 24, 2023
3 checks passed
@bigkevmcd bigkevmcd deleted the cluster-id branch October 24, 2023 12:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants