From d84fd37ef073c6aa81b8074c1331aa36fe767f77 Mon Sep 17 00:00:00 2001 From: Akhilesh Verma Date: Thu, 15 Dec 2022 19:58:26 +0530 Subject: [PATCH 1/4] add support for dns resource group --- Makefile | 3 ++- api/v1beta1/types_class.go | 3 +++ azure/scope/cluster.go | 3 +++ azure/services/privatedns/link_spec.go | 11 +++++------ azure/services/privatedns/zone_spec.go | 2 +- config/default/manager_image_patch.yaml | 2 +- 6 files changed, 15 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index f9f913186dc..e829a9e0ad3 100644 --- a/Makefile +++ b/Makefile @@ -128,7 +128,8 @@ IMAGE_NAME ?= cluster-api-azure-controller CONTROLLER_IMG ?= $(REGISTRY)/$(IMAGE_NAME) TAG ?= spectro-v1.3.2-$(shell date +%Y%m%d) ARCH ?= $(GOARCH) -ALL_ARCH = amd64 arm arm64 ppc64le s390x +ALL_ARCH = amd64 + #arm arm64 ppc64le s390x # Allow overriding manifest generation destination directory MANIFEST_ROOT ?= config diff --git a/api/v1beta1/types_class.go b/api/v1beta1/types_class.go index 26675a02d74..bd285c9fc52 100644 --- a/api/v1beta1/types_class.go +++ b/api/v1beta1/types_class.go @@ -57,6 +57,9 @@ type NetworkClassSpec struct { // PrivateDNSZoneName defines the zone name for the Azure Private DNS. // +optional PrivateDNSZoneName string `json:"privateDNSZoneName,omitempty"` + + // +optional + PrivateDNSZoneResourceGroup string `json:"privateDNSZoneResourceGroup,omitempty"` } // VnetClassSpec defines the VnetSpec properties that may be shared across several Azure clusters. diff --git a/azure/scope/cluster.go b/azure/scope/cluster.go index 3ba3d131bc7..169382057bb 100644 --- a/azure/scope/cluster.go +++ b/azure/scope/cluster.go @@ -668,6 +668,9 @@ func (s *ClusterScope) OutboundPoolName(loadBalancerName string) string { // ResourceGroup returns the cluster resource group. func (s *ClusterScope) ResourceGroup() string { + if len(s.AzureCluster.Spec.NetworkSpec.PrivateDNSZoneResourceGroup) > 0 { + return s.AzureCluster.Spec.NetworkSpec.PrivateDNSZoneResourceGroup + } return s.AzureCluster.Spec.ResourceGroup } diff --git a/azure/services/privatedns/link_spec.go b/azure/services/privatedns/link_spec.go index 36047803bd7..e3b622d0b1d 100644 --- a/azure/services/privatedns/link_spec.go +++ b/azure/services/privatedns/link_spec.go @@ -22,7 +22,6 @@ import ( "github.com/pkg/errors" infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" - "sigs.k8s.io/cluster-api-provider-azure/azure/converters" ) // LinkSpec defines the specification for a virtual network link in a private DNS zone. @@ -70,10 +69,10 @@ func (s LinkSpec) Parameters(existing interface{}) (params interface{}, err erro RegistrationEnabled: to.BoolPtr(false), }, Location: to.StringPtr(azure.Global), - Tags: converters.TagsToMap(infrav1.Build(infrav1.BuildParams{ - ClusterName: s.ClusterName, - Lifecycle: infrav1.ResourceLifecycleOwned, - Additional: s.AdditionalTags, - })), + //Tags: converters.TagsToMap(infrav1.Build(infrav1.BuildParams{ + // ClusterName: s.ClusterName, + // Lifecycle: infrav1.ResourceLifecycleOwned, + // Additional: s.AdditionalTags, + //})), }, nil } diff --git a/azure/services/privatedns/zone_spec.go b/azure/services/privatedns/zone_spec.go index 30cfd59d37f..41f52f25edd 100644 --- a/azure/services/privatedns/zone_spec.go +++ b/azure/services/privatedns/zone_spec.go @@ -63,7 +63,7 @@ func (s ZoneSpec) Parameters(existing interface{}) (params interface{}, err erro Tags: converters.TagsToMap(infrav1.Build(infrav1.BuildParams{ ClusterName: s.ClusterName, Lifecycle: infrav1.ResourceLifecycleOwned, - Additional: s.AdditionalTags, + //Additional: s.AdditionalTags, })), }, nil } diff --git a/config/default/manager_image_patch.yaml b/config/default/manager_image_patch.yaml index 51d5d8453d1..d9b75f9645c 100644 --- a/config/default/manager_image_patch.yaml +++ b/config/default/manager_image_patch.yaml @@ -8,5 +8,5 @@ spec: spec: containers: # Change the value of image field below to your controller image URL - - image: gcr.io/spectro-dev-public/snehal/cluster-api-azure/cluster-api-azure-controller:spectro-v1.3.2-20221125 + - image: gcr.io/spectro-dev-public/snehal/cluster-api-azure/cluster-api-azure-controller:spectro-v1.3.2-20221215 name: manager From 45a727939fea89ced6aefdf9084ed2d5f9b02995 Mon Sep 17 00:00:00 2001 From: Akhilesh Verma Date: Fri, 16 Dec 2022 18:18:17 +0530 Subject: [PATCH 2/4] private dns support --- azure/scope/cluster.go | 13 +++++++++---- ...ructure.cluster.x-k8s.io_azureclusters.yaml | 2 ++ ...cluster.x-k8s.io_azureclustertemplates.yaml | 2 ++ config/default/manager_image_patch.yaml | 2 +- spectro/generated/core-base.yaml | 2 +- spectro/generated/core-global.yaml | 18 +++++++++++++++++- 6 files changed, 32 insertions(+), 7 deletions(-) diff --git a/azure/scope/cluster.go b/azure/scope/cluster.go index 169382057bb..6ac43a7e957 100644 --- a/azure/scope/cluster.go +++ b/azure/scope/cluster.go @@ -409,7 +409,7 @@ func (s *ClusterScope) PrivateDNSSpec() (zoneSpec azure.ResourceSpecGetter, link if s.IsAPIServerPrivate() { zone := privatedns.ZoneSpec{ Name: s.GetPrivateDNSZoneName(), - ResourceGroup: s.ResourceGroup(), + ResourceGroup: s.PrivateDNSZoneResourceGroup(), ClusterName: s.ClusterName(), AdditionalTags: s.AdditionalTags(), } @@ -421,7 +421,7 @@ func (s *ClusterScope) PrivateDNSSpec() (zoneSpec azure.ResourceSpecGetter, link SubscriptionID: s.SubscriptionID(), VNetResourceGroup: s.Vnet().ResourceGroup, VNetName: s.Vnet().Name, - ResourceGroup: s.ResourceGroup(), + ResourceGroup: s.PrivateDNSZoneResourceGroup(), ClusterName: s.ClusterName(), AdditionalTags: s.AdditionalTags(), } @@ -432,7 +432,7 @@ func (s *ClusterScope) PrivateDNSSpec() (zoneSpec azure.ResourceSpecGetter, link SubscriptionID: s.SubscriptionID(), VNetResourceGroup: peering.ResourceGroup, VNetName: peering.RemoteVnetName, - ResourceGroup: s.ResourceGroup(), + ResourceGroup: s.PrivateDNSZoneResourceGroup(), ClusterName: s.ClusterName(), AdditionalTags: s.AdditionalTags(), } @@ -445,7 +445,7 @@ func (s *ClusterScope) PrivateDNSSpec() (zoneSpec azure.ResourceSpecGetter, link IP: s.APIServerPrivateIP(), }, ZoneName: s.GetPrivateDNSZoneName(), - ResourceGroup: s.ResourceGroup(), + ResourceGroup: s.PrivateDNSZoneResourceGroup(), } return zone, links, records @@ -668,6 +668,11 @@ func (s *ClusterScope) OutboundPoolName(loadBalancerName string) string { // ResourceGroup returns the cluster resource group. func (s *ClusterScope) ResourceGroup() string { + return s.AzureCluster.Spec.ResourceGroup +} + +// ResourceGroup returns the cluster resource group. +func (s *ClusterScope) PrivateDNSZoneResourceGroup() string { if len(s.AzureCluster.Spec.NetworkSpec.PrivateDNSZoneResourceGroup) > 0 { return s.AzureCluster.Spec.NetworkSpec.PrivateDNSZoneResourceGroup } diff --git a/config/crd/bases/infrastructure.cluster.x-k8s.io_azureclusters.yaml b/config/crd/bases/infrastructure.cluster.x-k8s.io_azureclusters.yaml index e56393c5d16..997282d5760 100644 --- a/config/crd/bases/infrastructure.cluster.x-k8s.io_azureclusters.yaml +++ b/config/crd/bases/infrastructure.cluster.x-k8s.io_azureclusters.yaml @@ -1805,6 +1805,8 @@ spec: description: PrivateDNSZoneName defines the zone name for the Azure Private DNS. type: string + privateDNSZoneResourceGroup: + type: string subnets: description: Subnets is the configuration for the control-plane subnet and the node subnet. diff --git a/config/crd/bases/infrastructure.cluster.x-k8s.io_azureclustertemplates.yaml b/config/crd/bases/infrastructure.cluster.x-k8s.io_azureclustertemplates.yaml index 59e6c1da99a..e2a8682a8cf 100644 --- a/config/crd/bases/infrastructure.cluster.x-k8s.io_azureclustertemplates.yaml +++ b/config/crd/bases/infrastructure.cluster.x-k8s.io_azureclustertemplates.yaml @@ -389,6 +389,8 @@ spec: description: PrivateDNSZoneName defines the zone name for the Azure Private DNS. type: string + privateDNSZoneResourceGroup: + type: string subnets: description: Subnets is the configuration for the control-plane subnet and the node subnet. diff --git a/config/default/manager_image_patch.yaml b/config/default/manager_image_patch.yaml index d9b75f9645c..599b3e58176 100644 --- a/config/default/manager_image_patch.yaml +++ b/config/default/manager_image_patch.yaml @@ -8,5 +8,5 @@ spec: spec: containers: # Change the value of image field below to your controller image URL - - image: gcr.io/spectro-dev-public/snehal/cluster-api-azure/cluster-api-azure-controller:spectro-v1.3.2-20221215 + - image: gcr.io/spectro-dev-public/snehal/cluster-api-azure/cluster-api-azure-controller:spectro-v1.3.2-20221216 name: manager diff --git a/spectro/generated/core-base.yaml b/spectro/generated/core-base.yaml index ab8d2dee686..af6b1981a63 100644 --- a/spectro/generated/core-base.yaml +++ b/spectro/generated/core-base.yaml @@ -61,7 +61,7 @@ spec: valueFrom: fieldRef: fieldPath: metadata.namespace - image: gcr.io/spectro-dev-public/snehal/cluster-api-azure/cluster-api-azure-controller:spectro-v1.3.2-20221102 + image: gcr.io/spectro-dev-public/snehal/cluster-api-azure/cluster-api-azure-controller:spectro-v1.3.2-20221215 imagePullPolicy: Always name: manager terminationGracePeriodSeconds: 10 diff --git a/spectro/generated/core-global.yaml b/spectro/generated/core-global.yaml index f5215b48c86..574d85e81cf 100644 --- a/spectro/generated/core-global.yaml +++ b/spectro/generated/core-global.yaml @@ -2218,6 +2218,8 @@ spec: the TCP idle connection. format: int32 type: integer + ipAllocationMethod: + type: string name: type: string sku: @@ -2272,6 +2274,8 @@ spec: the TCP idle connection. format: int32 type: integer + ipAllocationMethod: + type: string name: type: string sku: @@ -2324,6 +2328,8 @@ spec: the TCP idle connection. format: int32 type: integer + ipAllocationMethod: + type: string name: type: string sku: @@ -2337,6 +2343,8 @@ spec: description: PrivateDNSZoneName defines the zone name for the Azure Private DNS. type: string + privateDNSZoneResourceGroup: + type: string subnets: description: Subnets is the configuration for the control-plane subnet and the node subnet. @@ -3033,6 +3041,8 @@ spec: for the TCP idle connection. format: int32 type: integer + ipAllocationMethod: + type: string sku: description: SKU defines an Azure load balancer SKU. type: string @@ -3052,6 +3062,8 @@ spec: for the TCP idle connection. format: int32 type: integer + ipAllocationMethod: + type: string sku: description: SKU defines an Azure load balancer SKU. type: string @@ -3069,6 +3081,8 @@ spec: for the TCP idle connection. format: int32 type: integer + ipAllocationMethod: + type: string sku: description: SKU defines an Azure load balancer SKU. type: string @@ -3081,6 +3095,8 @@ spec: description: PrivateDNSZoneName defines the zone name for the Azure Private DNS. type: string + privateDNSZoneResourceGroup: + type: string subnets: description: Subnets is the configuration for the control-plane subnet and the node subnet. @@ -10656,7 +10672,7 @@ spec: valueFrom: fieldRef: fieldPath: metadata.namespace - image: gcr.io/spectro-dev-public/snehal/cluster-api-azure/cluster-api-azure-controller:spectro-v1.3.2-20221102 + image: gcr.io/spectro-dev-public/snehal/cluster-api-azure/cluster-api-azure-controller:spectro-v1.3.2-20221215 imagePullPolicy: Always livenessProbe: httpGet: From bdcf9275bfff5a926564578f6cba01ac0b9b6fb0 Mon Sep 17 00:00:00 2001 From: Akhilesh Verma Date: Fri, 16 Dec 2022 18:22:02 +0530 Subject: [PATCH 3/4] uncomment --- azure/services/privatedns/link_spec.go | 11 ++++++----- azure/services/privatedns/zone_spec.go | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/azure/services/privatedns/link_spec.go b/azure/services/privatedns/link_spec.go index e3b622d0b1d..36047803bd7 100644 --- a/azure/services/privatedns/link_spec.go +++ b/azure/services/privatedns/link_spec.go @@ -22,6 +22,7 @@ import ( "github.com/pkg/errors" infrav1 "sigs.k8s.io/cluster-api-provider-azure/api/v1beta1" "sigs.k8s.io/cluster-api-provider-azure/azure" + "sigs.k8s.io/cluster-api-provider-azure/azure/converters" ) // LinkSpec defines the specification for a virtual network link in a private DNS zone. @@ -69,10 +70,10 @@ func (s LinkSpec) Parameters(existing interface{}) (params interface{}, err erro RegistrationEnabled: to.BoolPtr(false), }, Location: to.StringPtr(azure.Global), - //Tags: converters.TagsToMap(infrav1.Build(infrav1.BuildParams{ - // ClusterName: s.ClusterName, - // Lifecycle: infrav1.ResourceLifecycleOwned, - // Additional: s.AdditionalTags, - //})), + Tags: converters.TagsToMap(infrav1.Build(infrav1.BuildParams{ + ClusterName: s.ClusterName, + Lifecycle: infrav1.ResourceLifecycleOwned, + Additional: s.AdditionalTags, + })), }, nil } diff --git a/azure/services/privatedns/zone_spec.go b/azure/services/privatedns/zone_spec.go index 41f52f25edd..30cfd59d37f 100644 --- a/azure/services/privatedns/zone_spec.go +++ b/azure/services/privatedns/zone_spec.go @@ -63,7 +63,7 @@ func (s ZoneSpec) Parameters(existing interface{}) (params interface{}, err erro Tags: converters.TagsToMap(infrav1.Build(infrav1.BuildParams{ ClusterName: s.ClusterName, Lifecycle: infrav1.ResourceLifecycleOwned, - //Additional: s.AdditionalTags, + Additional: s.AdditionalTags, })), }, nil } From 63115c512e074ca68cc11ce475a38c3db5b05f83 Mon Sep 17 00:00:00 2001 From: Akhilesh Verma Date: Fri, 16 Dec 2022 18:23:38 +0530 Subject: [PATCH 4/4] more --- Makefile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Makefile b/Makefile index e829a9e0ad3..f9f913186dc 100644 --- a/Makefile +++ b/Makefile @@ -128,8 +128,7 @@ IMAGE_NAME ?= cluster-api-azure-controller CONTROLLER_IMG ?= $(REGISTRY)/$(IMAGE_NAME) TAG ?= spectro-v1.3.2-$(shell date +%Y%m%d) ARCH ?= $(GOARCH) -ALL_ARCH = amd64 - #arm arm64 ppc64le s390x +ALL_ARCH = amd64 arm arm64 ppc64le s390x # Allow overriding manifest generation destination directory MANIFEST_ROOT ?= config