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

🌱 Make in memory runtime and server accessible from outside #9986

Merged
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
20 changes: 10 additions & 10 deletions test/infrastructure/inmemory/controllers/alias.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,19 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/controller"

"sigs.k8s.io/cluster-api/test/infrastructure/inmemory/internal/cloud"
inmemorycontrollers "sigs.k8s.io/cluster-api/test/infrastructure/inmemory/internal/controllers"
"sigs.k8s.io/cluster-api/test/infrastructure/inmemory/internal/server"
inmemoryruntime "sigs.k8s.io/cluster-api/test/infrastructure/inmemory/pkg/runtime"
inmemoryserver "sigs.k8s.io/cluster-api/test/infrastructure/inmemory/pkg/server"
)

// Following types provides access to reconcilers implemented in internal/controllers, thus
// allowing users to provide a single binary "batteries included" with Cluster API and providers of choice.

// InMemoryClusterReconciler reconciles a InMemoryCluster object.
type InMemoryClusterReconciler struct {
Client client.Client
CloudManager cloud.Manager
APIServerMux *server.WorkloadClustersMux // TODO: find a way to use an interface here
Client client.Client
InMemoryManager inmemoryruntime.Manager
APIServerMux *inmemoryserver.WorkloadClustersMux // TODO: find a way to use an interface here

// WatchFilterValue is the label value used to filter events prior to reconciliation.
WatchFilterValue string
Expand All @@ -46,17 +46,17 @@ type InMemoryClusterReconciler struct {
func (r *InMemoryClusterReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager, options controller.Options) error {
return (&inmemorycontrollers.InMemoryClusterReconciler{
Client: r.Client,
CloudManager: r.CloudManager,
InMemoryManager: r.InMemoryManager,
APIServerMux: r.APIServerMux,
WatchFilterValue: r.WatchFilterValue,
}).SetupWithManager(ctx, mgr, options)
}

// InMemoryMachineReconciler reconciles a InMemoryMachine object.
type InMemoryMachineReconciler struct {
Client client.Client
CloudManager cloud.Manager
APIServerMux *server.WorkloadClustersMux // TODO: find a way to use an interface here
Client client.Client
InMemoryManager inmemoryruntime.Manager
APIServerMux *inmemoryserver.WorkloadClustersMux // TODO: find a way to use an interface here

// WatchFilterValue is the label value used to filter events prior to reconciliation.
WatchFilterValue string
Expand All @@ -66,7 +66,7 @@ type InMemoryMachineReconciler struct {
func (r *InMemoryMachineReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager, options controller.Options) error {
return (&inmemorycontrollers.InMemoryMachineReconciler{
Client: r.Client,
CloudManager: r.CloudManager,
InMemoryManager: r.InMemoryManager,
APIServerMux: r.APIServerMux,
WatchFilterValue: r.WatchFilterValue,
}).SetupWithManager(ctx, mgr, options)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

// Package v1alpha1 contains API Schema definitions for the cloud v1alpha1 API group
// Package v1alpha1 contains API Schema definitions for the inmemory v1alpha1 API group
// +kubebuilder:object:generate=true
// +groupName=virtual.cluster.x-k8s.io
package v1alpha1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ type CloudMachineStatus struct {

// +kubebuilder:object:root=true

// CloudMachine represents a machine in the cloud.
// CloudMachine represents a machine in memory.
type CloudMachine struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ import (

clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
infrav1 "sigs.k8s.io/cluster-api/test/infrastructure/inmemory/api/v1alpha1"
"sigs.k8s.io/cluster-api/test/infrastructure/inmemory/internal/cloud"
"sigs.k8s.io/cluster-api/test/infrastructure/inmemory/internal/server"
inmemoryruntime "sigs.k8s.io/cluster-api/test/infrastructure/inmemory/pkg/runtime"
inmemoryserver "sigs.k8s.io/cluster-api/test/infrastructure/inmemory/pkg/server"
"sigs.k8s.io/cluster-api/util"
"sigs.k8s.io/cluster-api/util/patch"
"sigs.k8s.io/cluster-api/util/predicates"
Expand All @@ -44,8 +44,8 @@ import (
// InMemoryClusterReconciler reconciles a InMemoryCluster object.
type InMemoryClusterReconciler struct {
client.Client
CloudManager cloud.Manager
APIServerMux *server.WorkloadClustersMux
InMemoryManager inmemoryruntime.Manager
APIServerMux *inmemoryserver.WorkloadClustersMux

// WatchFilterValue is the label value used to filter events prior to reconciliation.
WatchFilterValue string
Expand Down Expand Up @@ -158,11 +158,11 @@ func (r *InMemoryClusterReconciler) reconcileNormal(_ context.Context, cluster *
// Store the resource group used by this inMemoryCluster.
inMemoryCluster.Annotations[infrav1.ResourceGroupAnnotationName] = resourceGroup

// Create a resource group for all the cloud resources belonging the workload cluster;
// Create a resource group for all the in memory resources belonging the workload cluster;
// if the resource group already exists, the operation is a no-op.
// NOTE: We are storing in this resource group both the cloud resources (e.g. VM) as
// NOTE: We are storing in this resource group both the in memory resources (e.g. VM) as
// well as Kubernetes resources that are expected to exist on the workload cluster (e.g Nodes).
r.CloudManager.AddResourceGroup(resourceGroup)
r.InMemoryManager.AddResourceGroup(resourceGroup)

// Initialize a listener for the workload cluster; if the listener has been already initialized
// the operation is a no-op.
Expand Down Expand Up @@ -190,8 +190,8 @@ func (r *InMemoryClusterReconciler) reconcileDelete(_ context.Context, cluster *
// Compute the resource group unique name.
resourceGroup := klog.KObj(cluster).String()

// Delete the resource group hosting all the cloud resources belonging the workload cluster;
r.CloudManager.DeleteResourceGroup(resourceGroup)
// Delete the resource group hosting all the in memory resources belonging the workload cluster;
r.InMemoryManager.DeleteResourceGroup(resourceGroup)

// Delete the listener for the workload cluster;
if err := r.APIServerMux.DeleteWorkloadClusterListener(resourceGroup); err != nil {
Expand Down
Loading