diff --git a/.github/workflows/helm-libvirt.yaml b/.github/workflows/helm-libvirt.yaml new file mode 100644 index 00000000..cce0a702 --- /dev/null +++ b/.github/workflows/helm-libvirt.yaml @@ -0,0 +1,51 @@ +name: Helm GitHub Actions for Libvirt + +on: + pull_request: + paths: + - base-helm-configs/libvirt/** + - .github/workflows/helm-libvirt.yaml +jobs: + helm: + strategy: + matrix: + overlays: + - base + name: Helm + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - uses: azure/setup-helm@v3 + with: + version: latest + token: "${{ secrets.GITHUB_TOKEN }}" + id: helm + - name: Kubectl Install + working-directory: /usr/local/bin/ + run: | + if [ ! -f /usr/local/bin/kubectl ]; then + curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" + chmod +x ./kubectl + fi + - name: Pull OSH submodules + run: | + git submodule update --init submodules/openstack-helm + git submodule update --init submodules/openstack-helm-infra + - name: Make OSH submodule + run: | + cd submodules/openstack-helm-infra + make libvirt + - name: Run Helm Template + run: | + cd submodules/openstack-helm-infra + ${{ steps.helm.outputs.helm-path }} template libvirt ./libvirt \ + --namespace=openstack \ + --wait \ + --timeout 120m \ + -f ${{ github.workspace }}/base-helm-configs/libvirt/libvirt-helm-overrides.yaml > /tmp/rendered.yaml + - name: Return helm Build + uses: actions/upload-artifact@v4 + with: + name: helm-libvirt-artifact-${{ matrix.overlays }} + path: /tmp/rendered.yaml diff --git a/.github/workflows/kustomize-libvirt.yaml b/.github/workflows/kustomize-libvirt.yaml deleted file mode 100644 index 600d47bc..00000000 --- a/.github/workflows/kustomize-libvirt.yaml +++ /dev/null @@ -1,40 +0,0 @@ -name: Kustomize GitHub Actions for libvirt - -on: - pull_request: - paths: - - base-kustomize/libvirt/** - - .github/workflows/kustomize-libvirt.yaml -jobs: - kustomize: - name: Kustomize - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - uses: azure/setup-helm@v3 - with: - version: latest - token: "${{ secrets.GITHUB_TOKEN }}" - id: helm - - name: Kustomize Install - working-directory: /usr/local/bin/ - run: | - if [ ! -f /usr/local/bin/kustomize ]; then - curl -s "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" | sudo bash - fi - - name: Pull OSH infra submodule - run: | - git submodule update --init submodules/openstack-helm-infra - - name: Make OSH infra submodule - run: | - cd submodules/openstack-helm-infra - make libvirt - - name: Run Kustomize Build - run: | - kustomize build base-kustomize/libvirt --enable-helm --helm-command ${{ steps.helm.outputs.helm-path }} > /tmp/rendered.yaml - - name: Return Kustomize Build - uses: actions/upload-artifact@v4 - with: - name: kustomize-libvirt-artifact - path: /tmp/rendered.yaml diff --git a/base-kustomize/libvirt/helm/libvirt-helm-overrides.yaml b/base-helm-configs/libvirt/libvirt-helm-overrides.yaml similarity index 97% rename from base-kustomize/libvirt/helm/libvirt-helm-overrides.yaml rename to base-helm-configs/libvirt/libvirt-helm-overrides.yaml index cb445c2a..821de246 100644 --- a/base-kustomize/libvirt/helm/libvirt-helm-overrides.yaml +++ b/base-helm-configs/libvirt/libvirt-helm-overrides.yaml @@ -195,12 +195,12 @@ pod: libvirt: enabled: false tolerations: - - key: node-role.kubernetes.io/master - operator: Exists - effect: NoSchedule - - key: node-role.kubernetes.io/control-plane - operator: Exists - effect: NoSchedule + - key: node-role.kubernetes.io/master + operator: Exists + effect: NoSchedule + - key: node-role.kubernetes.io/control-plane + operator: Exists + effect: NoSchedule dns_policy: "ClusterFirstWithHostNet" mounts: libvirt: diff --git a/base-kustomize/libvirt/kustomization.yaml b/base-kustomize/libvirt/kustomization.yaml deleted file mode 100644 index 7619c256..00000000 --- a/base-kustomize/libvirt/kustomization.yaml +++ /dev/null @@ -1,9 +0,0 @@ -helmGlobals: - chartHome: /opt/genestack/submodules/openstack-helm-infra - -helmCharts: - - name: libvirt - releaseName: libvirt - valuesFile: helm/libvirt-helm-overrides.yaml - namespace: openstack - includeCRDs: true diff --git a/bin/install-libvirt.sh b/bin/install-libvirt.sh new file mode 100644 index 00000000..3e592d82 --- /dev/null +++ b/bin/install-libvirt.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +# Directory to check for YAML files +CONFIG_DIR="/etc/genestack/helm-configs/libvirt" + +pushd /opt/genestack/submodules/openstack-helm-infra || exit + +# Base helm upgrade command +HELM_CMD="helm upgrade --install libvirt ./libvirt \ + --namespace=openstack \ + --timeout 120m" + +# Add the base overrides file +HELM_CMD+=" -f /opt/genestack/base-helm-configs/libvirt/libvirt-helm-overrides.yaml" + +# Check if YAML files exist in the specified directory +if compgen -G "${CONFIG_DIR}/*.yaml" > /dev/null; then + # Append all YAML files from the directory to the helm command + for yaml_file in "${CONFIG_DIR}"/*.yaml; do + HELM_CMD+=" -f ${yaml_file}" + done +fi + +# Run the helm command +eval "${HELM_CMD}" + +popd || exit diff --git a/docs/infrastructure-libvirt.md b/docs/infrastructure-libvirt.md index e47e66f0..db2b3553 100644 --- a/docs/infrastructure-libvirt.md +++ b/docs/infrastructure-libvirt.md @@ -2,9 +2,13 @@ The first part of the compute kit is Libvirt. -``` shell -kubectl kustomize --enable-helm /etc/genestack/kustomize/libvirt | kubectl apply --namespace openstack -f - -``` +## Run the package deployment + +!!! example "Run the libvirt deployment Script `bin/install-libvirt.sh`" + + ``` shell + --8<-- "bin/install-libvirt.sh" + ``` Once deployed you can validate functionality on your compute hosts with `virsh`