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

detect minio image based on the kurl or existing instance #2527

Merged
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
12 changes: 11 additions & 1 deletion pkg/image/minio.go
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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