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

Implemented the unmanaged cluster CRD for adopting existing k8s clusters #623

Closed
wants to merge 5 commits into from

Conversation

kylewuolle
Copy link
Contributor

Resolves #542

This PR implements adopting existing k8s clusters into 2a.

Makefile Show resolved Hide resolved
Makefile Outdated Show resolved Hide resolved
Makefile Outdated Show resolved Hide resolved
Makefile Outdated Show resolved Hide resolved
Makefile Outdated Show resolved Hide resolved
internal/controller/unmanagedcluster_controller.go Outdated Show resolved Hide resolved
internal/controller/unmanagedcluster_controller.go Outdated Show resolved Hide resolved
kind: ClusterRole
metadata:
labels:
hmc.mirantis.com/aggregate-to-global-admin: "true"
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think rbac considerations should be similar to managedclusters, unless it was decided otherwise

Copy link
Contributor

@a13x5 a13x5 left a comment

Choose a reason for hiding this comment

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

IMO The design of using unmanaged cluster as an infrastructure provider looks needlessly complicated for our purposes.

Status handling logic should be reconsidered.
kubebuilder comments must be cleared out.

api/v1alpha1/unmanagedcluster_types.go Outdated Show resolved Hide resolved
api/v1alpha1/unmanagedcluster_types.go Show resolved Hide resolved
api/v1alpha1/unmanagedmachine_types.go Show resolved Hide resolved
internal/controller/unmanagedcluster_controller.go Outdated Show resolved Hide resolved
internal/controller/unmanagedcluster_controller.go Outdated Show resolved Hide resolved
internal/controller/unmanagedmachine_controller.go Outdated Show resolved Hide resolved
internal/controller/unmanagedmachine_controller.go Outdated Show resolved Hide resolved
internal/controller/unmanagedmachine_controller.go Outdated Show resolved Hide resolved
@kylewuolle kylewuolle requested review from a13x5 and Kshatrix November 13, 2024 18:29
Copy link
Member

@eromanova eromanova left a comment

Choose a reason for hiding this comment

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

Minor comments from my side. @kylewuolle could you please address unresolved comments from Andrey, rebase the PR, and resolve all the conflicts?

// +kubebuilder:default:=false
Ready bool `json:"ready"`

// Conditions contains details for the current state of the ManagedCluster.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// Conditions contains details for the current state of the ManagedCluster.
// Conditions contains details for the current state of the UnmanagedCluster.

// Flag indicating whether the machine is in the ready state or not
// +kubebuilder:default:=false
Ready bool `json:"ready,omitempty"`
// Conditions contains details for the current state of the ManagedCluster
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// Conditions contains details for the current state of the ManagedCluster
// Conditions contains details for the current state of the UnmanagedCluster

Name: unmanagedCluster.Name,
Namespace: unmanagedCluster.Namespace,
Labels: map[string]string{
"helm.toolkit.fluxcd.io/name": unmanagedCluster.Name,
Copy link
Member

Choose a reason for hiding this comment

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

Can be replaced with hmc.FluxHelmChartNameKey

Namespace: unmanagedCluster.Namespace,
Labels: map[string]string{
"helm.toolkit.fluxcd.io/name": unmanagedCluster.Name,
"helm.toolkit.fluxcd.io/namespace": unmanagedCluster.Namespace,
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
"helm.toolkit.fluxcd.io/namespace": unmanagedCluster.Namespace,
hmc.FluxHelmChartNamespaceKey: unmanagedCluster.Namespace,

return nil, nil
}

kubecfgSeccret := &corev1.Secret{}
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
kubecfgSeccret := &corev1.Secret{}
kubecfgSecret := &corev1.Secret{}

"with key %s", kubecfgSeccret.Name, secret.KubeconfigDataName))
}

if cluserNameLabel, ok := kubecfgSeccret.Labels[v1beta1.ClusterNameLabel]; !ok || cluserNameLabel != unmanagedCluster.Name {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if cluserNameLabel, ok := kubecfgSeccret.Labels[v1beta1.ClusterNameLabel]; !ok || cluserNameLabel != unmanagedCluster.Name {
if clusterNameLabel, ok := kubecfgSeccret.Labels[v1beta1.ClusterNameLabel]; !ok || cluserNameLabel != unmanagedCluster.Name {

Spec: v1beta1.ClusterSpec{
ControlPlaneEndpoint: controlPlaneEndPoint,
InfrastructureRef: &corev1.ObjectReference{
Kind: "UnmanagedCluster",
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Kind: "UnmanagedCluster",
Kind: hmc.UnmanagedClusterKind,

OwnerReferences: []metav1.OwnerReference{
{
APIVersion: hmc.GroupVersion.Identifier(),
Kind: "UnmanagedMachine",
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Kind: "UnmanagedMachine",
Kind: hmc.UnmanagedMachineKind,

@kylewuolle kylewuolle closed this Dec 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Create unmanaged cluster controller and crd
4 participants