This repository has been archived by the owner on Nov 9, 2023. It is now read-only.
Archive Lab #223
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: MiniFab CI | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
# 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 | |
continue-on-error: true | |
strategy: | |
matrix: | |
fabric: ['1.4.4', '1.4.6', '1.4.8', '1.4.12', | |
'2.0.0', | |
'2.1.0', | |
'2.2', '2.2.0', '2.2.3', '2.2.4', | |
'2.3', '2.3.2', '2.3.3', | |
'2.4'] | |
# 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@v3 | |
- name: 'Build up the minifabric container' | |
run: docker build -t hyperledgerlabs/minifab:latest . | |
- name: 'Setup minifabric network' | |
run: ./minifab up -i ${{ matrix.fabric }} -f default | |
- name: 'Tear down the network' | |
run: ./minifab cleanup | |
operator: | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Start up kind k8s cluster | |
uses: helm/[email protected] | |
with: | |
cluster_name: kind | |
- name: Label node and deploy metallb | |
run: | | |
kubectl label nodes kind-control-plane ingress-ready="true" | |
kubectl apply -f https://raw.githubusercontent.com/metallb/metallb/v0.13.5/config/manifests/metallb-native.yaml | |
- name: Wait for the metallb to be ready | |
run: | | |
while : ; do | |
res=$(kubectl wait --context "kind-kind" -n metallb-system pod \ | |
-l component=controller,app=metallb --for=condition=Ready --timeout=120s 2>/dev/null ||true) | |
if [[ "${res}" == *"condition met"* ]]; then | |
break | |
fi | |
echo 'Waiting for metallb to be ready...' | |
sleep 15 | |
done | |
- name: Setup metallb public ip range | |
run: | | |
PREFIX=$(docker network inspect -f '{{range .IPAM.Config }}{{ .Gateway }}{{end}}' kind | cut -d '.' -f1,2) | |
cat <<EOF | kubectl apply -f - | |
apiVersion: metallb.io/v1beta1 | |
kind: IPAddressPool | |
metadata: | |
namespace: metallb-system | |
name: address-pool | |
spec: | |
addresses: | |
- $PREFIX.255.230-$PREFIX.255.240 | |
EOF | |
- name: Ensure the kube configuration for the cluster is not using loopback ip as part of the api server endpoint | |
run: | | |
while : ; do | |
ip=$(docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' kind-control-plane) | |
if [[ -n "${ip}" ]]; then | |
#Change the kubeconfig file not to use the loopback IP | |
kubectl config set clusters.kind-kind.server https://"${ip}":6443 | |
break | |
fi | |
echo 'Waiting for public IP address to be available...' | |
sleep 3 | |
done | |
- name: Deploy the nginx ingress controller | |
run: kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v1.4.0/deploy/static/provider/cloud/deploy.yaml | |
- name: Wait for the controller to have the external IP | |
run: | | |
for ((x=0;x<30;x++)); do | |
ENDPOINT=$(kubectl get -n ingress-nginx service/ingress-nginx-controller -o jsonpath='{.status.loadBalancer.ingress}') | |
if [[ ! -z $ENDPOINT ]]; then | |
break | |
fi | |
echo -e ${Green}Waiting${ColorOff} for Nginx Ingress Controller to be ready... | |
sleep 5 | |
done | |
- name: copy kubeconfig to vars/kubeconfig and copy minifab script with "--network kind" | |
run: | | |
mkdir vars | |
mkdir vars/kubeconfig | |
cp ~/.kube/config vars/kubeconfig/ | |
cp tests/minifab . | |
- name: Up minifabric network | |
run: ./minifab netup -e true -a K8SOPERATOR | |
- name: Deploy fabric operator | |
run: ./minifab deployoperator | |
- name: Copy sample nodes and create testing namespace | |
run: | | |
cp -r tests/nodespecs vars | |
kubectl create namespace testing | |
- name: Deploy nodes | |
run: ./minifab deploynodes | |
- name: Check node status | |
run: | | |
for POD in `kubectl get pods --namespace testing --no-headers -o custom-columns=":metadata.name"`; do | |
STATUS=$(kubectl get --namespace testing -o template pod/${POD} --template={{.status.phase}}) | |
if [[ "$STATUS" != "Running" ]]; then | |
echo "::error ::${POD} is not running, it is currently ${STATUS}" | |
exit 1 | |
else | |
echo "${POD} is running." | |
fi | |
done |