From 1e5be596f1a884ab6a8368f3f609459406bece6d Mon Sep 17 00:00:00 2001 From: Jalaja Date: Sat, 12 Feb 2022 01:44:46 +0000 Subject: [PATCH] detect minio image based on the kurl or existing instance --- pkg/image/minio.go | 12 +++++++++++- pkg/snapshot/filesystem.go | 4 ++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/pkg/image/minio.go b/pkg/image/minio.go index 79220aa725..b502e04561 100644 --- a/pkg/image/minio.go +++ b/pkg/image/minio.go @@ -5,12 +5,22 @@ import ( "fmt" "strings" + "github.com/replicatedhq/kots/pkg/kotsutil" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/client-go/kubernetes" ) // MinioImage looks through the nodes in the cluster and finds nodes that have already pulled Minio, and then finds the latest image tag listed -func MinioImage(clientset kubernetes.Interface) (string, error) { +func GetMinioImage(clientset kubernetes.Interface, kotsadmNamespace string) (string, error) { + /* + * In existing install with limited RBAC, kotsadm does not have previliges to run Nodes() API. + * If it is a kurl instance, then use search logic to find the best minio image. + * If it is not a kurl instance, return the static image name present in the bundle. + */ + if !kotsutil.IsKurl(clientset) || kotsadmNamespace != metav1.NamespaceDefault { + return Minio, nil + } + nodes, err := clientset.CoreV1().Nodes().List(context.TODO(), metav1.ListOptions{}) if err != nil { return "", fmt.Errorf("failed to list nodes with minio image: %w", err) diff --git a/pkg/snapshot/filesystem.go b/pkg/snapshot/filesystem.go index aa1c2507af..2912b4272e 100644 --- a/pkg/snapshot/filesystem.go +++ b/pkg/snapshot/filesystem.go @@ -276,7 +276,7 @@ func ensureFileSystemMinioDeployment(ctx context.Context, clientset kubernetes.I } func fileSystemMinioDeploymentResource(clientset kubernetes.Interface, secretChecksum string, deployOptions FileSystemDeployOptions, registryOptions kotsadmtypes.KotsadmOptions) (*appsv1.Deployment, error) { - existingImage, err := image.MinioImage(clientset) + existingImage, err := image.GetMinioImage(clientset, deployOptions.Namespace) if err != nil { return nil, errors.Wrap(err, "failed to find minio image") } @@ -1089,7 +1089,7 @@ func IsFileSystemMinioDisabled(kotsadmNamespace string) (bool, error) { //Minio disabled is detected based on two cases // 1. minio image is not present in the cluster // 2. disableS3 flag is enabled - minioImage, err := image.MinioImage(clientset) + minioImage, err := image.GetMinioImage(clientset, kotsadmNamespace) if err != nil { return false, errors.Wrap(err, "failed to check minio image") }