Skip to content

Commit faef1b0

Browse files
authored
Merge pull request kubernetes-sigs#9986 from fabriziopandini/export-inmemory-runtime-server
🌱 Make in memory runtime and server accessible from outside
2 parents 97c9720 + 025014f commit faef1b0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+241
-244
lines changed

test/infrastructure/inmemory/controllers/alias.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,19 @@ import (
2424
"sigs.k8s.io/controller-runtime/pkg/client"
2525
"sigs.k8s.io/controller-runtime/pkg/controller"
2626

27-
"sigs.k8s.io/cluster-api/test/infrastructure/inmemory/internal/cloud"
2827
inmemorycontrollers "sigs.k8s.io/cluster-api/test/infrastructure/inmemory/internal/controllers"
29-
"sigs.k8s.io/cluster-api/test/infrastructure/inmemory/internal/server"
28+
inmemoryruntime "sigs.k8s.io/cluster-api/test/infrastructure/inmemory/pkg/runtime"
29+
inmemoryserver "sigs.k8s.io/cluster-api/test/infrastructure/inmemory/pkg/server"
3030
)
3131

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

3535
// InMemoryClusterReconciler reconciles a InMemoryCluster object.
3636
type InMemoryClusterReconciler struct {
37-
Client client.Client
38-
CloudManager cloud.Manager
39-
APIServerMux *server.WorkloadClustersMux // TODO: find a way to use an interface here
37+
Client client.Client
38+
InMemoryManager inmemoryruntime.Manager
39+
APIServerMux *inmemoryserver.WorkloadClustersMux // TODO: find a way to use an interface here
4040

4141
// WatchFilterValue is the label value used to filter events prior to reconciliation.
4242
WatchFilterValue string
@@ -46,17 +46,17 @@ type InMemoryClusterReconciler struct {
4646
func (r *InMemoryClusterReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager, options controller.Options) error {
4747
return (&inmemorycontrollers.InMemoryClusterReconciler{
4848
Client: r.Client,
49-
CloudManager: r.CloudManager,
49+
InMemoryManager: r.InMemoryManager,
5050
APIServerMux: r.APIServerMux,
5151
WatchFilterValue: r.WatchFilterValue,
5252
}).SetupWithManager(ctx, mgr, options)
5353
}
5454

5555
// InMemoryMachineReconciler reconciles a InMemoryMachine object.
5656
type InMemoryMachineReconciler struct {
57-
Client client.Client
58-
CloudManager cloud.Manager
59-
APIServerMux *server.WorkloadClustersMux // TODO: find a way to use an interface here
57+
Client client.Client
58+
InMemoryManager inmemoryruntime.Manager
59+
APIServerMux *inmemoryserver.WorkloadClustersMux // TODO: find a way to use an interface here
6060

6161
// WatchFilterValue is the label value used to filter events prior to reconciliation.
6262
WatchFilterValue string
@@ -66,7 +66,7 @@ type InMemoryMachineReconciler struct {
6666
func (r *InMemoryMachineReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager, options controller.Options) error {
6767
return (&inmemorycontrollers.InMemoryMachineReconciler{
6868
Client: r.Client,
69-
CloudManager: r.CloudManager,
69+
InMemoryManager: r.InMemoryManager,
7070
APIServerMux: r.APIServerMux,
7171
WatchFilterValue: r.WatchFilterValue,
7272
}).SetupWithManager(ctx, mgr, options)

test/infrastructure/inmemory/internal/cloud/api/v1alpha1/groupversion_info.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
// Package v1alpha1 contains API Schema definitions for the cloud v1alpha1 API group
17+
// Package v1alpha1 contains API Schema definitions for the inmemory v1alpha1 API group
1818
// +kubebuilder:object:generate=true
1919
// +groupName=virtual.cluster.x-k8s.io
2020
package v1alpha1

test/infrastructure/inmemory/internal/cloud/api/v1alpha1/machine_types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ type CloudMachineStatus struct {
3333

3434
// +kubebuilder:object:root=true
3535

36-
// CloudMachine represents a machine in the cloud.
36+
// CloudMachine represents a machine in memory.
3737
type CloudMachine struct {
3838
metav1.TypeMeta `json:",inline"`
3939
metav1.ObjectMeta `json:"metadata,omitempty"`

test/infrastructure/inmemory/internal/controllers/inmemorycluster_controller.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ import (
3434

3535
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
3636
infrav1 "sigs.k8s.io/cluster-api/test/infrastructure/inmemory/api/v1alpha1"
37-
"sigs.k8s.io/cluster-api/test/infrastructure/inmemory/internal/cloud"
38-
"sigs.k8s.io/cluster-api/test/infrastructure/inmemory/internal/server"
37+
inmemoryruntime "sigs.k8s.io/cluster-api/test/infrastructure/inmemory/pkg/runtime"
38+
inmemoryserver "sigs.k8s.io/cluster-api/test/infrastructure/inmemory/pkg/server"
3939
"sigs.k8s.io/cluster-api/util"
4040
"sigs.k8s.io/cluster-api/util/patch"
4141
"sigs.k8s.io/cluster-api/util/predicates"
@@ -44,8 +44,8 @@ import (
4444
// InMemoryClusterReconciler reconciles a InMemoryCluster object.
4545
type InMemoryClusterReconciler struct {
4646
client.Client
47-
CloudManager cloud.Manager
48-
APIServerMux *server.WorkloadClustersMux
47+
InMemoryManager inmemoryruntime.Manager
48+
APIServerMux *inmemoryserver.WorkloadClustersMux
4949

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

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

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

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

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

0 commit comments

Comments
 (0)