diff --git a/.github/workflows/build-sealos-offline-installer.yml b/.github/workflows/build-sealos-offline-installer.yml new file mode 100644 index 0000000..c8b3231 --- /dev/null +++ b/.github/workflows/build-sealos-offline-installer.yml @@ -0,0 +1,104 @@ +name: Build Sealos Offline Installer + +on: + push: + paths: + - 'scripts/create-sealos-offline-package.sh' + - 'scripts/sealos-install.sh' + - 'scripts/cilium-values.yaml' + - '.github/workflows/build-sealos-offline-installer.yml' + workflow_dispatch: + +jobs: + build-sealos-installer: + strategy: + matrix: + arch: [amd64, arm64] + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Run Offline Package Builder + run: | + chmod +x scripts/create-sealos-offline-package.sh + ARCH=${{ matrix.arch }} ./scripts/create-sealos-offline-package.sh + + - name: Upload Artifact + uses: actions/upload-artifact@v4 + with: + name: sealos-offline-package-${{ matrix.arch }} + path: sealos-offline-package-${{ matrix.arch }}.tar.gz + + test-sealos-installer: + needs: build-sealos-installer + strategy: + matrix: + arch: [amd64] + runs-on: ubuntu-latest + + steps: + - name: Download Artifact + uses: actions/download-artifact@v4 + with: + name: sealos-offline-package-${{ matrix.arch }} + path: ./test-dir + + - name: Extract Package + run: | + cd test-dir + tar -xzvf sealos-offline-package-${{ matrix.arch }}.tar.gz + + - name: Verify Package Contents + run: | + test -f test-dir/sealos-offline-package/sealos-install.sh + test -f test-dir/sealos-offline-package/cilium-values.yaml + + publish-release: + needs: test-sealos-installer + runs-on: ubuntu-latest + env: + tag_name: offline-sealos-${{ github.run_number }} + + steps: + - uses: actions/checkout@v4 + + - name: Create GitHub Release + id: create_release + uses: actions/create-release@v1 + with: + tag_name: ${{ env.tag_name }} + release_name: Daily Build ${{ env.tag_name }} + draft: false + prerelease: false + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Download amd64 Artifact + uses: actions/download-artifact@v4 + with: + name: sealos-offline-package-amd64 + path: release-artifacts + + - name: Download arm64 Artifact + uses: actions/download-artifact@v4 + with: + name: sealos-offline-package-arm64 + path: release-artifacts + + - name: Upload to GitHub Release + uses: softprops/action-gh-release@v1 + with: + tag_name: ${{ env.tag_name }} + files: | + release-artifacts/sealos-offline-package-amd64.tar.gz + release-artifacts/sealos-offline-package-arm64.tar.gz + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/scripts/cilium-values.yaml b/scripts/cilium-values.yaml new file mode 100644 index 0000000..f7b5d3e --- /dev/null +++ b/scripts/cilium-values.yaml @@ -0,0 +1,23 @@ +cluster: + name: kubernetes +k8sServiceHost: apiserver.cluster.local +k8sServicePort: 6443 +kubeProxyReplacement: true +ipam: + mode: "kubernetes" +nodePort: + enabled: true +externalIPs: + enabled: true +hostServices: + enabled: true +enableIPv4Masquerade: true +envoy: + enabled: false +operator: + replicas: 1 +serviceAccounts: + cilium: + name: cilium + operator: + name: cilium-operator diff --git a/scripts/create-sealos-offline-package.sh b/scripts/create-sealos-offline-package.sh new file mode 100755 index 0000000..c0e4201 --- /dev/null +++ b/scripts/create-sealos-offline-package.sh @@ -0,0 +1,28 @@ +#!/bin/bash +set -euo pipefail + +K8S_VERSION="${K8S_VERSION:-labring/kubernetes:v1.29.9}" +CILIUM_VERSION="${CILIUM_VERSION:-labring/cilium:v1.13.4}" +HELM_VERSION="${HELM_VERSION:-labring/helm:v3.9.4}" + +ARCH="${ARCH:-amd64}" +IMAGES=("$K8S_VERSION" "$CILIUM_VERSION" "$HELM_VERSION") +WORKDIR="sealos-offline-package" +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" + +rm -rf "$WORKDIR" +mkdir -p "$WORKDIR/images" + +for img in "${IMAGES[@]}"; do + docker pull --platform "linux/${ARCH}" "$img" +done + +docker save "${IMAGES[@]}" -o "$WORKDIR/images/sealos-images.tar" + +cp "$SCRIPT_DIR/cilium-values.yaml" "$WORKDIR/" +cp "$SCRIPT_DIR/sealos-install.sh" "$WORKDIR/" +chmod +x "$WORKDIR/sealos-install.sh" + +tar czf "sealos-offline-package-${ARCH}.tar.gz" "$WORKDIR" + +echo "Created sealos-offline-package-${ARCH}.tar.gz" diff --git a/scripts/sealos-install.sh b/scripts/sealos-install.sh new file mode 100755 index 0000000..96e933c --- /dev/null +++ b/scripts/sealos-install.sh @@ -0,0 +1,26 @@ +#!/bin/bash +set -euo pipefail + +# Load pre-packaged images if present +if [ -f "images/sealos-images.tar" ]; then + if command -v sealos >/dev/null 2>&1; then + sealos load -i images/sealos-images.tar || true + elif command -v docker >/dev/null 2>&1; then + docker load -i images/sealos-images.tar || true + fi +fi + +sealos run labring/kubernetes:v1.29.9 \ + labring/cilium:v1.13.4 \ + labring/helm:v3.9.4 \ + --masters 172.31.23.68 \ + --user root \ + --pk /root/.ssh/id_rsa \ + --env '{}' \ + --cmd 'kubeadm init --skip-phases=addon/kube-proxy' + +sealos add --nodes 172.31.23.69 + +helm repo add cilium https://helm.cilium.io +helm repo update +helm upgrade cilium cilium/cilium -n kube-system -f cilium-values.yaml