forked from labring/sealos
-
Notifications
You must be signed in to change notification settings - Fork 0
125 lines (116 loc) · 4.26 KB
/
e2e_metering.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
name: Test Controllers Metering
env:
# Common versions
GO_VERSION: "1.20"
on:
workflow_dispatch:
push:
branches: [ "main" ]
paths:
- "controllers/metering/**"
- ".github/workflows/e2e_metering.yml"
- "!**/*.md"
- "!**/*.yaml"
jobs:
build-image:
runs-on: ubuntu-latest
strategy:
matrix:
module: [ metering ]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Auto install sealos
uses: labring/[email protected]
with:
sealosVersion: 4.1.5-alpha2
- name: Build ${{ matrix.module }} amd64
working-directory: controllers/${{ matrix.module }}
run: |
GOARCH=amd64 make build
mv bin/manager bin/controller-${{ matrix.module }}-amd64
chmod +x bin/controller-${{ matrix.module }}-amd64
- name: Prepare
id: prepare
run: |
TAG=deploy
echo tag_name=${TAG} >> $GITHUB_OUTPUT
- name: build ${{ matrix.module }} main controller image
env:
# fork friendly ^^
DOCKER_REPO: ghcr.io/${{ github.repository_owner }}/sealos-${{ matrix.module }}-controller
working-directory: controllers/${{ matrix.module }}/deploy
run: |
ls -l
sealos build --debug -t ${DOCKER_REPO}:${{ steps.prepare.outputs.tag_name }}-cluster .
sealos login -u ${{ github.repository_owner }} -p ${{ secrets.GH_TOKEN }} --debug ghcr.io
sealos push ${DOCKER_REPO}:${{ steps.prepare.outputs.tag_name }}-cluster
- name: docker images
run: |
sudo sealos images
e2e-test:
needs:
- build-image
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Auto install sealos
uses: labring/[email protected]
with:
sealosVersion: 4.1.5-alpha2
- name: Auto install k8s using sealos
uses: labring/[email protected]
with:
image: labring/kubernetes:v1.25.0 labring/helm:v3.8.2 labring/calico:v3.24.1
debug: true
type: run-k8s
- name: After k8s operation
run: |
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
NODENAME=$(sudo -u root kubectl get nodes -ojsonpath='{.items[0].metadata.name}' )
NODEIP=$(sudo -u root kubectl get nodes -ojsonpath='{.items[0].status.addresses[0].address}' )
echo "NodeName=$NODENAME,NodeIP=$NODEIP"
sudo -u root kubectl taint node $NODENAME node-role.kubernetes.io/control-plane-
sleep 60
sudo -u root crictl ps -a
sudo -u root cat /etc/hosts
sudo -u root systemctl status kubelet
sudo -u root kubectl get nodes
sudo -u root kubectl get nodes
sudo -u root kubectl get pods -A
- name: Prepare
id: prepare
run: |
TAG=deploy
echo tag_name=${TAG} >> $GITHUB_OUTPUT
- name: install CRD metering
working-directory: ./controllers/metering
run: |
sudo sealos run --env METERING_INTERVAL=1 ghcr.io/${{ github.repository_owner }}/sealos-metering-controller:${{ steps.prepare.outputs.tag_name }}-cluster
sudo -u root kubectl get configmap -A
- name: install CRD account
working-directory: ./controllers/account
run: |
make pre-deploy
sudo -u root kubectl create namespace account-system
sudo -u root kubectl create namespace sealos-system
sudo -u root kubectl create secret generic payment-secret -n account-system
sudo -u root kubectl apply -f ./deploy/manifests/deploy.yaml
- name: install CRD infra
working-directory: ./controllers/infra
run: |
make pre-deploy
sudo -u root kubectl apply -f ./deploy/manifests/deploy.yaml
sleep 30
- name: Setup Golang with cache
uses: magnetikonline/action-golang-cache@v3
with:
go-version: ${{ env.GO_VERSION }}
- name: e2e Test
working-directory: ./controllers/metering
run: |
sudo -u root kubectl get pod -A
go test ./testdata/e2e/metering_test.go -v