Skip to content

Commit

Permalink
detect minio image based on the kurl or existing instance (#2527)
Browse files Browse the repository at this point in the history
  • Loading branch information
jala-dx committed Feb 13, 2022
1 parent 8d6568b commit 8985152
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
12 changes: 11 additions & 1 deletion pkg/image/minio.go
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions pkg/snapshot/filesystem.go
Expand Up @@ -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")
}
Expand Down Expand Up @@ -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")
}
Expand Down

0 comments on commit 8985152

Please sign in to comment.