Skip to content

Commit

Permalink
Basic Tenant deployment script (#953)
Browse files Browse the repository at this point in the history
Co-authored-by: cniackz <cniackz@cniackzs-MacBook-Air.local>
  • Loading branch information
dvaldivia and cniackz authored Jan 5, 2022
1 parent 7a5e842 commit 7e1998d
Show file tree
Hide file tree
Showing 3 changed files with 133 additions and 0 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/bash.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# This is a basic workflow to execute our Tenant deployment script

name: Bash

# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the main branch
push:
branches: [ master ]
pull_request:
branches: [ master ]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2

# Runs a set of commands using the runners shell
- name: Run a multi-line script
run: |
chmod 755 "${GITHUB_WORKSPACE}/testing/basic-tenant.sh"
cd "${GITHUB_WORKSPACE}/testing/"
"${GITHUB_WORKSPACE}/testing/basic-tenant.sh"
91 changes: 91 additions & 0 deletions testing/basic-tenant.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
#!/bin/bash

# Copyright (C) 2022, MinIO, Inc.
#
# This code is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License, version 3,
# as published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License, version 3,
# along with this program. If not, see <http://www.gnu.org/licenses/>

# This script requires: kubectl, kind

yell() { echo "$0: $*" >&2; }

die() {
yell "$*"
(kind delete cluster || true ) && exit 111
}

try() { "$@" || die "cannot $*"; }

try kind create cluster --config kind-config.yaml

echo "Installing Current Operator"

# TODO: Compile the current branch and create an overlay to use that image version
try kubectl apply -k ../resources

echo "Waiting for Operator Pods to come online"

try kubectl wait --namespace minio-operator \
--for=condition=ready pod \
--selector=name=minio-operator \
--timeout=90s

echo "Installing lite tenant"

try kubectl apply -k ../examples/kustomization/tenant-lite


echo "Waiting for the tenant statefulset, this indicates the tenant is being fulfilled"
waitdone=0
totalwait=0
while true; do
waitdone=$(kubectl -n tenant-lite get pods -l v1.min.io/tenant=storage-lite --no-headers | wc -l)
if [ "$waitdone" -ne 0 ]; then
echo "Found $waitdone pods"
break
fi
sleep 5
totalwait=$((totalwait + 5))
if [ "$totalwait" -gt 300 ]; then
echo "Tenant never created statefulset after 5 minutes"
try false
fi
done

echo "Waiting for tenant pods to come online (5m timeout)"
try kubectl wait --namespace tenant-lite \
--for=condition=ready pod \
--selector="v1.min.io/tenant=storage-lite" \
--timeout=300s

echo "Build passes basic tenant creation"

# Check MinIO is accessible

waitdone=0
totalwait=0
while true; do
waitdone=$(kubectl -n tenant-lite get pods -l v1.min.io/tenant=storage-lite --no-headers | wc -l)
if [ "$waitdone" -ne 0 ]; then
echo "Found $waitdone pods"
break
fi
sleep 5
totalwait=$((totalwait + 5))
if [ "$totalwait" -gt 305 ]; then
echo "Unable to create tenant after 5 minutes, exiting."
try false
fi
done

# clean up
kind delete cluster
9 changes: 9 additions & 0 deletions testing/kind-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# four node (two workers) cluster config
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
- role: worker
- role: worker
- role: worker
- role: worker

0 comments on commit 7e1998d

Please sign in to comment.