Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to lb-csi v1.12, drop k8s < v1.20 #63

Merged
merged 2 commits into from
Dec 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Build the duros-controller binary
FROM golang:1.20 as builder
FROM golang:1.21 as builder

ENV KUBEBUILDER_DOWNLOAD_URL=https://github.com/kubernetes-sigs/kubebuilder/releases/download
ENV KUBEBUILDER_VER=v3.4.1
Expand Down
18 changes: 8 additions & 10 deletions controllers/images.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
package controllers

const (
lbCSIPluginImage = "docker.lightbitslabs.com/lightos-csi/lb-csi-plugin:1.9.1"
lbDiscoveryClientImage = "docker.lightbitslabs.com/lightos-csi/lb-nvme-discovery-client:1.9.1"
csiProvisionerImage = "registry.k8s.io/sig-storage/csi-provisioner:v2.2.2"
csiAttacherImage = "registry.k8s.io/sig-storage/csi-attacher:v3.5.0"
csiResizerImage = "registry.k8s.io/sig-storage/csi-resizer:v1.5.0"
csiNodeDriverRegistrarImage = "registry.k8s.io/sig-storage/csi-node-driver-registrar:v2.5.1"
snapshotControllerImageBeta1 = "registry.k8s.io/sig-storage/snapshot-controller:v4.1.0"
csiSnapshotterImageBeta1 = "registry.k8s.io/sig-storage/csi-snapshotter:v4.1.0"
snapshotControllerImage = "registry.k8s.io/sig-storage/snapshot-controller:v6.1.0" // for k8s >= 1.20
csiSnapshotterImage = "registry.k8s.io/sig-storage/csi-snapshotter:v6.1.0" // for k8s >= 1.20
lbCSIPluginImage = "docker.lightbitslabs.com/lightos-csi/lb-csi-plugin:1.12.0"
lbDiscoveryClientImage = "docker.lightbitslabs.com/lightos-csi/lb-nvme-discovery-client:1.12.0"
csiProvisionerImage = "registry.k8s.io/sig-storage/csi-provisioner:v3.6.2"
csiAttacherImage = "registry.k8s.io/sig-storage/csi-attacher:v4.4.2"
csiResizerImage = "registry.k8s.io/sig-storage/csi-resizer:v1.9.2"
csiNodeDriverRegistrarImage = "registry.k8s.io/sig-storage/csi-node-driver-registrar:v2.9.2"
snapshotControllerImage = "registry.k8s.io/sig-storage/snapshot-controller:v6.3.2"
csiSnapshotterImage = "registry.k8s.io/sig-storage/csi-snapshotter:v6.3.2"
)
72 changes: 26 additions & 46 deletions controllers/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"github.com/golang-jwt/jwt/v4"
"github.com/metal-stack/duros-go"
durosv2 "github.com/metal-stack/duros-go/api/duros/v2"
"github.com/metal-stack/metal-lib/pkg/k8s"
metaltag "github.com/metal-stack/metal-lib/pkg/tag"

storagev1 "github.com/metal-stack/duros-controller/api/v1"
Expand Down Expand Up @@ -937,16 +936,6 @@ func (r *DurosReconciler) deployCSI(ctx context.Context, projectID string, scs [
log := r.Log.WithName("storage-csi")
log.Info("deploy storage-class")

v, err := r.DiscoveryClient.ServerVersion()
if err != nil {
return err
}
kubernetesVersion := v.String()
greaterOrEqual120, err := k8s.GreaterThanOrEqual(kubernetesVersion, k8s.KubernetesV120)
if err != nil {
return err
}

rm := r.Shoot.RESTMapper()
gkv, err := rm.ResourceFor(schema.GroupVersionResource{
Group: "storage.k8s.io",
Expand All @@ -973,13 +962,8 @@ func (r *DurosReconciler) deployCSI(ctx context.Context, projectID string, scs [
}
log.Info("csidriver", "name", csiDriver.Name, "operation", op)
snapshotsSupported = true
if greaterOrEqual120 {
snapshotControllerContainer.Image = snapshotControllerImage
csiSnapshotterContainer.Image = csiSnapshotterImage
} else {
snapshotControllerContainer.Image = snapshotControllerImageBeta1
Gerrit91 marked this conversation as resolved.
Show resolved Hide resolved
csiSnapshotterContainer.Image = csiSnapshotterImageBeta1
}
snapshotControllerContainer.Image = snapshotControllerImage
csiSnapshotterContainer.Image = csiSnapshotterImage
case "v1beta1":
csiDriver := &storagev1beta1.CSIDriver{ObjectMeta: metav1.ObjectMeta{Name: provisioner}}
op, err := controllerutil.CreateOrUpdate(ctx, r.Shoot, csiDriver, func() error {
Expand Down Expand Up @@ -1119,10 +1103,6 @@ func (r *DurosReconciler) deployCSI(ctx context.Context, projectID string, scs [

for i := range scs {
sc := scs[i]
if sc.Encryption && !greaterOrEqual120 {
log.Info("storageclass has encryption enabled but the k8s version is lower than 1.20, ignoring this storageclass", "name", sc.Name)
continue
}
annotations := map[string]string{
"storageclass.kubernetes.io/is-default-class": strconv.FormatBool(sc.Default),
metaltag.ClusterDescription: "DO NOT EDIT - This resource is managed by duros-controller. Any modifications are discarded and the resource is returned to the original state.",
Expand Down Expand Up @@ -1180,33 +1160,33 @@ func (r *DurosReconciler) deployCSI(ctx context.Context, projectID string, scs [
return err
}

if greaterOrEqual120 {
annotations := map[string]string{
"snapshot.storage.kubernetes.io/is-default-class": "true",
metaltag.ClusterDescription: "DO NOT EDIT - This resource is managed by duros-controller. Any modifications are discarded and the resource is returned to the original state.",
}
obj := &snapshotv1.VolumeSnapshotClass{ObjectMeta: metav1.ObjectMeta{Name: "partition-snapshot"}}
op, err := controllerutil.CreateOrUpdate(ctx, r.Shoot, obj, func() error {
obj.ObjectMeta.Annotations = annotations
obj.Driver = provisioner
obj.DeletionPolicy = snapshotv1.VolumeSnapshotContentDelete
obj.Parameters = map[string]string{
"csi.storage.k8s.io/snapshotter-secret-name": storageClassCredentialsRef,
"csi.storage.k8s.io/snapshotter-secret-namespace": namespace,
"csi.storage.k8s.io/snapshotter-list-secret-name": storageClassCredentialsRef,
"csi.storage.k8s.io/snapshotter-list-secret-namespace": namespace,
"snapshot.storage.kubernetes.io/deletion-secret-name": storageClassCredentialsRef,
"snapshot.storage.kubernetes.io/deletion-secret-namespace": namespace,
}
return nil
})
if err != nil {
return err
log.Info("storageclass", "name", sc.Name, "operation", op)

// Snapshot Volume Class
snapannotations := map[string]string{
"snapshot.storage.kubernetes.io/is-default-class": "true",
metaltag.ClusterDescription: "DO NOT EDIT - This resource is managed by duros-controller. Any modifications are discarded and the resource is returned to the original state.",
}
snapobj := &snapshotv1.VolumeSnapshotClass{ObjectMeta: metav1.ObjectMeta{Name: "partition-snapshot"}}
op, err := controllerutil.CreateOrUpdate(ctx, r.Shoot, snapobj, func() error {
snapobj.ObjectMeta.Annotations = snapannotations
snapobj.Driver = provisioner
snapobj.DeletionPolicy = snapshotv1.VolumeSnapshotContentDelete
snapobj.Parameters = map[string]string{
"csi.storage.k8s.io/snapshotter-secret-name": storageClassCredentialsRef,
"csi.storage.k8s.io/snapshotter-secret-namespace": namespace,
"csi.storage.k8s.io/snapshotter-list-secret-name": storageClassCredentialsRef,
"csi.storage.k8s.io/snapshotter-list-secret-namespace": namespace,
"snapshot.storage.kubernetes.io/deletion-secret-name": storageClassCredentialsRef,
"snapshot.storage.kubernetes.io/deletion-secret-namespace": namespace,
}
log.Info("snapshotstorageclass", "name", obj.ObjectMeta.Name, "operation", op)
return nil
})
if err != nil {
return err
}
log.Info("snapshotstorageclass", "name", snapobj.ObjectMeta.Name, "operation", op)

log.Info("storageclass", "name", sc.Name, "operation", op)
}

return nil
Expand Down
31 changes: 15 additions & 16 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,25 @@ go 1.21

require (
github.com/go-logr/logr v1.3.0
github.com/go-logr/zapr v1.2.4
github.com/go-logr/zapr v1.3.0
github.com/golang-jwt/jwt/v4 v4.5.0
github.com/kubernetes-csi/external-snapshotter/client/v6 v6.2.0
github.com/metal-stack/duros-go v0.4.3
github.com/metal-stack/metal-lib v0.13.5
github.com/metal-stack/metal-lib v0.14.1
github.com/metal-stack/v v1.0.3
go.uber.org/zap v1.26.0
google.golang.org/grpc v1.59.0
k8s.io/api v0.26.10
k8s.io/apimachinery v0.27.4
k8s.io/apimachinery v0.28.2
k8s.io/client-go v0.26.10
k8s.io/utils v0.0.0-20230505201702-9f6742963106
sigs.k8s.io/controller-runtime v0.14.6
)

require (
github.com/Masterminds/semver/v3 v3.2.1 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
github.com/evanphx/json-patch/v5 v5.7.0 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
Expand All @@ -48,26 +47,26 @@ require (
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/onsi/ginkgo/v2 v2.13.0 // indirect
github.com/onsi/gomega v1.29.0 // indirect
github.com/onsi/ginkgo/v2 v2.13.2 // indirect
github.com/onsi/gomega v1.30.0 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/prometheus/client_golang v1.17.0 // indirect
github.com/prometheus/client_model v0.5.0 // indirect
github.com/prometheus/common v0.45.0 // indirect
github.com/prometheus/procfs v0.12.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/net v0.17.0 // indirect
golang.org/x/oauth2 v0.13.0 // indirect
golang.org/x/sys v0.13.0 // indirect
golang.org/x/term v0.13.0 // indirect
golang.org/x/text v0.13.0 // indirect
golang.org/x/time v0.3.0 // indirect
golang.org/x/net v0.19.0 // indirect
golang.org/x/oauth2 v0.15.0 // indirect
golang.org/x/sys v0.15.0 // indirect
golang.org/x/term v0.15.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/time v0.5.0 // indirect
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/genproto v0.0.0-20231030173426-d783a09b4405 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20231030173426-d783a09b4405 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20231030173426-d783a09b4405 // indirect
google.golang.org/genproto v0.0.0-20231127180814-3a041ad873d4 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20231127180814-3a041ad873d4 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20231127180814-3a041ad873d4 // indirect
google.golang.org/protobuf v1.31.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
Expand Down
Loading