Skip to content

Commit

Permalink
Merge pull request k0sproject#574 from cwrau/fix/missing-fsgroup
Browse files Browse the repository at this point in the history
fix: add missing fsgroup option otherwise etcd couldn't read the dataDir
  • Loading branch information
makhov authored May 27, 2024
2 parents c94573e + f37254f commit 80a3410
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 15 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ require (
k8s.io/apimachinery v0.28.4
k8s.io/client-go v0.28.4
k8s.io/kubernetes v1.28.4
k8s.io/utils v0.0.0-20230406110748-d93618cff8a2
k8s.io/utils v0.0.0-20240502163921-fe8a2dddb1d0
sigs.k8s.io/controller-runtime v0.16.5
sigs.k8s.io/yaml v1.4.0
)
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -551,8 +551,8 @@ k8s.io/kubelet v0.28.4 h1:Ypxy1jaFlSXFXbg/yVtFOU2ZxErBVRJfLu8+t4s7Dtw=
k8s.io/kubelet v0.28.4/go.mod h1:w1wPI12liY/aeC70nqKYcNNkr6/nbyvdMB7P7wmww2o=
k8s.io/kubernetes v1.28.4 h1:aRNxs5jb8FVTtlnxeA4FSDBVKuFwA8Gw40/U2zReBYA=
k8s.io/kubernetes v1.28.4/go.mod h1:BTzDCKYAlu6LL9ITbfjwgwIrJ30hlTgbv0eXDoA/WoA=
k8s.io/utils v0.0.0-20230406110748-d93618cff8a2 h1:qY1Ad8PODbnymg2pRbkyMT/ylpTrCM8P2RJ0yroCyIk=
k8s.io/utils v0.0.0-20230406110748-d93618cff8a2/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
k8s.io/utils v0.0.0-20240502163921-fe8a2dddb1d0 h1:jgGTlFYnhF1PM1Ax/lAlxUPE+KfCIXHaathvJg1C3ak=
k8s.io/utils v0.0.0-20240502163921-fe8a2dddb1d0/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.1.2 h1:trsWhjU5jZrx6UvFu4WzQDrN7Pga4a7Qg+zcfcj64PA=
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.1.2/go.mod h1:+qG7ISXqCDVVcyO8hLn12AKVYYUjM7ftlqsqmrhMZE0=
sigs.k8s.io/cluster-api v1.6.3 h1:VOlPNg92PQLlhBVLc5pg+cbAuPvGOOBujeFLk9zgnoo=
Expand Down
6 changes: 3 additions & 3 deletions internal/controller/bootstrap/bootstrap_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"
"k8s.io/utils/pointer"
"k8s.io/utils/ptr"
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
bsutil "sigs.k8s.io/cluster-api/bootstrap/util"
"sigs.k8s.io/cluster-api/controllers/remote"
Expand Down Expand Up @@ -202,7 +202,7 @@ func (r *Controller) Reconcile(ctx context.Context, req ctrl.Request) (res ctrl.
Kind: "K0sWorkerConfig",
Name: scope.Config.Name,
UID: scope.Config.UID,
Controller: pointer.Bool(true),
Controller: ptr.To(true),
},
},
},
Expand All @@ -221,7 +221,7 @@ func (r *Controller) Reconcile(ctx context.Context, req ctrl.Request) (res ctrl.

// Set the status to ready
scope.Config.Status.Ready = true
scope.Config.Status.DataSecretName = pointer.String(bootstrapSecret.Name)
scope.Config.Status.DataSecretName = ptr.To(bootstrapSecret.Name)
if err := r.Status().Update(ctx, scope.Config); err != nil {
log.Error(err, "Failed to patch config status")
return ctrl.Result{}, err
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import (
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"
"k8s.io/client-go/util/retry"
"k8s.io/utils/pointer"
"k8s.io/utils/ptr"
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
kubeadmbootstrapv1 "sigs.k8s.io/cluster-api/bootstrap/kubeadm/api/v1beta1"
bsutil "sigs.k8s.io/cluster-api/bootstrap/util"
Expand Down Expand Up @@ -248,7 +248,7 @@ func (c *ControlPlaneController) Reconcile(ctx context.Context, req ctrl.Request
Kind: "K0sControllerConfig",
Name: config.Name,
UID: config.UID,
Controller: pointer.Bool(true),
Controller: ptr.To(true),
},
},
},
Expand All @@ -267,7 +267,7 @@ func (c *ControlPlaneController) Reconcile(ctx context.Context, req ctrl.Request

// Set the status to ready
config.Status.Ready = true
config.Status.DataSecretName = pointer.String(bootstrapSecret.Name)
config.Status.DataSecretName = ptr.To(bootstrapSecret.Name)

err = retry.RetryOnConflict(retry.DefaultBackoff, func() error {
return c.Status().Update(ctx, config)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import (
"context"
"errors"
"fmt"
"strings"

"github.com/google/uuid"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
Expand All @@ -29,7 +31,7 @@ import (
"k8s.io/apimachinery/pkg/util/intstr"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"
"k8s.io/utils/pointer"
"k8s.io/utils/ptr"
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
kubeadmbootstrapv1 "sigs.k8s.io/cluster-api/bootstrap/kubeadm/api/v1beta1"
capiutil "sigs.k8s.io/cluster-api/util"
Expand All @@ -39,7 +41,6 @@ import (
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/log"
"strings"

bootstrapv1 "github.com/k0sproject/k0smotron/api/bootstrap/v1beta1"
cpv1beta1 "github.com/k0sproject/k0smotron/api/controlplane/v1beta1"
Expand Down Expand Up @@ -308,8 +309,8 @@ func (c *K0sController) createBootstrapConfig(ctx context.Context, name string,
Kind: machine.Kind,
Name: machine.GetName(),
UID: machine.GetUID(),
BlockOwnerDeletion: pointer.Bool(true),
Controller: pointer.Bool(true),
BlockOwnerDeletion: ptr.To(true),
Controller: ptr.To(true),
}},
},
Spec: bootstrapv1.K0sControllerConfigSpec{
Expand Down
4 changes: 2 additions & 2 deletions internal/controller/infrastructure/job_provisioner.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes"
"k8s.io/utils/pointer"
"k8s.io/utils/ptr"
"sigs.k8s.io/cluster-api/api/v1beta1"
"sigs.k8s.io/controller-runtime/pkg/client"

Expand Down Expand Up @@ -178,7 +178,7 @@ func (p *JobProvisioner) extractCloudInit(cloudInit *cloudinit.CloudInit) (volum
volume.VolumeSource.Secret.Items = append(volume.VolumeSource.Secret.Items, v1.KeyToPath{
Key: "k0smotron-entrypoint.sh",
Path: "k0smotron-entrypoint.sh",
Mode: pointer.Int32(0755),
Mode: ptr.To[int32](0755),
})

return volume, volumeMounts, secretData
Expand Down
4 changes: 4 additions & 0 deletions internal/controller/k0smotron.io/k0smotroncluster_etcd.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/intstr"
"k8s.io/utils/ptr"
"sigs.k8s.io/cluster-api/util/secret"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
Expand Down Expand Up @@ -220,6 +221,9 @@ func (r *ClusterReconciler) generateEtcdStatefulSet(kmc *km.Cluster, replicas in
},
},
}},
SecurityContext: &v1.PodSecurityContext{
FSGroup: ptr.To(int64(1001)),
},
InitContainers: r.generateEtcdInitContainers(kmc),
Containers: []v1.Container{{
Name: "etcd",
Expand Down

0 comments on commit 80a3410

Please sign in to comment.