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

feat: Support using external infra cluster #4

Merged
merged 1 commit into from
Jul 5, 2022

Conversation

carezkh
Copy link
Contributor

@carezkh carezkh commented Jun 27, 2022

Steps to use external cluster for infrastructure

  • Create a Secret with a kubeconfig for external cluster used for infrastructure.
    kubectl create secret generic <secret-name> --from-file=kubeconfig=<kubeconfig-file-path>
  • Add Secret name to VirtinkCluster.Spec.InfraClusterSecretRef. When nil, the management cluster will be used for infrastructure.

spec:
infraClusterSecretRef:
name: secret-name
namespace: default

  • Set VirtinkCluster.Spec.ConrolPlaneServiceType to LoadBalancer. You can set this filed to NodePort or LoadBalancer (nil for NodePort). When using external cluster, LoadBalancer is required and its external IP should be reachable in management cluster.

@carezkh carezkh force-pushed the care-dev-support-external-cluster branch from bf83b08 to a817ebe Compare June 27, 2022 08:11
controllers/virtinkmachine_controller.go Outdated Show resolved Hide resolved
controllers/virtinkmachine_controller.go Outdated Show resolved Hide resolved
controllers/virtinkmachine_controller.go Outdated Show resolved Hide resolved
pkg/externalcluster/externalcluster.go Outdated Show resolved Hide resolved
@carezkh carezkh force-pushed the care-dev-support-external-cluster branch from a817ebe to fc10090 Compare July 1, 2022 06:23
@carezkh carezkh requested a review from fengye87 July 1, 2022 06:30
controllers/virtinkmachine_controller.go Outdated Show resolved Hide resolved
vm.Spec.Instance.Disks = append(vm.Spec.Instance.Disks, virtv1alpha1.Disk{
Name: "cloud-init",
})
vm.Spec.Volumes = append(vm.Spec.Volumes, virtv1alpha1.Volume{
Name: "cloud-init",
VolumeSource: virtv1alpha1.VolumeSource{
CloudInit: &virtv1alpha1.CloudInitVolumeSource{
UserDataSecretName: *ownerMachine.Spec.Bootstrap.DataSecretName,
UserData: string(secret.Data["value"]),
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe it's better we base64 encode it?

controllers/virtinkcluster_controller.go Outdated Show resolved Hide resolved
@fengye87 fengye87 changed the title feat: Support using external cluster for infrastructure feat: Support using external infra cluster Jul 1, 2022
@carezkh carezkh force-pushed the care-dev-support-external-cluster branch from 7e0b7bc to 46f7987 Compare July 1, 2022 09:45
@carezkh carezkh requested a review from fengye87 July 1, 2022 09:46
@@ -67,65 +71,136 @@ func (r *VirtinkClusterReconciler) Reconcile(ctx context.Context, req ctrl.Reque
}

func (r *VirtinkClusterReconciler) reconcile(ctx context.Context, cluster *infrastructurev1beta1.VirtinkCluster) error {
if !cluster.DeletionTimestamp.IsZero() {
if !controllerutil.ContainsFinalizer(cluster, finalizer) {
Copy link
Contributor

Choose a reason for hiding this comment

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

We should only add finalizer when object is not deleted. See https://book.kubebuilder.io/reference/using-finalizers.html

@@ -67,7 +69,8 @@ func (r *VirtinkMachineReconciler) Reconcile(ctx context.Context, req ctrl.Reque
}

func (r *VirtinkMachineReconciler) reconcile(ctx context.Context, machine *infrastructurev1beta1.VirtinkMachine) error {
if !machine.DeletionTimestamp.IsZero() {
if !controllerutil.ContainsFinalizer(machine, finalizer) {
controllerutil.AddFinalizer(machine, finalizer)
Copy link
Contributor

Choose a reason for hiding this comment

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

@carezkh carezkh force-pushed the care-dev-support-external-cluster branch from 46f7987 to c4ee1b1 Compare July 5, 2022 06:17
@fengye87 fengye87 merged commit 5f9232a into main Jul 5, 2022
@fengye87 fengye87 deleted the care-dev-support-external-cluster branch July 5, 2022 06:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants