DEV Community

Said Olano
Said Olano

Posted on

Can minikube point to multiple clusters?

Yes, minikube can point to multiple clusters.

In my local environment, I normally deploy Java Apps (Spring Boot Apps) to different Cloud providers such as Oracle, AWS, Google, and Microsoft Azure. The way to easily switch between Kubernetes environments across multiple Clouds is by using a single file.

Here comes the explanation:

I can point to my local Minikube instance, which is used to run Java apps on GCP, and other cluster contexts, such as AWS EKS, where I run Java Spring Boot apps using AWS RDS databases.

How can I switch between one and the other with one simple command?
The answer is simple: a SH script file to switch between contexts...

See:

#!/bin/bash

case "$1" in
  minikube)
    kubectl config use-context fast-minikube
    echo "✅ Cambiaste al contexto: fast-minikube (local)"
    ;;
  eks)
    kubectl config use-context arn:aws:eks:us-east-1:1234567890:cluster/eks-springboot-lab-cluster
    echo "✅ Cambiaste al contexto: arn:aws:eks:us-east-1:1234567890:cluster/eks-springboot-lab-cluster (AWS)"
    ;;
  azure)
    kubectl config use-context azure: cluster/eks-springboot-lab-cluster
    echo "✅ Cambiaste al contexto: azure:cluster/eks-springboot-lab-cluster"
    ;;
  google)
    kubectl config use-context google: cluster/eks-springboot-lab-cluster
    echo "✅ Cambiaste al contexto: google:cluster/eks-springboot-lab-cluster"
    ;;

  current)
    kubectl config current-context
    ;;
  list)
    kubectl config get-contexts
    ;;
  *)
    echo "Uso: $0 { minikube | eks | current | list }"
    ;;
esac
Enter fullscreen mode Exit fullscreen mode

Here is the picture with its usage:

Top comments (0)