Skip to content

Commit

Permalink
done
Browse files Browse the repository at this point in the history
  • Loading branch information
Praveenrajmani committed Oct 1, 2024
1 parent bd82e2e commit 14c5b8e
Show file tree
Hide file tree
Showing 35 changed files with 83 additions and 134 deletions.
72 changes: 72 additions & 0 deletions functests/migration-tests-kustomize.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#!/usr/bin/env bash
#
# This file is part of MinIO DirectPV
# Copyright (c) 2022 MinIO, Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

if [ "$#" -ne 1 ]; then
echo "usage: migration-tests-kustomize.sh <DIRECTCSI-VERSION>"
exit 255
fi

LEGACY_VERSION="$1"
LEGACY_FILE="kubectl-direct_csi_${LEGACY_VERSION:1}_linux_amd64"

set -ex

# shellcheck source=/dev/null
source "common.sh"

sed -e s:directpv-min-io:direct-csi-min-io:g -e s:directpv.min.io:direct.csi.min.io:g minio.yaml > directcsi-minio.yaml

# usage: migrate_test <plugin> <legacy-pod-count>
function migrate_test() {
directcsi_client="$1"
legacy_pod_count=$(( $2 + ACTIVE_NODES - 1 ))
pod_count=$(( 6 + ACTIVE_NODES * 2 ))

setup_lvm
setup_luks

install_directcsi "${directcsi_client}" "${legacy_pod_count}"

"${directcsi_client}" drives format --all --force

deploy_minio directcsi-minio.yaml

uninstall_directcsi "${directcsi_client}" "${legacy_pod_count}"

install_directpv_kustomize "${DIRECTPV_DIR}/kubectl-directpv" "${pod_count}" "true"

delete_minio directcsi-minio.yaml

deploy_minio directcsi-minio.yaml

uninstall_minio "${DIRECTPV_DIR}/kubectl-directpv" directcsi-minio.yaml

force_uninstall_directcsi "${directcsi_client}"

remove_drives "${DIRECTPV_DIR}/kubectl-directpv"
uninstall_directpv "${DIRECTPV_DIR}/kubectl-directpv" "${pod_count}" "true"

unmount_directpv

remove_luks
remove_lvm
}

curl --silent --location --insecure --fail --output "${LEGACY_FILE}" "https://github.com/minio/directpv/releases/download/${LEGACY_VERSION}/${LEGACY_FILE}"
chmod a+x "${LEGACY_FILE}"
migrate_test "./${LEGACY_FILE}" 4
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ apiVersion: storage.k8s.io/v1
kind: CSIDriver
metadata:
annotations:
directpv.min.io/plugin-version: v4.0.10
creationTimestamp: null
labels:
application-name: directpv.min.io
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
annotations:
directpv.min.io/plugin-version: v4.0.10
rbac.authorization.kubernetes.io/autoupdate: "true"
creationTimestamp: null
labels:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
annotations:
directpv.min.io/plugin-version: v4.0.10
rbac.authorization.kubernetes.io/autoupdate: "true"
creationTimestamp: null
labels:
Expand Down
3 changes: 0 additions & 3 deletions operator/helm-charts/directpv-chart/templates/DaemonSet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
apiVersion: apps/v1
kind: DaemonSet
metadata:
annotations:
directpv.min.io/image-tag: v4.0.10
directpv.min.io/plugin-version: v4.0.10
creationTimestamp: null
labels:
application-name: directpv.min.io
Expand Down
3 changes: 0 additions & 3 deletions operator/helm-charts/directpv-chart/templates/Deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
directpv.min.io/image-tag: v4.0.10
directpv.min.io/plugin-version: v4.0.10
creationTimestamp: null
labels:
application-name: directpv.min.io
Expand Down
2 changes: 0 additions & 2 deletions operator/helm-charts/directpv-chart/templates/Namespace.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
apiVersion: v1
kind: Namespace
metadata:
annotations:
directpv.min.io/plugin-version: v4.0.10
creationTimestamp: null
finalizers:
- foregroundDeletion
Expand Down
1 change: 0 additions & 1 deletion operator/helm-charts/directpv-chart/templates/Role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
annotations:
directpv.min.io/plugin-version: v4.0.10
rbac.authorization.kubernetes.io/autoupdate: "true"
creationTimestamp: null
labels:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
annotations:
directpv.min.io/plugin-version: v4.0.10
rbac.authorization.kubernetes.io/autoupdate: "true"
creationTimestamp: null
labels:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ apiVersion: v1
kind: ServiceAccount
metadata:
annotations:
directpv.min.io/plugin-version: v4.0.10
creationTimestamp: null
labels:
application-name: directpv.min.io
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ allowedTopologies:
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
annotations:
directpv.min.io/plugin-version: v4.0.10
creationTimestamp: null
finalizers:
- foregroundDeletion
Expand Down
10 changes: 0 additions & 10 deletions pkg/admin/installer/args.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"fmt"
"io"
"path"
"regexp"

"github.com/minio/directpv/pkg/utils"
corev1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -80,18 +79,10 @@ type Args struct {
nodeDriverRegistrarImage string
livenessProbeImage string
csiResizerImage string
imageTag string
}

var imageTagRegex = regexp.MustCompile(`:([^/]+)$`)

// NewArgs creates arguments for DirectPV installation.
func NewArgs(image string) *Args {
imageTag := "dev"
matchIndex := imageTagRegex.FindStringSubmatchIndex(image)
if len(matchIndex) > 0 && len(image) > matchIndex[0]+1 {
imageTag = image[matchIndex[0]+1:]
}
return &Args{
image: image,
Registry: "quay.io",
Expand All @@ -101,7 +92,6 @@ func NewArgs(image string) *Args {
nodeDriverRegistrarImage: nodeDriverRegistrarImage,
livenessProbeImage: livenessProbeImage,
csiResizerImage: csiResizerImage,
imageTag: imageTag,
}
}

Expand Down
11 changes: 2 additions & 9 deletions pkg/admin/installer/csidriver.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"errors"
"fmt"

directpvtypes "github.com/minio/directpv/pkg/apis/directpv.min.io/types"
"github.com/minio/directpv/pkg/client"
"github.com/minio/directpv/pkg/consts"
legacyclient "github.com/minio/directpv/pkg/legacy/client"
Expand Down Expand Up @@ -95,10 +94,7 @@ func (t csiDriverTask) doCreateCSIDriver(ctx context.Context, args *Args, versio
ObjectMeta: metav1.ObjectMeta{
Name: name,
Namespace: metav1.NamespaceNone,
Annotations: map[string]string{
string(directpvtypes.PluginVersionLabelKey): args.PluginVersion,
},
Labels: defaultLabels,
Labels: defaultLabels,
},
Spec: storagev1.CSIDriverSpec{
PodInfoOnMount: &podInfoOnMount,
Expand Down Expand Up @@ -128,10 +124,7 @@ func (t csiDriverTask) doCreateCSIDriver(ctx context.Context, args *Args, versio
ObjectMeta: metav1.ObjectMeta{
Name: name,
Namespace: metav1.NamespaceNone,
Annotations: map[string]string{
string(directpvtypes.PluginVersionLabelKey): args.PluginVersion,
},
Labels: defaultLabels,
Labels: defaultLabels,
},
Spec: storagev1beta1.CSIDriverSpec{
PodInfoOnMount: &podInfoOnMount,
Expand Down
7 changes: 1 addition & 6 deletions pkg/admin/installer/daemonset.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"context"
"fmt"

directpvtypes "github.com/minio/directpv/pkg/apis/directpv.min.io/types"
"github.com/minio/directpv/pkg/client"
"github.com/minio/directpv/pkg/consts"
"github.com/minio/directpv/pkg/k8s"
Expand Down Expand Up @@ -215,11 +214,7 @@ func newDaemonset(podSpec corev1.PodSpec, name, selectorValue string, args *Args
ObjectMeta: metav1.ObjectMeta{
Name: name,
Namespace: namespace,
Annotations: map[string]string{
string(directpvtypes.ImageTagLabelKey): args.imageTag,
string(directpvtypes.PluginVersionLabelKey): args.PluginVersion,
},
Labels: defaultLabels,
Labels: defaultLabels,
},
Spec: appsv1.DaemonSetSpec{
Selector: metav1.AddLabelToSelector(&metav1.LabelSelector{}, selectorKey, selectorValue),
Expand Down
7 changes: 1 addition & 6 deletions pkg/admin/installer/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"context"
"fmt"

directpvtypes "github.com/minio/directpv/pkg/apis/directpv.min.io/types"
"github.com/minio/directpv/pkg/client"
"github.com/minio/directpv/pkg/consts"
"github.com/minio/directpv/pkg/k8s"
Expand Down Expand Up @@ -207,11 +206,7 @@ func (t deploymentTask) doCreateDeployment(ctx context.Context, args *Args, lega
ObjectMeta: metav1.ObjectMeta{
Name: name,
Namespace: namespace,
Annotations: map[string]string{
string(directpvtypes.ImageTagLabelKey): args.imageTag,
string(directpvtypes.PluginVersionLabelKey): args.PluginVersion,
},
Labels: defaultLabels,
Labels: defaultLabels,
},
Spec: appsv1.DeploymentSpec{
Replicas: &replicas,
Expand Down
8 changes: 2 additions & 6 deletions pkg/admin/installer/namespace.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package installer
import (
"context"

directpvtypes "github.com/minio/directpv/pkg/apis/directpv.min.io/types"
"github.com/minio/directpv/pkg/client"
corev1 "k8s.io/api/core/v1"
apierrors "k8s.io/apimachinery/pkg/api/errors"
Expand Down Expand Up @@ -90,11 +89,8 @@ func (t namespaceTask) createNamespace(ctx context.Context, args *Args) (err err
Kind: "Namespace",
},
ObjectMeta: metav1.ObjectMeta{
Name: namespace,
Namespace: metav1.NamespaceNone,
Annotations: map[string]string{
string(directpvtypes.PluginVersionLabelKey): args.PluginVersion,
},
Name: namespace,
Namespace: metav1.NamespaceNone,
Labels: labels,
Finalizers: []string{metav1.FinalizerDeleteDependents},
},
Expand Down
10 changes: 1 addition & 9 deletions pkg/admin/installer/rbac.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package installer
import (
"context"

directpvtypes "github.com/minio/directpv/pkg/apis/directpv.min.io/types"
"github.com/minio/directpv/pkg/client"
"github.com/minio/directpv/pkg/consts"
corev1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -99,10 +98,7 @@ func (t rbacTask) createServiceAccount(ctx context.Context, args *Args) (err err
ObjectMeta: metav1.ObjectMeta{
Name: consts.Identity,
Namespace: namespace,
Annotations: map[string]string{
string(directpvtypes.PluginVersionLabelKey): args.PluginVersion,
},
Labels: defaultLabels,
Labels: defaultLabels,
},
Secrets: []corev1.ObjectReference{},
ImagePullSecrets: []corev1.LocalObjectReference{},
Expand Down Expand Up @@ -142,7 +138,6 @@ func (t rbacTask) createClusterRole(ctx context.Context, args *Args) (err error)
Namespace: metav1.NamespaceNone,
Annotations: map[string]string{
"rbac.authorization.kubernetes.io/autoupdate": "true",
string(directpvtypes.PluginVersionLabelKey): args.PluginVersion,
},
Labels: defaultLabels,
},
Expand Down Expand Up @@ -209,7 +204,6 @@ func (t rbacTask) createClusterRoleBinding(ctx context.Context, args *Args) (err
Namespace: metav1.NamespaceNone,
Annotations: map[string]string{
"rbac.authorization.kubernetes.io/autoupdate": "true",
string(directpvtypes.PluginVersionLabelKey): args.PluginVersion,
},
Labels: defaultLabels,
},
Expand Down Expand Up @@ -260,7 +254,6 @@ func (t rbacTask) createRole(ctx context.Context, args *Args) (err error) {
Namespace: namespace,
Annotations: map[string]string{
"rbac.authorization.kubernetes.io/autoupdate": "true",
string(directpvtypes.PluginVersionLabelKey): args.PluginVersion,
},
Labels: defaultLabels,
},
Expand Down Expand Up @@ -302,7 +295,6 @@ func (t rbacTask) createRoleBinding(ctx context.Context, args *Args) (err error)
Namespace: namespace,
Annotations: map[string]string{
"rbac.authorization.kubernetes.io/autoupdate": "true",
string(directpvtypes.PluginVersionLabelKey): args.PluginVersion,
},
Labels: defaultLabels,
},
Expand Down
14 changes: 4 additions & 10 deletions pkg/admin/installer/storageclass.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,8 @@ func (t storageClassTask) doCreateStorageClass(ctx context.Context, args *Args,
storageClass := &storagev1.StorageClass{
TypeMeta: metav1.TypeMeta{APIVersion: "storage.k8s.io/v1", Kind: "StorageClass"},
ObjectMeta: metav1.ObjectMeta{
Name: name,
Namespace: metav1.NamespaceNone,
Annotations: map[string]string{
string(directpvtypes.PluginVersionLabelKey): args.PluginVersion,
},
Name: name,
Namespace: metav1.NamespaceNone,
Labels: defaultLabels,
Finalizers: []string{metav1.FinalizerDeleteDependents},
},
Expand Down Expand Up @@ -135,11 +132,8 @@ func (t storageClassTask) doCreateStorageClass(ctx context.Context, args *Args,
storageClass := &storagev1beta1.StorageClass{
TypeMeta: metav1.TypeMeta{APIVersion: "storage.k8s.io/v1beta1", Kind: "StorageClass"},
ObjectMeta: metav1.ObjectMeta{
Name: name,
Namespace: metav1.NamespaceNone,
Annotations: map[string]string{
string(directpvtypes.PluginVersionLabelKey): args.PluginVersion,
},
Name: name,
Namespace: metav1.NamespaceNone,
Labels: defaultLabels,
Finalizers: []string{metav1.FinalizerDeleteDependents},
},
Expand Down
8 changes: 0 additions & 8 deletions pkg/apis/directpv.min.io/types/label.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,6 @@ const (

// ClaimIDLabelKey label key to denote the claim id of the volumes
ClaimIDLabelKey LabelKey = consts.GroupName + "/claim-id"

// ImageTagLabelKey denotes the tag of the directpv container image
ImageTagLabelKey LabelKey = consts.GroupName + "/image-tag"

// PluginVersionLabelKey denotes the plugin version
PluginVersionLabelKey LabelKey = consts.GroupName + "/plugin-version"
)

var reservedLabelKeys = map[LabelKey]struct{}{
Expand All @@ -115,8 +109,6 @@ var reservedLabelKeys = map[LabelKey]struct{}{
SuspendLabelKey: {},
VolumeClaimIDLabelKey: {},
ClaimIDLabelKey: {},
ImageTagLabelKey: {},
PluginVersionLabelKey: {},
}

// IsReserved returns if the key is a reserved key
Expand Down
Loading

0 comments on commit 14c5b8e

Please sign in to comment.