Skip to content

Commit

Permalink
Support bootstrapper in CI
Browse files Browse the repository at this point in the history
  • Loading branch information
HoKim98 committed Sep 15, 2022
1 parent aa43b44 commit 068ca55
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 5 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ env:

ALPINE_VERSION: "3.16"
K8S_VERSION: "1.24.4"
ROCKYLINUX_VERSION: "8"
UBUNTU_VERSION: rolling

jobs:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
12 changes: 7 additions & 5 deletions templates/bootstrap/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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/"
Expand All @@ -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}"
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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" \
Expand Down Expand Up @@ -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!
Expand Down

0 comments on commit 068ca55

Please sign in to comment.