diff --git a/README.md b/README.md index e05d16a4b72b..a8d931ea08ca 100644 --- a/README.md +++ b/README.md @@ -70,5 +70,5 @@ spec: And delete the cluster using: ```bash -$ oc delete --namespace hypershift openshiftclusters/example +$ oc delete --namespace hypershift hostedclusters/example ``` diff --git a/api/v1alpha1/openshiftcluster_types.go b/api/v1alpha1/hostedcluster_types.go similarity index 75% rename from api/v1alpha1/openshiftcluster_types.go rename to api/v1alpha1/hostedcluster_types.go index 242adf048812..8fa90e66d976 100644 --- a/api/v1alpha1/openshiftcluster_types.go +++ b/api/v1alpha1/hostedcluster_types.go @@ -24,8 +24,8 @@ import ( // EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN! // NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized. -// OpenShiftClusterSpec defines the desired state of OpenShiftCluster -type OpenShiftClusterSpec struct { +// HostedClusterSpec defines the desired state of HostedCluster +type HostedClusterSpec struct { // INSERT ADDITIONAL SPEC FIELDS - desired state of cluster // Important: Run "make" to regenerate code after modifying this file @@ -53,8 +53,8 @@ type ReleaseSpec struct { Image string `json:"image"` } -// OpenShiftClusterStatus defines the observed state of OpenShiftCluster -type OpenShiftClusterStatus struct { +// HostedClusterStatus defines the observed state of HostedCluster +type HostedClusterStatus struct { // INSERT ADDITIONAL STATUS FIELD - define observed state of cluster // Important: Run "make" to regenerate code after modifying this file @@ -62,27 +62,27 @@ type OpenShiftClusterStatus struct { } // +kubebuilder:object:root=true -// +kubebuilder:resource:path=openshiftclusters,shortName=oc;ocs,scope=Namespaced +// +kubebuilder:resource:path=hostedclusters,shortName=hc;hcs,scope=Namespaced // +kubebuilder:storageversion // +kubebuilder:subresource:status -// OpenShiftCluster is the Schema for the openshiftclusters API -type OpenShiftCluster struct { +// HostedCluster is the Schema for the hostedclusters API +type HostedCluster struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata,omitempty"` - Spec OpenShiftClusterSpec `json:"spec,omitempty"` - Status OpenShiftClusterStatus `json:"status,omitempty"` + Spec HostedClusterSpec `json:"spec,omitempty"` + Status HostedClusterStatus `json:"status,omitempty"` } // +kubebuilder:object:root=true -// OpenShiftClusterList contains a list of OpenShiftCluster -type OpenShiftClusterList struct { +// HostedClusterList contains a list of HostedCluster +type HostedClusterList struct { metav1.TypeMeta `json:",inline"` metav1.ListMeta `json:"metadata,omitempty"` - Items []OpenShiftCluster `json:"items"` + Items []HostedCluster `json:"items"` } func init() { - SchemeBuilder.Register(&OpenShiftCluster{}, &OpenShiftClusterList{}) + SchemeBuilder.Register(&HostedCluster{}, &HostedClusterList{}) } diff --git a/api/v1alpha1/zz_generated.deepcopy.go b/api/v1alpha1/zz_generated.deepcopy.go index 10dd9af7ffc3..c089b1dfa455 100644 --- a/api/v1alpha1/zz_generated.deepcopy.go +++ b/api/v1alpha1/zz_generated.deepcopy.go @@ -201,6 +201,99 @@ func (in *Filter) DeepCopy() *Filter { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *HostedCluster) DeepCopyInto(out *HostedCluster) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + out.Spec = in.Spec + out.Status = in.Status +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HostedCluster. +func (in *HostedCluster) DeepCopy() *HostedCluster { + if in == nil { + return nil + } + out := new(HostedCluster) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *HostedCluster) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *HostedClusterList) DeepCopyInto(out *HostedClusterList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]HostedCluster, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HostedClusterList. +func (in *HostedClusterList) DeepCopy() *HostedClusterList { + if in == nil { + return nil + } + out := new(HostedClusterList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *HostedClusterList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *HostedClusterSpec) DeepCopyInto(out *HostedClusterSpec) { + *out = *in + out.Release = in.Release + out.PullSecret = in.PullSecret + out.SSHKey = in.SSHKey + out.ProviderCreds = in.ProviderCreds +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HostedClusterSpec. +func (in *HostedClusterSpec) DeepCopy() *HostedClusterSpec { + if in == nil { + return nil + } + out := new(HostedClusterSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *HostedClusterStatus) DeepCopyInto(out *HostedClusterStatus) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HostedClusterStatus. +func (in *HostedClusterStatus) DeepCopy() *HostedClusterStatus { + if in == nil { + return nil + } + out := new(HostedClusterStatus) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *HostedControlPlane) DeepCopyInto(out *HostedControlPlane) { *out = *in @@ -420,99 +513,6 @@ func (in *NodePoolStatus) DeepCopy() *NodePoolStatus { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *OpenShiftCluster) DeepCopyInto(out *OpenShiftCluster) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - out.Spec = in.Spec - out.Status = in.Status -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OpenShiftCluster. -func (in *OpenShiftCluster) DeepCopy() *OpenShiftCluster { - if in == nil { - return nil - } - out := new(OpenShiftCluster) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *OpenShiftCluster) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *OpenShiftClusterList) DeepCopyInto(out *OpenShiftClusterList) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ListMeta.DeepCopyInto(&out.ListMeta) - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]OpenShiftCluster, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OpenShiftClusterList. -func (in *OpenShiftClusterList) DeepCopy() *OpenShiftClusterList { - if in == nil { - return nil - } - out := new(OpenShiftClusterList) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *OpenShiftClusterList) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *OpenShiftClusterSpec) DeepCopyInto(out *OpenShiftClusterSpec) { - *out = *in - out.Release = in.Release - out.PullSecret = in.PullSecret - out.SSHKey = in.SSHKey - out.ProviderCreds = in.ProviderCreds -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OpenShiftClusterSpec. -func (in *OpenShiftClusterSpec) DeepCopy() *OpenShiftClusterSpec { - if in == nil { - return nil - } - out := new(OpenShiftClusterSpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *OpenShiftClusterStatus) DeepCopyInto(out *OpenShiftClusterStatus) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OpenShiftClusterStatus. -func (in *OpenShiftClusterStatus) DeepCopy() *OpenShiftClusterStatus { - if in == nil { - return nil - } - out := new(OpenShiftClusterStatus) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ReleaseSpec) DeepCopyInto(out *ReleaseSpec) { *out = *in diff --git a/config/example-cluster/cluster.yaml b/config/example-cluster/cluster.yaml index 38cadd0e1bc7..6eebe043c9f8 100644 --- a/config/example-cluster/cluster.yaml +++ b/config/example-cluster/cluster.yaml @@ -1,5 +1,5 @@ apiVersion: hypershift.openshift.io/v1alpha1 -kind: OpenShiftCluster +kind: HostedCluster metadata: name: example spec: diff --git a/config/hypershift-operator/hypershift.openshift.io_openshiftclusters.yaml b/config/hypershift-operator/hypershift.openshift.io_hostedclusters.yaml similarity index 89% rename from config/hypershift-operator/hypershift.openshift.io_openshiftclusters.yaml rename to config/hypershift-operator/hypershift.openshift.io_hostedclusters.yaml index cce30fa06e88..5b490c2c1e89 100644 --- a/config/hypershift-operator/hypershift.openshift.io_openshiftclusters.yaml +++ b/config/hypershift-operator/hypershift.openshift.io_hostedclusters.yaml @@ -6,23 +6,23 @@ metadata: annotations: controller-gen.kubebuilder.io/version: v0.3.0 creationTimestamp: null - name: openshiftclusters.hypershift.openshift.io + name: hostedclusters.hypershift.openshift.io spec: group: hypershift.openshift.io names: - kind: OpenShiftCluster - listKind: OpenShiftClusterList - plural: openshiftclusters + kind: HostedCluster + listKind: HostedClusterList + plural: hostedclusters shortNames: - - oc - - ocs - singular: openshiftcluster + - hc + - hcs + singular: hostedcluster scope: Namespaced versions: - name: v1alpha1 schema: openAPIV3Schema: - description: OpenShiftCluster is the Schema for the openshiftclusters API + description: HostedCluster is the Schema for the hostedclusters API properties: apiVersion: description: 'APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' @@ -33,7 +33,7 @@ spec: metadata: type: object spec: - description: OpenShiftClusterSpec defines the desired state of OpenShiftCluster + description: HostedClusterSpec defines the desired state of HostedCluster properties: initialComputeReplicas: type: integer @@ -82,7 +82,7 @@ spec: - sshKey type: object status: - description: OpenShiftClusterStatus defines the observed state of OpenShiftCluster + description: HostedClusterStatus defines the observed state of HostedCluster properties: ready: type: boolean diff --git a/config/hypershift-operator/kustomization.yaml b/config/hypershift-operator/kustomization.yaml index 90a40fb8a70b..3712483a4799 100644 --- a/config/hypershift-operator/kustomization.yaml +++ b/config/hypershift-operator/kustomization.yaml @@ -2,7 +2,7 @@ apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization resources: - - hypershift.openshift.io_openshiftclusters.yaml + - hypershift.openshift.io_hostedclusters.yaml - hypershift.openshift.io_hostedcontrolplanes.yaml - hypershift.openshift.io_externalinfraclusters.yaml - hypershift.openshift.io_nodepools.yaml diff --git a/hypershift-operator/controllers/openshiftcluster_controller.go b/hypershift-operator/controllers/hostedcluster_controller.go similarity index 79% rename from hypershift-operator/controllers/openshiftcluster_controller.go rename to hypershift-operator/controllers/hostedcluster_controller.go index e653639255e4..e61fbe64e666 100644 --- a/hypershift-operator/controllers/openshiftcluster_controller.go +++ b/hypershift-operator/controllers/hostedcluster_controller.go @@ -49,24 +49,24 @@ const ( providerCredsSecretName = "provider-creds" ) -// OpenShiftClusterReconciler reconciles a OpenShiftCluster object -type OpenShiftClusterReconciler struct { +// HostedClusterReconciler reconciles a HostedCluster object +type HostedClusterReconciler struct { client.Client Log logr.Logger ReleaseProvider releaseinfo.Provider Infra *configv1.Infrastructure } -// +kubebuilder:rbac:groups=hypershift.openshift.io,resources=openshiftclusters,verbs=get;list;watch;create;update;patch;delete -// +kubebuilder:rbac:groups=hypershift.openshift.io,resources=openshiftclusters/status,verbs=get;update;patch +// +kubebuilder:rbac:groups=hypershift.openshift.io,resources=hostedclusters,verbs=get;list;watch;create;update;patch;delete +// +kubebuilder:rbac:groups=hypershift.openshift.io,resources=hostedclusters/status,verbs=get;update;patch -func (r *OpenShiftClusterReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { +func (r *HostedClusterReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { r.Log = ctrl.LoggerFrom(ctx) r.Log.Info("Reconciling") - ocluster := &hyperv1.OpenShiftCluster{} + hcluster := &hyperv1.HostedCluster{} isMissing := false - err := r.Get(ctx, req.NamespacedName, ocluster) + err := r.Get(ctx, req.NamespacedName, hcluster) if err != nil { if apierrors.IsNotFound(err) { isMissing = true @@ -76,15 +76,15 @@ func (r *OpenShiftClusterReconciler) Reconcile(ctx context.Context, req ctrl.Req } // Return early if deleted - if isMissing || !ocluster.DeletionTimestamp.IsZero() { + if isMissing || !hcluster.DeletionTimestamp.IsZero() { if err := r.delete(ctx, req); err != nil { r.Log.Error(err, "failed to delete cluster") return ctrl.Result{}, err } - if controllerutil.ContainsFinalizer(ocluster, finalizer) { - controllerutil.RemoveFinalizer(ocluster, finalizer) - if err := r.Update(ctx, ocluster); err != nil { + if controllerutil.ContainsFinalizer(hcluster, finalizer) { + controllerutil.RemoveFinalizer(hcluster, finalizer) + if err := r.Update(ctx, hcluster); err != nil { return ctrl.Result{}, fmt.Errorf("failed to remove finalizer from cluster: %w", err) } } @@ -92,19 +92,19 @@ func (r *OpenShiftClusterReconciler) Reconcile(ctx context.Context, req ctrl.Req } // Ensure the cluster has a finalizer for cleanup - if !controllerutil.ContainsFinalizer(ocluster, finalizer) { - controllerutil.AddFinalizer(ocluster, finalizer) - if err := r.Update(ctx, ocluster); err != nil { + if !controllerutil.ContainsFinalizer(hcluster, finalizer) { + controllerutil.AddFinalizer(hcluster, finalizer) + if err := r.Update(ctx, hcluster); err != nil { return ctrl.Result{}, fmt.Errorf("failed to add finalizer to cluster: %w", err) } } - if ocluster.Status.Ready { + if hcluster.Status.Ready { r.Log.Info("Is ready") return ctrl.Result{}, nil } - targetNamespace := ocluster.GetName() + targetNamespace := hcluster.GetName() r.Log.Info("Creating the target namespace", "namespace", targetNamespace) ns := &corev1.Namespace{ ObjectMeta: metav1.ObjectMeta{Name: targetNamespace}, @@ -115,13 +115,13 @@ func (r *OpenShiftClusterReconciler) Reconcile(ctx context.Context, req ctrl.Req r.Log.Info("Creating provider creds secret in the target namespace", "namespace", targetNamespace) var providerCredsSecret corev1.Secret - err = r.Client.Get(ctx, client.ObjectKey{Namespace: ocluster.GetNamespace(), Name: ocluster.Spec.ProviderCreds.Name}, &providerCredsSecret) + err = r.Client.Get(ctx, client.ObjectKey{Namespace: hcluster.GetNamespace(), Name: hcluster.Spec.ProviderCreds.Name}, &providerCredsSecret) if err != nil { - return ctrl.Result{}, fmt.Errorf("failed to get provider creds %s: %w", ocluster.Spec.ProviderCreds.Name, err) + return ctrl.Result{}, fmt.Errorf("failed to get provider creds %s: %w", hcluster.Spec.ProviderCreds.Name, err) } providerCredsData, hasProviderCredsData := providerCredsSecret.Data["credentials"] if !hasProviderCredsData { - return ctrl.Result{}, fmt.Errorf("provider credentials %s is missing the credentials key", ocluster.Spec.PullSecret.Name) + return ctrl.Result{}, fmt.Errorf("provider credentials %s is missing the credentials key", hcluster.Spec.PullSecret.Name) } targetProviderCredsSecret, err := generateProviderCredsSecret(providerCredsData, targetNamespace) if err != nil { @@ -133,12 +133,12 @@ func (r *OpenShiftClusterReconciler) Reconcile(ctx context.Context, req ctrl.Req r.Log.Info("Creating pull secret in the target namespace", "namespace", targetNamespace) var pullSecret corev1.Secret - if err := r.Client.Get(ctx, ctrlclient.ObjectKey{Namespace: ocluster.GetNamespace(), Name: ocluster.Spec.PullSecret.Name}, &pullSecret); err != nil { - return ctrl.Result{}, fmt.Errorf("failed to get pull secret %s: %w", ocluster.Spec.PullSecret.Name, err) + if err := r.Client.Get(ctx, ctrlclient.ObjectKey{Namespace: hcluster.GetNamespace(), Name: hcluster.Spec.PullSecret.Name}, &pullSecret); err != nil { + return ctrl.Result{}, fmt.Errorf("failed to get pull secret %s: %w", hcluster.Spec.PullSecret.Name, err) } pullSecretData, hasPullSecretData := pullSecret.Data[".dockerconfigjson"] if !hasPullSecretData { - return ctrl.Result{}, fmt.Errorf("pull secret %s is missing the .dockerconfigjson key", ocluster.Spec.PullSecret.Name) + return ctrl.Result{}, fmt.Errorf("pull secret %s is missing the .dockerconfigjson key", hcluster.Spec.PullSecret.Name) } if _, err := createPullSecret(r, targetNamespace, pullSecretData); err != nil { return ctrl.Result{}, fmt.Errorf("failed to create pull secret: %w", err) @@ -146,13 +146,13 @@ func (r *OpenShiftClusterReconciler) Reconcile(ctx context.Context, req ctrl.Req r.Log.Info("Creating ssh key secret in the target namespace", "namespace", targetNamespace) var sshKeySecret corev1.Secret - err = r.Client.Get(ctx, client.ObjectKey{Namespace: ocluster.Namespace, Name: ocluster.Spec.SSHKey.Name}, &sshKeySecret) + err = r.Client.Get(ctx, client.ObjectKey{Namespace: hcluster.Namespace, Name: hcluster.Spec.SSHKey.Name}, &sshKeySecret) if err != nil { - return ctrl.Result{}, fmt.Errorf("failed to get SSH key secret %s: %w", ocluster.Spec.SSHKey.Name, err) + return ctrl.Result{}, fmt.Errorf("failed to get SSH key secret %s: %w", hcluster.Spec.SSHKey.Name, err) } sshKeyData, hasSSHKeyData := sshKeySecret.Data["id_rsa.pub"] if !hasSSHKeyData { - return ctrl.Result{}, fmt.Errorf("SSH key secret secret %s is missing the id_rsa.pub key", ocluster.Spec.SSHKey.Name) + return ctrl.Result{}, fmt.Errorf("SSH key secret secret %s is missing the id_rsa.pub key", hcluster.Spec.SSHKey.Name) } targetSSHSecret, err := generateSSHSecret(sshKeyData, targetNamespace) if err != nil { @@ -165,7 +165,7 @@ func (r *OpenShiftClusterReconciler) Reconcile(ctx context.Context, req ctrl.Req // run CAPI controllers params := hypershiftcp.NewClusterParams() params.Namespace = targetNamespace - releaseImage, err := r.ReleaseProvider.Lookup(ctx, ocluster.Spec.Release.Image) + releaseImage, err := r.ReleaseProvider.Lookup(ctx, hcluster.Spec.Release.Image) manifests, err := hypershiftcp.RenderCAPIManifests(params, releaseImage, nil, nil) if err != nil { return ctrl.Result{}, fmt.Errorf("failed to render hypershift manifests for cluster: %w", err) @@ -177,7 +177,7 @@ func (r *OpenShiftClusterReconciler) Reconcile(ctx context.Context, req ctrl.Req cluster := &capiv1.Cluster{ ObjectMeta: metav1.ObjectMeta{ Namespace: targetNamespace, - Name: ocluster.GetName(), + Name: hcluster.GetName(), }, Spec: capiv1.ClusterSpec{ ControlPlaneEndpoint: capiv1.APIEndpoint{}, @@ -185,17 +185,17 @@ func (r *OpenShiftClusterReconciler) Reconcile(ctx context.Context, req ctrl.Req APIVersion: "hypershift.openshift.io/v1alpha1", Kind: "HostedControlPlane", Namespace: targetNamespace, - Name: ocluster.GetName(), + Name: hcluster.GetName(), }, InfrastructureRef: &corev1.ObjectReference{ APIVersion: "hypershift.openshift.io/v1alpha1", Kind: "ExternalInfraCluster", Namespace: targetNamespace, - Name: ocluster.GetName(), + Name: hcluster.GetName(), }, }, } - patchHelper, err := patch.NewHelper(ocluster, r.Client) + patchHelper, err := patch.NewHelper(hcluster, r.Client) if err != nil { return ctrl.Result{}, fmt.Errorf("failed to init patch helper: %w", err) } @@ -203,7 +203,7 @@ func (r *OpenShiftClusterReconciler) Reconcile(ctx context.Context, req ctrl.Req hcp := &hyperv1.HostedControlPlane{ ObjectMeta: metav1.ObjectMeta{ Namespace: targetNamespace, - Name: ocluster.GetName(), + Name: hcluster.GetName(), }, Spec: hyperv1.HostedControlPlaneSpec{ ProviderCreds: corev1.LocalObjectReference{ @@ -215,18 +215,18 @@ func (r *OpenShiftClusterReconciler) Reconcile(ctx context.Context, req ctrl.Req SSHKey: corev1.LocalObjectReference{ Name: sshKeySecretName, }, - ServiceCIDR: ocluster.Spec.ServiceCIDR, - PodCIDR: ocluster.Spec.PodCIDR, - ReleaseImage: ocluster.Spec.Release.Image, + ServiceCIDR: hcluster.Spec.ServiceCIDR, + PodCIDR: hcluster.Spec.PodCIDR, + ReleaseImage: hcluster.Spec.Release.Image, }, } ExternalInfraCluster := &hyperv1.ExternalInfraCluster{ ObjectMeta: metav1.ObjectMeta{ Namespace: targetNamespace, - Name: ocluster.GetName(), + Name: hcluster.GetName(), }, Spec: hyperv1.ExternalInfraClusterSpec{ - ComputeReplicas: ocluster.Spec.InitialComputeReplicas, + ComputeReplicas: hcluster.Spec.InitialComputeReplicas, Region: r.Infra.Status.PlatformStatus.AWS.Region, }, } @@ -254,21 +254,21 @@ func (r *OpenShiftClusterReconciler) Reconcile(ctx context.Context, req ctrl.Req r.Log.Info("Not ready yet. Requeueing") return ctrl.Result{Requeue: true}, nil } - ocluster.Status.Ready = ready - if err := patchHelper.Patch(ctx, ocluster); err != nil { + hcluster.Status.Ready = ready + if err := patchHelper.Patch(ctx, hcluster); err != nil { return ctrl.Result{}, fmt.Errorf("failed to patch: %w", err) } - if ocluster.Spec.InitialComputeReplicas > 0 { + if hcluster.Spec.InitialComputeReplicas > 0 { nodePool := &hyperv1.NodePool{ TypeMeta: metav1.TypeMeta{}, ObjectMeta: metav1.ObjectMeta{ - Name: ocluster.GetName(), - Namespace: ocluster.GetNamespace(), + Name: hcluster.GetName(), + Namespace: hcluster.GetNamespace(), }, Spec: hyperv1.NodePoolSpec{ ClusterName: cluster.GetName(), - NodeCount: ocluster.Spec.InitialComputeReplicas, + NodeCount: hcluster.Spec.InitialComputeReplicas, Platform: hyperv1.NodePoolPlatform{ AWS: &hyperv1.AWSNodePoolPlatform{ InstanceType: "m5.large", @@ -286,7 +286,7 @@ func (r *OpenShiftClusterReconciler) Reconcile(ctx context.Context, req ctrl.Req return ctrl.Result{}, nil } -func (r *OpenShiftClusterReconciler) delete(ctx context.Context, req ctrl.Request) error { +func (r *HostedClusterReconciler) delete(ctx context.Context, req ctrl.Request) error { targetNamespace := req.Name r.Log.Info("Deleting default nodePool", "name", req.Name) @@ -323,7 +323,7 @@ func (r *OpenShiftClusterReconciler) delete(ctx context.Context, req ctrl.Reques return nil } -func (r *OpenShiftClusterReconciler) SetupWithManager(mgr ctrl.Manager) error { +func (r *HostedClusterReconciler) SetupWithManager(mgr ctrl.Manager) error { var infra configv1.Infrastructure if err := mgr.GetAPIReader().Get(context.Background(), client.ObjectKey{Name: "cluster"}, &infra); err != nil { return fmt.Errorf("failed to get cluster infra: %w", err) @@ -331,7 +331,7 @@ func (r *OpenShiftClusterReconciler) SetupWithManager(mgr ctrl.Manager) error { r.Infra = &infra return ctrl.NewControllerManagedBy(mgr). - For(&hyperv1.OpenShiftCluster{}). + For(&hyperv1.HostedCluster{}). WithEventFilter(predicate.GenerationChangedPredicate{}). WithOptions(controller.Options{ RateLimiter: workqueue.NewItemExponentialFailureRateLimiter(1*time.Second, 10*time.Second), diff --git a/hypershift-operator/controllers/nodepool_controller.go b/hypershift-operator/controllers/nodepool_controller.go index 1ea3f64018f9..6195aa04f3b7 100644 --- a/hypershift-operator/controllers/nodepool_controller.go +++ b/hypershift-operator/controllers/nodepool_controller.go @@ -75,7 +75,7 @@ func (r *NodePoolReconciler) Reconcile(ctx context.Context, req ctrl.Request) (c return ctrl.Result{}, err } - ocluster, err := GetOClusterByName(ctx, r.Client, nodePool.GetNamespace(), nodePool.Spec.ClusterName) + hcluster, err := GetHostedClusterByName(ctx, r.Client, nodePool.GetNamespace(), nodePool.Spec.ClusterName) if err != nil { return ctrl.Result{}, err } @@ -83,7 +83,7 @@ func (r *NodePoolReconciler) Reconcile(ctx context.Context, req ctrl.Request) (c // Ignore deleted nodePools, this can happen when foregroundDeletion // is enabled if !nodePool.DeletionTimestamp.IsZero() { - machineSet, _, err := generateScalableResources(r, ctx, r.Infra.Status.InfrastructureName, r.Infra.Status.PlatformStatus.AWS.Region, nodePool, ocluster.GetName()) + machineSet, _, err := generateScalableResources(r, ctx, r.Infra.Status.InfrastructureName, r.Infra.Status.PlatformStatus.AWS.Region, nodePool, hcluster.GetName()) if err != nil { return reconcile.Result{}, fmt.Errorf("failed to generate worker machineset: %w", err) } @@ -115,7 +115,7 @@ func (r *NodePoolReconciler) Reconcile(ctx context.Context, req ctrl.Request) (c return ctrl.Result{}, err } - result, err := r.reconcile(ctx, ocluster, nodePool) + result, err := r.reconcile(ctx, hcluster, nodePool) if err != nil { r.Log.Error(err, "Failed to reconcile nodePool") r.recorder.Eventf(nodePool, corev1.EventTypeWarning, "ReconcileError", "%v", err) @@ -131,19 +131,19 @@ func (r *NodePoolReconciler) Reconcile(ctx context.Context, req ctrl.Request) (c return result, nil } -func (r *NodePoolReconciler) reconcile(ctx context.Context, ocluster *hyperv1.OpenShiftCluster, nodePool *hyperv1.NodePool) (ctrl.Result, error) { +func (r *NodePoolReconciler) reconcile(ctx context.Context, hcluster *hyperv1.HostedCluster, nodePool *hyperv1.NodePool) (ctrl.Result, error) { log := ctrl.LoggerFrom(ctx) log.Info("Reconcile nodePool") nodePool.OwnerReferences = util.EnsureOwnerRef(nodePool.OwnerReferences, metav1.OwnerReference{ APIVersion: hyperv1.GroupVersion.String(), - Kind: "OpenshiftCluster", - Name: ocluster.Name, - UID: ocluster.UID, + Kind: "HostedCluster", + Name: hcluster.Name, + UID: hcluster.UID, }) // Create a machine scalable resources for the new cluster's worker nodes - machineSet, AWSMachineTemplate, err := generateScalableResources(r, ctx, r.Infra.Status.InfrastructureName, r.Infra.Status.PlatformStatus.AWS.Region, nodePool, ocluster.GetName()) + machineSet, AWSMachineTemplate, err := generateScalableResources(r, ctx, r.Infra.Status.InfrastructureName, r.Infra.Status.PlatformStatus.AWS.Region, nodePool, hcluster.GetName()) if err != nil { return reconcile.Result{}, fmt.Errorf("failed to generate worker machineset: %w", err) } @@ -167,19 +167,19 @@ func (r *NodePoolReconciler) reconcile(ctx context.Context, ocluster *hyperv1.Op return ctrl.Result{}, nil } -// GetClusterByName finds and return an OpenshiftCluster object using the specified params. -func GetOClusterByName(ctx context.Context, c client.Client, namespace, name string) (*hyperv1.OpenShiftCluster, error) { - ocluster := &hyperv1.OpenShiftCluster{} +// GetHostedClusterByName finds and return a HostedCluster object using the specified params. +func GetHostedClusterByName(ctx context.Context, c client.Client, namespace, name string) (*hyperv1.HostedCluster, error) { + hcluster := &hyperv1.HostedCluster{} key := client.ObjectKey{ Namespace: namespace, Name: name, } - if err := c.Get(ctx, key, ocluster); err != nil { + if err := c.Get(ctx, key, hcluster); err != nil { return nil, err } - return ocluster, nil + return hcluster, nil } func generateScalableResources(client ctrlclient.Client, ctx context.Context, diff --git a/hypershift-operator/main.go b/hypershift-operator/main.go index b26165ee6c3b..8fa954401ce7 100644 --- a/hypershift-operator/main.go +++ b/hypershift-operator/main.go @@ -140,13 +140,13 @@ func NewStartCommand() *cobra.Command { os.Exit(1) } - if err = (&controllers.OpenShiftClusterReconciler{ + if err = (&controllers.HostedClusterReconciler{ Client: mgr.GetClient(), ReleaseProvider: &releaseinfo.PodProvider{ Pods: kubeClient.CoreV1().Pods("hypershift"), }, }).SetupWithManager(mgr); err != nil { - setupLog.Error(err, "unable to create controller", "controller", "OpenShiftCluster") + setupLog.Error(err, "unable to create controller", "controller", "HostedCluster") os.Exit(1) } diff --git a/test/e2e/quick_start_test.go b/test/e2e/quick_start_test.go index f814857a4a64..d2ab547f8017 100644 --- a/test/e2e/quick_start_test.go +++ b/test/e2e/quick_start_test.go @@ -52,7 +52,7 @@ func QuickStartSpec(ctx context.Context, inputGetter func() QuickStartSpecInput) specName = "quick-start" input QuickStartSpecInput - cluster *hyperv1.OpenShiftCluster + cluster *hyperv1.HostedCluster ) BeforeEach(func() { @@ -82,9 +82,9 @@ func QuickStartSpec(ctx context.Context, inputGetter func() QuickStartSpecInput) Expect(err).NotTo(HaveOccurred(), "couldn't apply resource") } - // Get the actual OpenShiftCluster that was created + // Get the actual HostedCluster that was created log.Logf("Waiting for cluster resource to exist") - cluster = &hyperv1.OpenShiftCluster{ + cluster = &hyperv1.HostedCluster{ ObjectMeta: metav1.ObjectMeta{ Namespace: "hypershift", Name: "example",