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

[draft]Start controller #221

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion api/v1alpha1/trafficmanagerbackend_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const (
// +kubebuilder:resource:scope=Namespaced,categories={fleet-networking},shortName=tmb
// +kubebuilder:subresource:status
// +kubebuilder:printcolumn:JSONPath=`.spec.profile.name`,name="Profile",type=string
// +kubebuilder:printcolumn:JSONPath=`.spec.endpointRef.name`,name="Backend",type=string
// +kubebuilder:printcolumn:JSONPath=`.spec.backend.name`,name="Backend",type=string
// +kubebuilder:printcolumn:JSONPath=`.status.conditions[?(@.type=='Accepted')].status`,name="Is-Accepted",type=string
// +kubebuilder:printcolumn:JSONPath=`.metadata.creationTimestamp`,name="Age",type=date

Expand Down
2 changes: 1 addition & 1 deletion api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions azure_config-new.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
azureCloudConfig:
cloud: "AzurePublicCloud"
subscriptionId: "c4528d9e-c99a-48bb-b12d-fde2176a43b8"
useManagedIdentityExtension: true
userAssignedIdentityID: "7099e851-09b2-4214-ba5f-d4d7de33b8a3"
Copy link
Contributor

Choose a reason for hiding this comment

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

let's not leave the clientID in PR.

resourceGroup: "zhiyinglin-fleet-networking-e2e-atm-1"
location: "westcentralus"
vnetName: "my-vnet"
Copy link
Contributor

Choose a reason for hiding this comment

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

Since fleet version has been updated, we do not need this vnetName anymore.

9 changes: 9 additions & 0 deletions azure_config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"cloud": "AzurePublicCloud",
"subscriptionId": "c4528d9e-c99a-48bb-b12d-fde2176a43b8",
"useManagedIdentityExtension": true,
"userAssignedIdentityID": "7099e851-09b2-4214-ba5f-d4d7de33b8a3",
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto

"resourceGroup": "zhiyinglin-fleet-networking-e2e-atm-1",
"location": "westcentralus",
"vnetName": "my-vnet",
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto

}
52 changes: 52 additions & 0 deletions charts/hub-net-controller-manager/templates/rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,58 @@ rules:
- get
- list
- watch
- apiGroups:
- networking.fleet.azure.com
resources:
- trafficmanagerbackends
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- networking.fleet.azure.com
resources:
- trafficmanagerbackends/finalizers
verbs:
- update
- apiGroups:
- networking.fleet.azure.com
resources:
- trafficmanagerbackends/status
verbs:
- get
- patch
- update
- apiGroups:
- networking.fleet.azure.com
resources:
- trafficmanagerprofiles
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- networking.fleet.azure.com
resources:
- trafficmanagerprofiles/finalizers
verbs:
- update
- apiGroups:
- networking.fleet.azure.com
resources:
- trafficmanagerprofiles/status
verbs:
- get
- patch
- update
---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
Expand Down
24 changes: 22 additions & 2 deletions cmd/hub-net-controller-manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ package main
import (
"flag"
"fmt"
"go.goms.io/fleet-networking/pkg/controllers/hub/trafficmanagerbackend"
"os"
"time"

Expand Down Expand Up @@ -42,6 +43,7 @@ import (
"go.goms.io/fleet-networking/pkg/controllers/hub/internalserviceimport"
"go.goms.io/fleet-networking/pkg/controllers/hub/membercluster"
"go.goms.io/fleet-networking/pkg/controllers/hub/serviceimport"
"go.goms.io/fleet-networking/pkg/controllers/hub/trafficmanagerprofile"
)

var (
Expand Down Expand Up @@ -200,13 +202,31 @@ func main() {
cloudConfig.SetUserAgent("fleet-hub-net-controller-manager")
klog.V(1).InfoS("Cloud config loaded", "cloudConfig", cloudConfig)

_, _, err = initAzureTrafficManagerClients(cloudConfig) // profilesClient, endpointsClient, err
profilesClient, endpointsClient, err := initAzureTrafficManagerClients(cloudConfig) // profilesClient, endpointsClient, err
if err != nil {
klog.ErrorS(err, "Unable to create Azure Traffic Manager clients")
exitWithErrorFunc()
}
klog.V(1).InfoS("Start to setup TrafficManagerProfile controller")
if err := (&trafficmanagerprofile.Reconciler{
Client: mgr.GetClient(),
ProfilesClient: profilesClient,
ResourceGroupName: cloudConfig.ResourceGroup,
}).SetupWithManager(mgr); err != nil {
klog.ErrorS(err, "Unable to create TrafficManagerProfile controller")
exitWithErrorFunc()
}

// TODO: start the traffic manager controllers
klog.V(1).InfoS("Start to setup TrafficManagerBackend controller")
if err := (&trafficmanagerbackend.Reconciler{
Client: mgr.GetClient(),
ProfilesClient: profilesClient,
EndpointsClient: endpointsClient,
ResourceGroupName: cloudConfig.ResourceGroup,
}).SetupWithManager(ctx, mgr); err != nil {
klog.ErrorS(err, "Unable to create TrafficManagerProfile controller")
exitWithErrorFunc()
}
}

klog.V(1).InfoS("Starting ServiceExportImport controller manager")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ spec:
- jsonPath: .spec.profile.name
name: Profile
type: string
- jsonPath: .spec.endpointRef.name
- jsonPath: .spec.backend.name
name: Backend
type: string
- jsonPath: .status.conditions[?(@.type=='Accepted')].status
Expand Down
3 changes: 3 additions & 0 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ rules:
- multiclusterservices
- serviceexports
- serviceimports
- trafficmanagerbackends
- trafficmanagerprofiles
verbs:
- create
Expand All @@ -86,6 +87,7 @@ rules:
- multiclusterservices/status
- serviceexports/status
- serviceimports/status
- trafficmanagerbackends/status
- trafficmanagerprofiles/status
verbs:
- get
Expand All @@ -96,6 +98,7 @@ rules:
resources:
- multiclusterservices/finalizers
- serviceimports/finalizers
- trafficmanagerbackends/finalizers
- trafficmanagerprofiles/finalizers
verbs:
- get
Expand Down
8 changes: 8 additions & 0 deletions hub_azure_config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
azureCloudConfig:
cloud: "AzurePublicCloud"
subscriptionId: "c4528d9e-c99a-48bb-b12d-fde2176a43b8"
useManagedIdentityExtension: true
userAssignedIdentityID: "aab3e00d-6427-48b0-af5d-ddffb2a284e0"
resourceGroup: "zhiyinglin-fleet-networking-e2e-atm-1"
location: "westcentralus"
vnetName: "my-vnet"
8 changes: 8 additions & 0 deletions member_1_azure_config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
azureCloudConfig:
cloud: "AzurePublicCloud"
subscriptionId: "c4528d9e-c99a-48bb-b12d-fde2176a43b8"
useManagedIdentityExtension: true
userAssignedIdentityID: "f882963a-abce-416c-9e44-172f678475f9"
resourceGroup: "MC_zhiyinglin-fleet-networking-e2e-atm-1_member-1_westcentralus"
location: "westcentralus"
vnetName: "my-vnet"
8 changes: 8 additions & 0 deletions member_2_azure_config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
azureCloudConfig:
cloud: "AzurePublicCloud"
subscriptionId: "c4528d9e-c99a-48bb-b12d-fde2176a43b8"
useManagedIdentityExtension: true
userAssignedIdentityID: "30d298c0-bf15-402a-b072-8fef4b3653ef"
resourceGroup: "MC_zhiyinglin-fleet-networking-e2e-atm-1_member-2_westcentralus"
location: "westcentralus"
vnetName: "my-vnet"
Loading