-
Notifications
You must be signed in to change notification settings - Fork 38
146 lines (144 loc) · 11.4 KB
/
CI.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
144
145
146
# workflow name
name: CI
# on events
on:
push:
branches:
- master
pull_request:
branches:
- master
env:
PACKET_TOKEN: ${{ secrets.PACKET_TOKEN }}
# jobs to run
jobs:
check:
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.20
uses: actions/setup-go@v2
with:
go-version: "1.20"
id: go
- name: Get current date
id: date
run: echo "::set-output name=date::$(date +'%Y%m%d%H%M%S')"
- name: Get output
run: echo ${{ steps.date.outputs.date }}
- name: Set env
run: echo "CLUSTER_NAME=pravega-operator-travis-${{ steps.date.outputs.date }}" >> $GITHUB_ENV
- name: Test
run: echo $CLUSTER_NAME
- name: Check out code into the Go module directory
uses: actions/checkout@v2
- name: Gofmt and License checks
run: make check
- name: unit tests
run: make test-unit
- name: Codecov
uses: codecov/codecov-action@v1.0.12
- name: Installing Packet-cli
run: curl -Lo packet-cli https://github.com/packethost/packet-cli/releases/download/0.0.7/packet-linux-amd64 && chmod +x packet-cli && sudo mv packet-cli /usr/local/bin/
- name: Installing ssh keys
run: |
ssh-keygen -f ~/.ssh/id_rsa -P ""
pub_key=$(cat ~/.ssh/id_rsa.pub)
echo "publc key is $pub_key"
echo "packet-cli ssh-key create --key \"$(cat ~/.ssh/id_rsa.pub)\" --label \"pravega\""
packet-cli ssh-key create --key "$(cat ~/.ssh/id_rsa.pub)" --label "pravega-travis"
- name: Creating nodes
run: |
cd .. && tar -czvf pravega-operator.tar.gz pravega-operator
packet-cli device create -H $CLUSTER_NAME"-master" -o "ubuntu_20_04" -P c3.medium.x86 -p 454b8b42-33d3-4e7e-8acf-1d1a5fec7e85 -f da11
packet-cli device get -p 454b8b42-33d3-4e7e-8acf-1d1a5fec7e85 | grep $CLUSTER_NAME"-master" | awk '{print $2}'
CLUSTER_ID=$(packet-cli device get -p 454b8b42-33d3-4e7e-8acf-1d1a5fec7e85 | grep $CLUSTER_NAME"-master" | awk '{print $2}' | tr -d ' ')
echo "cluster id is $CLUSTER_ID"
packet-cli device create -H $CLUSTER_NAME"-worker1" -o "ubuntu_20_04" -P c3.medium.x86 -p 454b8b42-33d3-4e7e-8acf-1d1a5fec7e85 -f da11
packet-cli device create -H $CLUSTER_NAME"-worker2" -o "ubuntu_20_04" -P c3.medium.x86 -p 454b8b42-33d3-4e7e-8acf-1d1a5fec7e85 -f da11
MASTER_STATE=$(packet-cli device get -p 454b8b42-33d3-4e7e-8acf-1d1a5fec7e85 | grep $CLUSTER_NAME"-master" | awk '{print $10}' | tr -d ' ')
while [ "$MASTER_STATE" != "active" ]; do MASTER_STATE=`packet-cli device get -p 454b8b42-33d3-4e7e-8acf-1d1a5fec7e85 | grep $CLUSTER_NAME"-master" | awk '{print $10}' | tr -d ' '`;sleep 30;done
CLUSTER_IP=$(packet-cli device get -i $CLUSTER_ID -y | grep "\- address:" | head -1 |awk '{print $3}' | tr -d ' ')
echo "Cluster IP is $CLUSTER_IP"
WORKER1_STATE=$(packet-cli device get -p 454b8b42-33d3-4e7e-8acf-1d1a5fec7e85 | grep $CLUSTER_NAME"-worker1" | awk '{print $10}' | tr -d ' ')
while [ "$WORKER1_STATE" != "active" ]; do WORKER1_STATE=`packet-cli device get -p 454b8b42-33d3-4e7e-8acf-1d1a5fec7e85 | grep $CLUSTER_NAME"-worker1" | awk '{print $10}' | tr -d ' '`;sleep 30;done
WORKER2_STATE=$(packet-cli device get -p 454b8b42-33d3-4e7e-8acf-1d1a5fec7e85 | grep $CLUSTER_NAME"-worker2" | awk '{print $10}' | tr -d ' ')
while [ "$WORKER2_STATE" != "active" ]; do WORKER2_STATE=`packet-cli device get -p 454b8b42-33d3-4e7e-8acf-1d1a5fec7e85 | grep $CLUSTER_NAME"-worker2" | awk '{print $10}' | tr -d ' '`;sleep 30;done
echo "CLUSTER_ID=$CLUSTER_ID" >> $GITHUB_ENV
echo "CLUSTER_IP=$CLUSTER_IP" >> $GITHUB_ENV
pwd;ls
scp -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -r pravega-operator.tar.gz root@$CLUSTER_IP:/root/
- name: Setup k8
run: |
pwd;ls
ssh -o StrictHostKeyChecking=no root@$CLUSTER_IP "sudo apt-get update;tar -xzvf /root/pravega-operator.tar.gz"
ssh -o StrictHostKeyChecking=no root@$CLUSTER_IP /root/pravega-operator/test/e2e/resources/kubernetes_master_install.sh
CLUSTER_ID1=`packet-cli device get -p 454b8b42-33d3-4e7e-8acf-1d1a5fec7e85 | grep $CLUSTER_NAME"-worker1" | awk '{print $2}' | tr -d ' '`
CLUSTER_IP1=`packet-cli device get -i $CLUSTER_ID1 -y | grep "\- address:" | head -1 |awk '{print $3}' | tr -d ' '`
CLUSTER_ID2=`packet-cli device get -p 454b8b42-33d3-4e7e-8acf-1d1a5fec7e85 | grep $CLUSTER_NAME"-worker2" | awk '{print $2}' | tr -d ' '`
CLUSTER_IP2=`packet-cli device get -i $CLUSTER_ID2 -y | grep "\- address:" | head -1 |awk '{print $3}' | tr -d ' '`
scp -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -r ../pravega-operator.tar.gz root@$CLUSTER_IP1:/root/
scp -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -r ../pravega-operator.tar.gz root@$CLUSTER_IP2:/root/
ssh -o StrictHostKeyChecking=no root@$CLUSTER_IP1 "sudo apt-get update;tar -xzvf /root/pravega-operator.tar.gz"
ssh -o StrictHostKeyChecking=no root@$CLUSTER_IP2 "sudo apt-get update;tar -xzvf /root/pravega-operator.tar.gz"
ssh -o StrictHostKeyChecking=no root@$CLUSTER_IP1 /root/pravega-operator/test/e2e/resources/kubernetes_slave_install.sh
ssh -o StrictHostKeyChecking=no root@$CLUSTER_IP2 /root/pravega-operator/test/e2e/resources/kubernetes_slave_install.sh
ssh -o StrictHostKeyChecking=no root@$CLUSTER_IP 'kubeadm token create --print-join-command | head -2' >JOIN
ssh -o StrictHostKeyChecking=no root@$CLUSTER_IP1 $(cat JOIN)
ssh -o StrictHostKeyChecking=no root@$CLUSTER_IP2 $(cat JOIN)
ssh -o StrictHostKeyChecking=no root@$CLUSTER_IP "kubectl get nodes"
echo "CLUSTER_ID1=$CLUSTER_ID1" >> $GITHUB_ENV
echo "CLUSTER_ID2=$CLUSTER_ID2" >> $GITHUB_ENV
- name: Make setup before running e2e
run: |
ssh -o StrictHostKeyChecking=no root@$CLUSTER_IP "mkdir /data;kubectl create -f /root/pravega-operator/test/e2e/resources/local-storage.yaml"
ssh -o StrictHostKeyChecking=no root@$CLUSTER_IP "curl -L https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | bash"
ssh -o StrictHostKeyChecking=no root@$CLUSTER_IP "helm repo add stable https://charts.helm.sh/stable;helm install stable/nfs-server-provisioner --generate-name"
ssh -o StrictHostKeyChecking=no root@$CLUSTER_IP "kubectl apply -f \"https://github.com/jetstack/cert-manager/releases/download/v1.7.0/cert-manager.crds.yaml\""
ssh -o StrictHostKeyChecking=no root@$CLUSTER_IP "helm repo add jetstack https://charts.jetstack.io"
ssh -o StrictHostKeyChecking=no root@$CLUSTER_IP "helm repo update"
ssh -o StrictHostKeyChecking=no root@$CLUSTER_IP "kubectl create namespace cert-manager;helm install cert-manager jetstack/cert-manager --namespace cert-manager --version v1.7.0 --wait"
ssh -o StrictHostKeyChecking=no root@$CLUSTER_IP "kubectl create -f /root/pravega-operator/test/e2e/resources/zookeeper_crd.yaml"
ssh -o StrictHostKeyChecking=no root@$CLUSTER_IP "kubectl create -f /root/pravega-operator/test/e2e/resources/zookeeper.yaml"
ssh -o StrictHostKeyChecking=no root@$CLUSTER_IP "kubectl -n default create -f /root/pravega-operator/test/e2e/resources/bk/bkoperator/crd.yaml"
ssh -o StrictHostKeyChecking=no root@$CLUSTER_IP "kubectl -n default create -f /root/pravega-operator/test/e2e/resources/bk/bkoperator/certificate.yaml"
ssh -o StrictHostKeyChecking=no root@$CLUSTER_IP "kubectl -n default create -f /root/pravega-operator/test/e2e/resources/bk/bkoperator/webhook.yaml"
ssh -o StrictHostKeyChecking=no root@$CLUSTER_IP "kubectl -n default create -f /root/pravega-operator/test/e2e/resources/bk/bkoperator/bk-config-map.yaml"
ssh -o StrictHostKeyChecking=no root@$CLUSTER_IP "kubectl -n default create -f /root/pravega-operator/test/e2e/resources/bk/bkoperator/service_account.yaml"
ssh -o StrictHostKeyChecking=no root@$CLUSTER_IP "kubectl -n default create -f /root/pravega-operator/test/e2e/resources/bk/bkoperator/role.yaml"
ssh -o StrictHostKeyChecking=no root@$CLUSTER_IP "kubectl -n default create -f /root/pravega-operator/test/e2e/resources/bk/bkoperator/role_binding.yaml"
ssh -o StrictHostKeyChecking=no root@$CLUSTER_IP "kubectl -n default create -f /root/pravega-operator/test/e2e/resources/bk/bkoperator/operator.yaml"
sleep 30s
ssh -o StrictHostKeyChecking=no root@$CLUSTER_IP "kubectl -n default create -f /root/pravega-operator/test/e2e/resources/bk/bk-cluster.yaml"
ssh -o StrictHostKeyChecking=no root@$CLUSTER_IP "kubectl -n default create secret docker-registry regcred --docker-server=https://index.docker.io/v1/ --docker-username=testpravegaop --docker-password=c155d654-3c09-48aa-a62d-2d5178454784 --docker-email=prabhaker.saxena75g@gmail.com"
ssh -o StrictHostKeyChecking=no root@$CLUSTER_IP "bash < <(curl -s -S -L https://raw.githubusercontent.com/moovweb/gvm/master/binscripts/gvm-installer);source /root/.gvm/scripts/gvm;gvm install go1.20 --binary;gvm use go1.20 --default;git config --global --add safe.directory /root/pravega-operator"
ssh -o StrictHostKeyChecking=no root@$CLUSTER_IP "kubectl create -f https://raw.githubusercontent.com/metallb/metallb/v0.9.3/manifests/namespace.yaml"
ssh -o StrictHostKeyChecking=no root@$CLUSTER_IP "kubectl apply -f https://raw.githubusercontent.com/metallb/metallb/v0.9.3/manifests/metallb.yaml"
ssh -o StrictHostKeyChecking=no root@$CLUSTER_IP "kubectl create -f /root/pravega-operator/config/crd/bases/pravega.pravega.io_pravegaclusters.yaml"
SECRET_KEY=8KGh4MBddaYa5SGDP943bisJk6uGqT9mBBaHN8dR2eZfUcaVmyqPLxC6KfAl9VWi
ssh -o StrictHostKeyChecking=no root@$CLUSTER_IP "kubectl create secret generic -n metallb-system memberlist --from-literal=secretkey=$SECRET_KEY"
ssh -o StrictHostKeyChecking=no root@$CLUSTER_IP "kubectl create -f /root/pravega-operator/test/e2e/resources/external_access/"
ssh -o StrictHostKeyChecking=no root@$CLUSTER_IP "cd /root/pravega-operator/test/e2e/resources/key_tls"
ssh -o StrictHostKeyChecking=no root@$CLUSTER_IP "cd /root/pravega-operator/test/e2e/resources/key_tls; kubectl create secret generic controller-tls \
--from-file=./controller01.pem \
--from-file=./tls.crt \
--from-file=./controller01.key.pem \
--from-file=./controller01.jks \
--from-file=./pass-secret-tls"
ssh -o StrictHostKeyChecking=no root@$CLUSTER_IP "cd /root/pravega-operator/test/e2e/resources/key_tls; kubectl create secret generic segmentstore-tls \
--from-file=./segmentstore01.pem \
--from-file=./tls.crt \
--from-file=./segmentstore01.jks \
--from-file=./pass-secret-tls \
--from-file=./segmentstore01.key.pem"
ssh -o StrictHostKeyChecking=no root@$CLUSTER_IP "cd /root/pravega-operator/test/e2e/resources/key_tls; kubectl create secret generic password-auth --from-file=pass-secret-tls-auth.txt"
- name: Running e2e
run: |
ssh -o StrictHostKeyChecking=no root@$CLUSTER_IP "cd /root/pravega-operator;source /root/.gvm/scripts/gvm;make test-e2e"
- name: Deleting cluster
if: ${{ always() }}
run: |
SSHKEY=`packet-cli ssh-key get | grep "pravega-travis" | awk '{print $2}' | tr -d ' '`
echo y | packet-cli ssh-key delete -i $SSHKEY
echo y | packet-cli device delete -i $CLUSTER_ID
echo y | packet-cli device delete -i $CLUSTER_ID1
echo y | packet-cli device delete -i $CLUSTER_ID2