docs(main): replace lookup env to apply (#3039) #1
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: Test Controllers Metering and Account | |
env: | |
# Common versions | |
GO_VERSION: "1.20" | |
on: | |
workflow_dispatch: | |
push: | |
branches: [ "main" ] | |
paths: | |
- "controllers/metering/**" | |
- "controllers/common/metering/**" | |
- ".github/workflows/e2e.yml" | |
- "controllers/account/**" | |
- "!**/*.md" | |
- "!**/*.yaml" | |
jobs: | |
build-image: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
module: [ metering, account ] | |
steps: | |
- name: Checkout # clone 代码 | |
uses: actions/checkout@v3 | |
- name: Setup Golang with cache | |
uses: magnetikonline/action-golang-cache@v3 | |
with: | |
go-version: ${{ env.GO_VERSION }} | |
- name: Auto install sealos | |
uses: labring/[email protected] | |
with: | |
sealosVersion: 4.1.5-alpha2 | |
- name: Build ${{ matrix.module }} amd64 # 打包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: Build ${{ matrix.module }} arm64 | |
working-directory: controllers/${{ matrix.module }} | |
run: | | |
GOARCH=arm64 make build | |
mv bin/manager bin/controller-${{ matrix.module }}-arm64 | |
chmod +x bin/controller-${{ matrix.module }}-arm64 | |
- name: Prepare | |
id: prepare | |
working-directory: controllers/${{ matrix.module }} | |
run: | | |
TAG=deploy | |
echo tag_name=${TAG} >> $GITHUB_OUTPUT | |
DOCKER_REPO=ghcr.io/${{ github.repository_owner }}/sealos-${{ matrix.module }}-controller | |
echo docker_repo=${DOCKER_REPO} >> $GITHUB_OUTPUT | |
IMG=${DOCKER_REPO}:dev make pre-deploy | |
- name: Build ${{ matrix.module }} image | |
working-directory: controllers/${{ matrix.module }} | |
run: | | |
sealos login -u ${{ github.repository_owner }} -p ${{ secrets.GH_PAT }} --debug ghcr.io | |
sealos build --debug -t ${{ steps.prepare.outputs.docker_repo }}:dev . | |
sealos push ${{ steps.prepare.outputs.docker_repo }}:dev | |
- name: build ${{ matrix.module }} main controller cluster image | |
working-directory: controllers/${{ matrix.module }}/deploy | |
run: | | |
ls -l | |
sealos build --debug -t ${{ steps.prepare.outputs.docker_repo }}:${{ steps.prepare.outputs.tag_name }}-cluster . | |
sealos push ${{ steps.prepare.outputs.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 40 | |
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 pods -A | |
- name: Prepare | |
id: prepare | |
run: | | |
TAG=deploy | |
echo tag_name=${TAG} >> $GITHUB_OUTPUT | |
- name: install common metering CRD | |
working-directory: ./controllers/common/metering | |
run: | | |
sudo -u root apt install make | |
make install | |
- 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 | |
- name: install CRD account | |
working-directory: ./controllers/account | |
run: | | |
sudo -u root sealos run docker.io/labring/cert-manager:v1.8.0 | |
sleep 10 | |
sudo kubectl get pod -A | |
IMG=ghcr.io/${{ github.repository_owner }}/sealos-account-controller:dev make pre-deploy | |
sudo -u root kubectl create namespace sealos-system | |
sudo -u root kubectl apply -f ./deploy/manifests/deploy.yaml | |
kubectl create configmap account-manager-configmap --from-literal=SMALL_BLOCK_WAIT_SECOND=1 -n account-system | |
sudo -u root kubectl create secret generic payment-secret -n account-system | |
sleep 10 | |
- name: account e2e Test | |
working-directory: ./controllers/account | |
run: | | |
go test -v ./testdata/e2e/debt_test.go | |
sleep 20 | |
- name: metering e2e Test | |
working-directory: ./controllers/metering | |
run: | | |
go test -v ./testdata/e2e/metering_test.go -run TestMetering |