Skip to content

Commit

Permalink
Merge pull request #298 from k0sproject/revert-291-fix-k0s-version
Browse files Browse the repository at this point in the history
Revert "Remove redundant k0s version field"
  • Loading branch information
makhov authored Oct 13, 2023
2 parents b61bad8 + 8eef3a5 commit 54fc44a
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 4 deletions.
4 changes: 4 additions & 0 deletions api/controlplane/v1beta1/k0s_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ type K0sControlPlaneSpec struct {
//+kubebuilder:validation:Optional
//+kubebuilder:default=1
Replicas int32 `json:"replicas,omitempty"`
// K0sVersion defines the k0s version to be deployed. If empty k0smotron
// will pick it automatically.
//+kubebuilder:validation:Optional
K0sVersion string `json:"k0sVersion,omitempty"`
}

type K0sBootstrapConfigSpec struct {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@ spec:
For reference see the Kubernetes version skew policy: https://kubernetes.io/docs/setup/release/version-skew-policy/'
type: string
type: object
k0sVersion:
description: K0sVersion defines the k0s version to be deployed. If
empty k0smotron will pick it automatically.
type: string
machineTemplate:
properties:
infrastructureRef:
Expand Down
2 changes: 1 addition & 1 deletion internal/controller/controlplane/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func (c *K0sController) deleteMachine(ctx context.Context, name string, kcp *cpv
}

func (c *K0sController) generateMachine(_ context.Context, name string, cluster *clusterv1.Cluster, kcp *cpv1beta1.K0sControlPlane, infraRef corev1.ObjectReference) *clusterv1.Machine {
ver := semver.MustParse(kcp.Spec.K0sConfigSpec.Version)
ver := semver.MustParse(kcp.Spec.K0sVersion)
v := fmt.Sprintf("%d.%d.%d", ver.Major(), ver.Minor(), ver.Patch())
return &clusterv1.Machine{
TypeMeta: metav1.TypeMeta{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ func (c *K0sController) Reconcile(ctx context.Context, req ctrl.Request) (res ct
return ctrl.Result{}, nil
}

if kcp.Spec.K0sConfigSpec.Version == "" {
kcp.Spec.K0sConfigSpec.Version = defaultK0SVersion
if kcp.Spec.K0sVersion == "" {
kcp.Spec.K0sVersion = defaultK0SVersion
}

cluster, err := capiutil.GetOwnerCluster(ctx, c.Client, kcp.ObjectMeta)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ metadata:
spec:
replicas: 1
k0sConfigSpec:
version: v1.27.3+k0s.0
version: v1.28.2+k0s.0
k0s:
apiVersion: k0s.k0sproject.io/v1beta1
kind: ClusterConfig
Expand Down

0 comments on commit 54fc44a

Please sign in to comment.