Skip to content

Commit 2947bf2

Browse files
committed
fix: owner references and clusterctl annotations
This should enable moves. Though they still result in a firewall roll.
1 parent f706998 commit 2947bf2

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

capi-lab/firewall-controller-manager/kustomization.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22
namespace: capms-system
33
namePrefix: capms-
44

5+
labels:
6+
- includeSelectors: false
7+
pairs:
8+
cluster.x-k8s.io/v1beta1: v1alpha1
9+
# TODO this only needs to be set because we currently do not install everything using clusterctl
10+
clusterctl.cluster.x-k8s.io: ""
11+
512
resources:
613
- bases/firewall.metal-stack.io_firewalldeployments.yaml
714
- bases/firewall.metal-stack.io_firewallmonitors.yaml

internal/controller/metalstackcluster_controller.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,7 @@ func (r *clusterReconciler) ensureSshKeyPair(ctx context.Context) (string, error
492492
secret.Labels = map[string]string{
493493
clusterv1.ClusterNameLabel: r.cluster.Name,
494494
}
495-
secret.OwnerReferences = append(secret.OwnerReferences, *metav1.NewControllerRef(r.infraCluster, r.infraCluster.GroupVersionKind()))
495+
secret.OwnerReferences = r.ownerReferences()
496496

497497
err = r.client.Create(ctx, secret)
498498
if err != nil {
@@ -561,6 +561,7 @@ func (r *clusterReconciler) ensureFirewallDeployment(nodeNetworkID, sshPubKey st
561561
}
562562

563563
deploy.Labels[clusterv1.ClusterNameLabel] = r.cluster.Name
564+
deploy.OwnerReferences = r.ownerReferences()
564565

565566
deploy.Spec.Replicas = 1
566567
deploy.Spec.Selector = map[string]string{
@@ -720,3 +721,9 @@ func (r *clusterReconciler) deleteFirewallDeployment() error {
720721

721722
return errors.New("firewall deployment is still ongoing")
722723
}
724+
725+
func (r *clusterReconciler) ownerReferences() []metav1.OwnerReference {
726+
return []metav1.OwnerReference{
727+
*metav1.NewControllerRef(r.infraCluster, r.infraCluster.GroupVersionKind()),
728+
}
729+
}

0 commit comments

Comments
 (0)