github.com/kotalco/kotal@v0.3.0/multi.sh (about)

     1  #!/bin/sh
     2  
     3  set -e
     4  
     5  K8S_PROVIDER="${K8S_PROVIDER:-kind}"
     6  
     7  
     8  function cleanup {
     9    echo "🧽 Cleaning up"
    10    if [ "$K8S_PROVIDER" == "minikube" ]
    11      then
    12        minikube delete --all
    13      else
    14        kind delete clusters --all
    15    fi
    16  }
    17  
    18  trap cleanup EXIT
    19  
    20  if ! docker info > /dev/null 2>&1; then
    21    echo "Docker isn't running"
    22    echo "Start docker, then try again!"
    23    exit 1
    24  fi
    25  
    26  if [ "$KOTAL_VERSION" == "" ]
    27  then
    28    # build manager image once
    29    echo "Building docker image"
    30    make docker-build
    31  fi
    32  
    33  
    34  if [ "$K8S_PROVIDER" == "minikube" ]
    35  then
    36  # minikube cluster versions
    37  VERSIONS=("1.19.0" "1.20.0" "1.21.0" "1.22.0" "1.23.0" "1.24.0" "1.25.0" "1.26.0")
    38  echo "🗑 Deleting all Minikube clusters"
    39  minikube delete --all
    40  else
    41  # kind cluster versions
    42  # https://hub.docker.com/r/kindest/node/tags
    43  VERSIONS=("1.19.16" "1.20.15" "1.21.14" "1.22.17" "1.23.17" "1.24.15" "1.25.11" "1.26.6" "1.27.3" "1.28.0" "1.29.0")
    44  echo "🗑 Deleting all Kind clusters"
    45  kind delete clusters --all
    46  fi
    47  
    48  for VERSION in "${VERSIONS[@]}"
    49  do
    50    echo "Testing Kotal operator in kubernetes v$VERSION"
    51      # start Kubernetes in Docker with this kubernetes version
    52      echo "Creating cluster"
    53      if [ "$K8S_PROVIDER" == "minikube" ]
    54      then
    55        minikube start --kubernetes-version=v${VERSION}
    56      else
    57  	    kind create cluster --image=kindest/node:v${VERSION}
    58      fi
    59      # install cert-manager
    60      echo "Installing cert manager"
    61      kubectl apply -f https://github.com/jetstack/cert-manager/releases/download/v1.5.3/cert-manager.yaml
    62      # load image and deploy manifests
    63      echo "⏳ Waiting for cert manager to be up and running"
    64      sleep 5
    65      kubectl wait -n cert-manager --for=condition=available deployments/cert-manager --timeout=600s
    66      kubectl wait -n cert-manager --for=condition=available deployments/cert-manager-cainjector --timeout=600s
    67      kubectl wait -n cert-manager --for=condition=available deployments/cert-manager-webhook --timeout=600s
    68      echo "🚀 Cert manager is up and running"
    69  
    70      if [ "$KOTAL_VERSION" == "" ]
    71      then
    72        echo "Installing Kotal custom resources"
    73        echo "Deploying Kotal controller manager"
    74        if [ "$K8S_PROVIDER" == "minikube" ]
    75        then
    76          make minikube
    77        else
    78          make kind
    79        fi
    80      else
    81        kubectl apply -f https://github.com/kotalco/kotal/releases/download/$KOTAL_VERSION/kotal.yaml
    82      fi
    83  
    84      echo "⏳ Waiting for kotal controller manager to be up and running"
    85      kubectl wait -n kotal --for=condition=available deployments/controller-manager --timeout=600s
    86      echo "🚀 Kotal is up and running"
    87  
    88      echo "🔥 Running tests"
    89      # test against image
    90      USE_EXISTING_CLUSTER=true make test
    91      # delete cluster
    92      echo "🎉 All tests has been passed"
    93  
    94      echo "🔥 Deleting kubernetes cluster v$VERSION"
    95      if [ "$K8S_PROVIDER" == "minikube" ]
    96      then
    97        minikube delete
    98      else
    99        kind delete cluster
   100      fi
   101  done