This repository has been archived by the owner on Nov 9, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 163
143 lines (123 loc) · 4.88 KB
/
main.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
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