Skip to content

Commit 9f3d897

Browse files
committed
Bump Cluster API Visualizer to v1.3.0 and visualize ASO CRDs
1 parent 743d95f commit 9f3d897

15 files changed

+135
-3
lines changed

azure/services/aso/aso.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import (
3838
"sigs.k8s.io/cluster-api-provider-azure/azure"
3939
"sigs.k8s.io/cluster-api-provider-azure/util/aso"
4040
"sigs.k8s.io/cluster-api-provider-azure/util/tele"
41+
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
4142
"sigs.k8s.io/controller-runtime/pkg/client"
4243
"sigs.k8s.io/controller-runtime/pkg/client/apiutil"
4344
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
@@ -175,6 +176,8 @@ func (r *reconciler[T]) CreateOrUpdateResource(ctx context.Context, spec azure.A
175176
if labels == nil {
176177
labels = make(map[string]string)
177178
}
179+
labels[clusterv1.ClusterNameLabel] = r.clusterName
180+
178181
annotations := parameters.GetAnnotations()
179182
if annotations == nil {
180183
annotations = make(map[string]string)

azure/services/aso/aso_test.go

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import (
3535
"sigs.k8s.io/cluster-api-provider-azure/azure/mock_azure"
3636
"sigs.k8s.io/cluster-api-provider-azure/azure/services/aso/mock_aso"
3737
gomockinternal "sigs.k8s.io/cluster-api-provider-azure/internal/test/matchers/gomock"
38+
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
3839
"sigs.k8s.io/controller-runtime/pkg/client"
3940
"sigs.k8s.io/controller-runtime/pkg/client/apiutil"
4041
fakeclient "sigs.k8s.io/controller-runtime/pkg/client/fake"
@@ -122,6 +123,9 @@ func TestCreateOrUpdateResource(t *testing.T) {
122123
Name: "name",
123124
Namespace: "namespace",
124125
OwnerReferences: ownerRefs(),
126+
Labels: map[string]string{
127+
clusterv1.ClusterNameLabel: clusterName,
128+
},
125129
},
126130
Status: asoresourcesv1.ResourceGroup_STATUS{},
127131
})).To(Succeed())
@@ -206,6 +210,9 @@ func TestCreateOrUpdateResource(t *testing.T) {
206210
Name: "name",
207211
Namespace: "namespace",
208212
OwnerReferences: ownerRefs(),
213+
Labels: map[string]string{
214+
clusterv1.ClusterNameLabel: clusterName,
215+
},
209216
Annotations: map[string]string{
210217
asoannotations.PerResourceSecret: "cluster-aso-secret",
211218
},
@@ -259,6 +266,9 @@ func TestCreateOrUpdateResource(t *testing.T) {
259266
Name: "name",
260267
Namespace: "namespace",
261268
OwnerReferences: ownerRefs(),
269+
Labels: map[string]string{
270+
clusterv1.ClusterNameLabel: clusterName,
271+
},
262272
Annotations: map[string]string{
263273
asoannotations.PerResourceSecret: "cluster-aso-secret",
264274
},
@@ -308,6 +318,9 @@ func TestCreateOrUpdateResource(t *testing.T) {
308318
Name: "name",
309319
Namespace: "namespace",
310320
OwnerReferences: ownerRefs(),
321+
Labels: map[string]string{
322+
clusterv1.ClusterNameLabel: clusterName,
323+
},
311324
Annotations: map[string]string{
312325
asoannotations.PerResourceSecret: "cluster-aso-secret",
313326
},
@@ -387,6 +400,9 @@ func TestCreateOrUpdateResource(t *testing.T) {
387400
Name: "name",
388401
Namespace: "namespace",
389402
OwnerReferences: ownerRefs(),
403+
Labels: map[string]string{
404+
clusterv1.ClusterNameLabel: clusterName,
405+
},
390406
},
391407
Status: asoresourcesv1.ResourceGroup_STATUS{
392408
Conditions: []conditions.Condition{
@@ -431,6 +447,9 @@ func TestCreateOrUpdateResource(t *testing.T) {
431447
Name: "name",
432448
Namespace: "namespace",
433449
OwnerReferences: ownerRefs(),
450+
Labels: map[string]string{
451+
clusterv1.ClusterNameLabel: clusterName,
452+
},
434453
Annotations: map[string]string{
435454
asoannotations.ReconcilePolicy: string(asoannotations.ReconcilePolicySkip),
436455
},
@@ -487,6 +506,9 @@ func TestCreateOrUpdateResource(t *testing.T) {
487506
Name: "name",
488507
Namespace: "namespace",
489508
OwnerReferences: ownerRefs(),
509+
Labels: map[string]string{
510+
clusterv1.ClusterNameLabel: clusterName,
511+
},
490512
Annotations: map[string]string{
491513
asoannotations.ReconcilePolicy: string(asoannotations.ReconcilePolicySkip),
492514
},
@@ -542,6 +564,7 @@ func TestCreateOrUpdateResource(t *testing.T) {
542564
Name: "name",
543565
Namespace: "namespace",
544566
Labels: map[string]string{
567+
clusterv1.ClusterNameLabel: clusterName,
545568
//nolint:staticcheck // Referencing this deprecated value is required for backwards compatibility.
546569
infrav1.OwnedByClusterLabelKey: clusterName,
547570
},
@@ -597,6 +620,9 @@ func TestCreateOrUpdateResource(t *testing.T) {
597620
Name: "name",
598621
Namespace: "namespace",
599622
OwnerReferences: ownerRefs(),
623+
Labels: map[string]string{
624+
clusterv1.ClusterNameLabel: clusterName,
625+
},
600626
},
601627
Status: asoresourcesv1.ResourceGroup_STATUS{
602628
Conditions: []conditions.Condition{
@@ -637,6 +663,9 @@ func TestCreateOrUpdateResource(t *testing.T) {
637663
ObjectMeta: metav1.ObjectMeta{
638664
Name: "name",
639665
Namespace: "namespace",
666+
Labels: map[string]string{
667+
clusterv1.ClusterNameLabel: clusterName,
668+
},
640669
},
641670
Status: asoresourcesv1.ResourceGroup_STATUS{
642671
Conditions: []conditions.Condition{
@@ -681,6 +710,9 @@ func TestCreateOrUpdateResource(t *testing.T) {
681710
Name: "name",
682711
Namespace: "namespace",
683712
OwnerReferences: ownerRefs(),
713+
Labels: map[string]string{
714+
clusterv1.ClusterNameLabel: clusterName,
715+
},
684716
Annotations: map[string]string{
685717
asoannotations.ReconcilePolicy: string(asoannotations.ReconcilePolicyManage),
686718
asoannotations.PerResourceSecret: "cluster-aso-secret",
@@ -737,6 +769,9 @@ func TestCreateOrUpdateResource(t *testing.T) {
737769
Name: "name",
738770
Namespace: "namespace",
739771
OwnerReferences: ownerRefs(),
772+
Labels: map[string]string{
773+
clusterv1.ClusterNameLabel: clusterName,
774+
},
740775
},
741776
Status: asoresourcesv1.ResourceGroup_STATUS{
742777
Conditions: []conditions.Condition{
@@ -792,6 +827,9 @@ func TestCreateOrUpdateResource(t *testing.T) {
792827
Name: "name",
793828
Namespace: "namespace",
794829
OwnerReferences: ownerRefs(),
830+
Labels: map[string]string{
831+
clusterv1.ClusterNameLabel: clusterName,
832+
},
795833
Annotations: map[string]string{
796834
asoannotations.ReconcilePolicy: string(asoannotations.ReconcilePolicyManage),
797835
},
@@ -848,6 +886,9 @@ func TestCreateOrUpdateResource(t *testing.T) {
848886
Name: "name",
849887
Namespace: "namespace",
850888
OwnerReferences: ownerRefs(),
889+
Labels: map[string]string{
890+
clusterv1.ClusterNameLabel: clusterName,
891+
},
851892
Annotations: map[string]string{
852893
asoannotations.ReconcilePolicy: string(asoannotations.ReconcilePolicyManage),
853894
tagsLastAppliedAnnotation: "{",
@@ -896,6 +937,9 @@ func TestCreateOrUpdateResource(t *testing.T) {
896937
Name: "name",
897938
Namespace: "namespace",
898939
OwnerReferences: ownerRefs(),
940+
Labels: map[string]string{
941+
clusterv1.ClusterNameLabel: clusterName,
942+
},
899943
Annotations: map[string]string{
900944
prePauseReconcilePolicyAnnotation: string(asoannotations.ReconcilePolicyManage),
901945
asoannotations.ReconcilePolicy: string(asoannotations.ReconcilePolicySkip),
@@ -1015,6 +1059,9 @@ func TestCreateOrUpdateResource(t *testing.T) {
10151059
Name: "name",
10161060
Namespace: "namespace",
10171061
OwnerReferences: ownerRefs(),
1062+
Labels: map[string]string{
1063+
clusterv1.ClusterNameLabel: clusterName,
1064+
},
10181065
Annotations: map[string]string{
10191066
asoannotations.ReconcilePolicy: string(asoannotations.ReconcilePolicyManage),
10201067
},

config/aso/kustomization.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,18 @@ resources:
66
- crds.yaml
77
- settings.yaml
88

9+
patchesStrategicMerge:
10+
- patches/visualizer_label_in_bastionhosts.yaml
11+
- patches/visualizer_label_in_extensions.yaml
12+
- patches/visualizer_label_in_fleetmembers.yaml
13+
- patches/visualizer_label_in_managedclusteragentpools.yaml
14+
- patches/visualizer_label_in_managed_clusters.yaml
15+
- patches/visualizer_label_in_natgateways.yaml
16+
- patches/visualizer_label_in_privateendpoints.yaml
17+
- patches/visualizer_label_in_resourcegroups.yaml
18+
- patches/visualizer_label_in_subnets.yaml
19+
- patches/visualizer_label_in_virtualnetworks.yaml
20+
921
patches:
1022
- patch: |- # default kustomization includes a namespace already
1123
$patch: delete
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
apiVersion: apiextensions.k8s.io/v1
2+
kind: CustomResourceDefinition
3+
metadata:
4+
labels:
5+
visualizer.cluster.x-k8s.io: ""
6+
visualizer.cluster.x-k8s.io/provider-type: "infrastructure"
7+
name: bastionhosts.network.azure.com
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
apiVersion: apiextensions.k8s.io/v1
2+
kind: CustomResourceDefinition
3+
metadata:
4+
labels:
5+
visualizer.cluster.x-k8s.io: ""
6+
visualizer.cluster.x-k8s.io/provider-type: "infrastructure"
7+
name: extensions.kubernetesconfiguration.azure.com
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
apiVersion: apiextensions.k8s.io/v1
2+
kind: CustomResourceDefinition
3+
metadata:
4+
labels:
5+
visualizer.cluster.x-k8s.io: ""
6+
visualizer.cluster.x-k8s.io/provider-type: "infrastructure"
7+
name: fleetsmembers.containerservice.azure.com
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
apiVersion: apiextensions.k8s.io/v1
2+
kind: CustomResourceDefinition
3+
metadata:
4+
labels:
5+
visualizer.cluster.x-k8s.io: ""
6+
visualizer.cluster.x-k8s.io/provider-type: "infrastructure"
7+
name: managedclusters.containerservice.azure.com
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
apiVersion: apiextensions.k8s.io/v1
2+
kind: CustomResourceDefinition
3+
metadata:
4+
labels:
5+
visualizer.cluster.x-k8s.io: ""
6+
visualizer.cluster.x-k8s.io/provider-type: "infrastructure"
7+
name: managedclustersagentpools.containerservice.azure.com
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
apiVersion: apiextensions.k8s.io/v1
2+
kind: CustomResourceDefinition
3+
metadata:
4+
labels:
5+
visualizer.cluster.x-k8s.io: ""
6+
visualizer.cluster.x-k8s.io/provider-type: "infrastructure"
7+
name: natgateways.network.azure.com
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
apiVersion: apiextensions.k8s.io/v1
2+
kind: CustomResourceDefinition
3+
metadata:
4+
labels:
5+
visualizer.cluster.x-k8s.io: ""
6+
visualizer.cluster.x-k8s.io/provider-type: "infrastructure"
7+
name: privateendpoints.network.azure.com

0 commit comments

Comments
 (0)