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

Cannot create FleetsMembers resources when using AzureASOManagedControlPlane #5333

Closed
markjgardner opened this issue Dec 12, 2024 · 4 comments · Fixed by #5341
Closed

Cannot create FleetsMembers resources when using AzureASOManagedControlPlane #5333

markjgardner opened this issue Dec 12, 2024 · 4 comments · Fixed by #5341
Assignees
Labels
kind/bug Categorizes issue or PR as related to a bug.

Comments

@markjgardner
Copy link

markjgardner commented Dec 12, 2024

/kind bug

What steps did you take and what happened:
When attempting to create a cluster using AzureASOManagedControlPlane and register it with fleet using fleetsmembers.containerservice.azure.com resourcetype, reconciliation fails because the FleetsMembers resource requires an owner reference of type fleet.containerservice.azure.com. This CRD, however, is not registered as part of the CAPZ install on the management cluster.

apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1
kind: AzureASOManagedControlPlane
metadata:
  name: fleet-cluster1-aks
spec:
  resources:
    - apiVersion: containerservice.azure.com/v1api20210501
      kind: ManagedCluster
      metadata:
        name: fleet-cluster1-aks
      spec:
        location: westus3
        owner:
          name: myfleet-rg
        dnsPrefix: fleet-cluster1
        identity:
          type: SystemAssigned
    - apiversion: containerservice.azure.com/v1api20230315preview
      kind: Fleet
      metadata:
        name: hub-fleet
        annotations:
          serviceoperator.azure.com/reconcile-policy: "skip"
      spec:
        owner:
          name: hub-rg
    - apiVersion: containerservice.azure.com/v1api20230315preview
      kind: FleetsMember
      metadata:
        name: fleet-cluster1-aks
      spec:
        group: apps
        owner:
          name: hub-fleet
        clusterResourceReference:
          group: containerservice.azure.com
          kind: ManagedCluster
          name: fleet-cluster1-aks

failed to get owner: couldn't resolve reference hub-fleet, Group/Kind: containerservice.azure.com/Fleet: no matches for kind "Fleet" in version "containerservice.azure.com/v1api20230315previewstorage"

$> kubectl api-resources --api-group containerservice.azure.com
NAME                        SHORTNAMES   APIVERSION                                        NAMESPACED   KIND
fleetsmembers                            containerservice.azure.com/v1api20230315preview   true         FleetsMember
managedclusters                          containerservice.azure.com/v1api20210501          true         ManagedCluster
managedclustersagentpools                containerservice.azure.com/v1api20210501          true         ManagedClustersAgentPool

What did you expect to happen:
Reconciliation should have detected the existing hub and registered the cluster as a member.

Anything else you would like to add:
ASO Fleet resource docs

Environment:

  • cluster-api-provider-azure version: v1.17.2
  • Kubernetes version: v1.30.6
  • OS (e.g. from /etc/os-release): AKSUbuntu-2204gen2containerd-202411.12.0
@k8s-ci-robot k8s-ci-robot added the kind/bug Categorizes issue or PR as related to a bug. label Dec 12, 2024
@markjgardner
Copy link
Author

markjgardner commented Dec 12, 2024

As a workaround, you must use the armId parameter for the owner reference.

apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1
kind: AzureASOManagedControlPlane
metadata:
  name: fleet-cluster1-aks
spec:
  resources:
    - apiVersion: containerservice.azure.com/v1api20210501
      kind: ManagedCluster
      metadata:
        name: fleet-cluster1-aks
      spec:
        location: westus3
        owner:
          name: myfleet-rg
        dnsPrefix: fleet-cluster1
        identity:
          type: SystemAssigned
    - apiVersion: containerservice.azure.com/v1api20230315preview
      kind: FleetsMember
      metadata:
        name: fleet-cluster1-aks
      spec:
        group: apps
        owner:
          armId: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/hub-rg/providers/Microsoft.ContainerService/fleets/hub-fleet
        clusterResourceReference:
          group: containerservice.azure.com
          kind: ManagedCluster
          name: fleet-cluster1-aks

@willie-yao
Copy link
Contributor

As a part of the implementation of FleetsMembers in CAPZ, we defined the use case of having a pre-defined Fleet hub prior to creating a cluster as a FleetsMember. However with the ASOAPI, it seems like this use case should be supported as well. I'll take a look into this, but the workaround you provided is similar to the existing FleetsMember implementation in the old CAPZ API: #4316

@markjgardner
Copy link
Author

I think just documenting that you have to use an ARM reference would be sufficient. I opened the bug because I couldn't find any documentation on how to reference the fleet hub without also having the hub registered with ASO. I had to export the CRDs and inspect the owner schema to figure it out. I agree that in most cases the hub will be created and managed outside of CAPZ.

@nojnhuh
Copy link
Contributor

nojnhuh commented Dec 17, 2024

CAPZ intentionally does not configure ASO to install all CRDs by default: Azure/azure-service-operator#2920. Additional ASO CRDs can be specified with the ADDITIONAL_ASO_CRDS environment variable as described here: https://capz.sigs.k8s.io/topics/aso#installing-more-crds. That makes the type available so you can create a Fleet ASO resource and then refer to it by its Kubernetes name instead of its ARM ID in the AzureASOManagedControlPlane spec.

@github-project-automation github-project-automation bot moved this from Todo to Done in CAPZ Planning Dec 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug.
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

4 participants