Skip to content

Commit

Permalink
disable k8s node cleanup and let CAPI handle it (#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
bschimke95 authored Aug 2, 2024
1 parent 5359637 commit fb71afe
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
8 changes: 8 additions & 0 deletions pkg/ck8s/api/annotations.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package apiv1

const (
// AnnotationSkipCleanupKubernetesNodeOnRemove if set, only the microcluster & file cleanup is done.
// This is useful, if an external controller (e.g. CAPI) is responsible for the Kubernetes node life cycle.
// By default, the Kubernetes node is removed by k8sd if a node is removed from the cluster.
AnnotationSkipCleanupKubernetesNodeOnRemove = "k8sd/v1alpha/lifecycle/skip-cleanup-kubernetes-node-on-remove"
)
6 changes: 6 additions & 0 deletions pkg/ck8s/config_init.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ func GenerateInitControlPlaneConfig(cfg InitControlPlaneConfig) (apiv1.Bootstrap
// annotations
out.ClusterConfig.Annotations = cfg.InitConfig.Annotations

// Since CAPI handles the lifecycle management of Kubernetes nodes, k8s-snap should only focus on
// cleaning up microcluster and files during upgrades.
if _, ok := out.ClusterConfig.Annotations[apiv1.AnnotationSkipCleanupKubernetesNodeOnRemove]; !ok {
out.ClusterConfig.Annotations[apiv1.AnnotationSkipCleanupKubernetesNodeOnRemove] = "true"
}

// features
out.ClusterConfig.DNS.Enabled = ptr.To(cfg.InitConfig.GetEnableDefaultDNS())
out.ClusterConfig.LocalStorage.Enabled = ptr.To(cfg.InitConfig.GetEnableDefaultLocalStorage())
Expand Down

0 comments on commit fb71afe

Please sign in to comment.