From 068ca5592a239cfc61436f9afbd3d77684e7631b Mon Sep 17 00:00:00 2001 From: Ho Kim Date: Thu, 15 Sep 2022 14:06:09 +0000 Subject: [PATCH] Support bootstrapper in CI --- .github/workflows/build.yml | 46 ++++++++++++++++++++++++++++++++ templates/bootstrap/bootstrap.sh | 12 +++++---- 2 files changed, 53 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 378662c2..969c1df9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -19,6 +19,7 @@ env: ALPINE_VERSION: "3.16" K8S_VERSION: "1.24.4" + ROCKYLINUX_VERSION: "8" UBUNTU_VERSION: rolling jobs: @@ -79,6 +80,50 @@ jobs: - name: Print image url run: echo "Image pushed to ${{ steps.push-to-quay.outputs.registry-paths }}" + build-and-push-image-bootstrap-node: + if: ${{ github.ref == 'refs/heads/master' }} + needs: + - build-rust + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Log in to ${{ env.REGISTRY }} + uses: redhat-actions/podman-login@v1 + with: + registry: ${{ env.REGISTRY }} + username: ${{ env.REGISTRY_USER }} + password: ${{ env.REGISTRY_PASSWORD }} + + - name: Build Image + id: build-and-push-image + uses: redhat-actions/buildah-build@v2 + with: + image: ${{ env.IMAGE_NAME }}-bootstrap-node + tags: latest + context: ./templates/bootstrap/node + containerfiles: | + ./templates/bootstrap/node/Dockerfile + build-args: | + ROCKYLINUX_VERSION=${{ env.ROCKYLINUX_VERSION }} + + - name: Push To ${{ env.REGISTRY }} + id: push-to-quay + if: ${{ github.repository }} == "ulagbulag-village/netai-cloud" + uses: redhat-actions/push-to-registry@v2 + with: + image: ${{ steps.build-and-push-image.outputs.image }} + tags: ${{ steps.build-and-push-image.outputs.tags }} + registry: ${{ env.REGISTRY }}/${{ env.REGISTRY_REPOSITORY }} + + - name: Print image url + run: echo "Image pushed to ${{ steps.push-to-quay.outputs.registry-paths }}" + build-and-push-image-ipxe: if: ${{ github.ref == 'refs/heads/master' }} needs: @@ -172,6 +217,7 @@ jobs: if: ${{ github.ref == 'refs/heads/master' }} needs: - build-and-push-image + - build-and-push-image-bootstrap-node - build-and-push-image-ipxe - build-and-push-image-upgrade-kiss runs-on: ubuntu-latest diff --git a/templates/bootstrap/bootstrap.sh b/templates/bootstrap/bootstrap.sh index 8ca9e424..34a38d00 100755 --- a/templates/bootstrap/bootstrap.sh +++ b/templates/bootstrap/bootstrap.sh @@ -12,7 +12,8 @@ set -e # Configure default environment variables CONTAINER_RUNTIME_DEFAULT="docker" -KISS_IMAGE_DEFAULT="quay.io/ulagbulag-village/netai-cloud-upgrade-kiss:latest" +KISS_BOOTSTRAP_NODE_IMAGE_DEFAULT="quay.io/ulagbulag-village/netai-cloud-bootstrap-node:latest" +KISS_INSTALLER_IMAGE_DEFAULT="quay.io/ulagbulag-village/netai-cloud-upgrade-kiss:latest" KUBERNETES_CONFIG_DEFAULT="$HOME/.kube/" KUBESPRAY_CONFIG_DEFAULT="$(pwd)/config/bootstrap/defaults/hosts.yaml" KUBESPRAY_CONFIG_TEMPLATE_DEFAULT="$(pwd)/config/" @@ -23,7 +24,8 @@ SSH_KEYFILE_DEFAULT="$KUBESPRAY_CONFIG_TEMPLATE_DEFAULT/id_rsa" # Configure environment variables CONTAINER_RUNTIME="${CONTAINER_RUNTIME:-$CONTAINER_RUNTIME_DEFAULT}" -KISS_IMAGE="${KISS_IMAGE:-$KISS_IMAGE_DEFAULT}" +KISS_BOOTSTRAP_NODE_IMAGE="${KISS_BOOTSTRAP_NODE_IMAGE:-$KISS_BOOTSTRAP_NODE_IMAGE_DEFAULT}" +KISS_INSTALLER_IMAGE="${KISS_INSTALLER_IMAGE:-$KISS_INSTALLER_IMAGE_DEFAULT}" KUBERNETES_CONFIG_DEFAULT="${KUBERNETES_CONFIG_DEFAULT:-$KUBERNETES_CONFIG_DEFAULT_DEFAULT}" KUBESPRAY_CONFIG="${KUBESPRAY_CONFIG:-$KUBESPRAY_CONFIG_DEFAULT}" KUBESPRAY_CONFIG_TEMPLATE="${KUBESPRAY_CONFIG_TEMPLATE:-$KUBESPRAY_CONFIG_TEMPLATE_DEFAULT}" @@ -99,7 +101,7 @@ function spawn_node() { --volume "/lib/modules/$UNAME:/lib/modules/$UNAME:ro" \ --volume "/sys/fs/cgroup:/sys/fs/cgroup" \ --volume "/usr/src/linux-headers-$UNAME:/usr/src/linux-headers-$UNAME" \ - node >/dev/null + "$KISS_BOOTSTRAP_NODE_IMAGE" >/dev/null else # Port scanner function get_available_port() { @@ -197,7 +199,7 @@ function install_k8s_cluster() { --volume "$KUBESPRAY_CONFIG_TEMPLATE/bootstrap/:/etc/kiss/bootstrap/:ro" \ --volume "$SSH_KEYFILE:/root/.ssh/id_rsa:ro" \ --volume "$SSH_KEYFILE.pub:/root/.ssh/id_rsa.pub:ro" \ - $KUBESPRAY_IMAGE ansible-playbook \ + "$KUBESPRAY_IMAGE" ansible-playbook \ --become --become-user="root" \ --inventory "/etc/kiss/bootstrap/defaults/hosts.yaml" \ --inventory "/root/kiss/bootstrap/hosts.yaml" \ @@ -261,7 +263,7 @@ function install_kiss_cluster() { --name "kiss-installer" \ --net "host" \ --volume "$KUBERNETES_CONFIG_DEFAULT:/root/.kube:ro" \ - $KISS_IMAGE + "$KISS_INSTALLER_IMAGE" fi # Finished!