Skip to content

Commit

Permalink
SUS-681 Additional Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
vishu2498 committed Jan 24, 2025
1 parent 775260f commit ed00c20
Show file tree
Hide file tree
Showing 28 changed files with 382 additions and 581 deletions.
7 changes: 2 additions & 5 deletions bootstrap/kubeadm/api/v1alpha4/zz_generated.conversion.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions bootstrap/kubeadm/api/v1beta1/kubeadm_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,21 @@ type NodeRegistrationOptions struct {
// IgnorePreflightErrors provides a slice of pre-flight errors to be ignored when the current node is registered.
// +optional
IgnorePreflightErrors []string `json:"ignorePreflightErrors,omitempty"`

// imagePullPolicy specifies the policy for image pulling
// during kubeadm "init" and "join" operations. The value of
// this field must be one of "Always", "IfNotPresent" or
// "Never". Defaults to "IfNotPresent". This can be used only
// with Kubernetes version equal to 1.22 and later.
// +kubebuilder:validation:Enum=Always;IfNotPresent;Never
// +optional
ImagePullPolicy string `json:"imagePullPolicy,omitempty"`

// imagePullSerial specifies if image pulling performed by kubeadm must be done serially or in parallel.
// This option takes effect only on Kubernetes >=1.31.0.
// Default: true (defaulted in kubeadm)
// +optional
ImagePullSerial *bool `json:"imagePullSerial,omitempty"`
}

// MarshalJSON marshals NodeRegistrationOptions in a way that an empty slice in Taints is preserved.
Expand Down
5 changes: 5 additions & 0 deletions bootstrap/kubeadm/api/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 7 additions & 2 deletions bootstrap/kubeadm/config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ rules:
- ""
resources:
- configmaps
- events
- secrets
verbs:
- create
Expand All @@ -23,7 +22,6 @@ rules:
- bootstrap.cluster.x-k8s.io
resources:
- kubeadmconfigs
- kubeadmconfigs/finalizers
- kubeadmconfigs/status
verbs:
- create
Expand All @@ -47,3 +45,10 @@ rules:
- get
- list
- watch
- apiGroups:
- ""
resources:
- events
verbs:
- create
- patch
2 changes: 1 addition & 1 deletion bootstrap/kubeadm/internal/cloudinit/cloudinit.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"fmt"
"text/template"

"github.com/blang/semver"
"github.com/blang/semver/v4"
"github.com/pkg/errors"

bootstrapv1 "sigs.k8s.io/cluster-api/bootstrap/kubeadm/api/v1beta1"
Expand Down
24 changes: 21 additions & 3 deletions bootstrap/kubeadm/internal/controllers/kubeadmconfig_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ import (
"sigs.k8s.io/cluster-api/controllers/remote"
expv1 "sigs.k8s.io/cluster-api/exp/api/v1beta1"
"sigs.k8s.io/cluster-api/feature"
"sigs.k8s.io/cluster-api/internal/util/taints"
"sigs.k8s.io/cluster-api/util"
"sigs.k8s.io/cluster-api/util/annotations"
"sigs.k8s.io/cluster-api/util/conditions"
Expand Down Expand Up @@ -601,8 +600,16 @@ func (r *KubeadmConfigReconciler) joinWorker(ctx context.Context, scope *Scope)
// Do not modify the KubeadmConfig in etcd as this is a temporary taint that will be dropped after the node
// is initialized by ClusterAPI.
joinConfiguration := scope.Config.Spec.JoinConfiguration.DeepCopy()
if !taints.HasTaint(joinConfiguration.NodeRegistration.Taints, clusterv1.NodeUninitializedTaint) {
joinConfiguration.NodeRegistration.Taints = append(joinConfiguration.NodeRegistration.Taints, clusterv1.NodeUninitializedTaint)

// TODO: Vishwanath
// For the k8s v1.31.4 support via kubeadm v1beta4 API version
var NodeUninitializedTaint = corev1.Taint{
Key: "node.cluster.x-k8s.io/uninitialized",
Effect: corev1.TaintEffectNoSchedule,
}

if !HasTaint(joinConfiguration.NodeRegistration.Taints, NodeUninitializedTaint) {
joinConfiguration.NodeRegistration.Taints = append(joinConfiguration.NodeRegistration.Taints, NodeUninitializedTaint)
}

// NOTE: It is not required to provide in input ClusterConfiguration because only clusterConfiguration.APIServer.TimeoutForControlPlane
Expand Down Expand Up @@ -1149,3 +1156,14 @@ func (r *KubeadmConfigReconciler) ensureBootstrapSecretOwnersRef(ctx context.Con
}
return nil
}

// TODO: Vishwanath
// HasTaint returns true if the targetTaint is in the list of taints.
func HasTaint(taints []corev1.Taint, targetTaint corev1.Taint) bool {
for _, taint := range taints {
if taint.MatchTaint(&targetTaint) {
return true
}
}
return false
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 7 additions & 10 deletions bootstrap/kubeadm/types/upstreamv1beta2/zz_generated.conversion.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"fmt"
"strings"

"github.com/blang/semver"
"github.com/blang/semver/v4"
"github.com/coredns/corefile-migration/migration"
jsonpatch "github.com/evanphx/json-patch/v5"
"github.com/pkg/errors"
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit ed00c20

Please sign in to comment.