Skip to content

Commit

Permalink
Use a github template for airgap
Browse files Browse the repository at this point in the history
  • Loading branch information
juadk committed Jan 18, 2024
1 parent bd173cf commit 13ed088
Show file tree
Hide file tree
Showing 5 changed files with 113 additions and 38 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/cli-k3s-airgap_rm_latest.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# This workflow calls the master E2E workflow with custom variables
name: CLI-K3s-Airgap-RM_latest

on:
pull_request:
workflow_dispatch:
inputs:
destroy_runner:
description: Destroy the auto-generated self-hosted runner
default: true
type: boolean
schedule:
- cron: '0 8 * * *'

jobs:
cli:
uses: ./.github/workflows/master-airgap.yaml
secrets:
credentials: ${{ secrets.GCP_CREDENTIALS }}
pat_token: ${{ secrets.SELF_HOSTED_RUNNER_PAT_TOKEN }}
slack_webhook_url: ${{ secrets.SLACK_WEBHOOK_URL }}
with:
cert-manager_version: v1.12.2
cluster_name: airgap-cluster
cluster_type: airgap
#destroy_runner: ${{ github.event_name == 'schedule' && true || inputs.destroy_runner }}
k8s_version_to_provision: v1.26.8+k3s1
os_to_test: dev
rancher_version: latest/devel/2.7
upstream_cluster_version: 1.26.8
30 changes: 30 additions & 0 deletions .github/workflows/cli-k3s-airgap_rm_stable.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# This workflow calls the master E2E workflow with custom variables
name: CLI-K3s-Airgap-RM_stable

on:
pull_request:
workflow_dispatch:
inputs:
destroy_runner:
description: Destroy the auto-generated self-hosted runner
default: true
type: boolean
schedule:
- cron: '0 8 * * *'

jobs:
cli:
uses: ./.github/workflows/master-airgap.yaml
secrets:
credentials: ${{ secrets.GCP_CREDENTIALS }}
pat_token: ${{ secrets.SELF_HOSTED_RUNNER_PAT_TOKEN }}
slack_webhook_url: ${{ secrets.SLACK_WEBHOOK_URL }}
with:
cert-manager_version: v1.12.2
cluster_name: airgap-cluster
cluster_type: airgap
#destroy_runner: ${{ github.event_name == 'schedule' && true || inputs.destroy_runner }}
k8s_version_to_provision: v1.26.8+k3s1
os_to_test: dev
rancher_version: stable/latest/2.7
upstream_cluster_version: 1.26.8
Original file line number Diff line number Diff line change
@@ -1,20 +1,46 @@
name: Elemental Airgap E2E tests with Rancher Manager
name: (template) Elemental Airgap E2E tests with Rancher Manager

on:
pull_request:
workflow_dispatch:
inputs:
qase_run_id:
description: Case run ID where the results will be reported
workflow_call:
# Variables to set when calling this reusable workflow
secrets:
credentials:
description: Credentials to use to connect
required: true
pat_token:
# A token is needed to be able to add runner on the repo, maybe this can be changed later
# This token is linked to a personal account
# So in case of token issue you have to check (no specific order and for example):
# - the expiration date
# - if the account associated still exists
# - if the person still has access to the repo
description: PAT token used to add runner
required: true
qase_api_token:
description: Qase API token to use for Cypress tests
required: false
type: string
slack_webhook_url:
description: WebHook URL to use for Slack
required: true
inputs:
cert-manager_version:
description: Version of cert-manager to use
type: string
cluster_name:
description: Name of the provisioned cluster
required: true
type: string
cluster_type:
description: Cluster type (empty if normal or hardened)
type: string
destroy_runner:
description: Destroy the auto-generated self-hosted runner
default: true
type: boolean
k8s_version_to_provision:
description: Name and version of installed K8s distribution
required: true
type: string
operator_repo:
description: Elemental operator repository to use
type: string
Expand All @@ -23,10 +49,18 @@ on:
description: OS repository to test (dev/staging/stable)
type: string
default: dev
qase_run_id:
description: Case run ID where the results will be reported
required: false
type: string
rancher_version:
description: Rancher Manager channel/version to use for installation
default: stable/latest/2.7
type: string
upstream_cluster_version:
description: Cluster upstream version where to install Rancher (K3s or RKE2)
default: v1.26.8
type: string

jobs:
create-runner:
Expand All @@ -48,7 +82,7 @@ jobs:
- name: Authenticate to GCP
uses: google-github-actions/auth@v1
with:
credentials_json: ${{ secrets.GCP_CREDENTIALS }}
credentials_json: ${{ secrets.credentials }}
- name: Setup gcloud
uses: google-github-actions/setup-gcloud@v1
- name: Create runner
Expand All @@ -58,7 +92,7 @@ jobs:
--zone us-central1-a
- name: Create PAT token secret
run: |
echo -n ${{ secrets.SELF_HOSTED_RUNNER_PAT_TOKEN }} \
echo -n ${{ secrets.pat_token }} \
| gcloud secrets create PAT_TOKEN_${{ steps.generator.outputs.uuid }} --data-file=-
- name: Get public dns name in GCP
id: dns
Expand Down Expand Up @@ -90,19 +124,19 @@ jobs:
runs-on: ${{ needs.create-runner.outputs.uuid }}
env:
ARCH: amd64
CERT_MANAGER_VERSION: v1.12.2
CLUSTER_NAME: airgap-cluster
CERT_MANAGER_VERSION: ${{ inputs.cert-manager_version }}
CLUSTER_NAME: ${{ inputs.cluster_name }}
CLUSTER_NS: fleet-default
CLUSTER_TYPE: airgap
CLUSTER_TYPE: ${{ inputs.cluster_type }}
# Distribution to use to host Rancher Manager (K3s)
K8S_UPSTREAM_VERSION: 1.26.8
K8S_UPSTREAM_VERSION: ${{ inputs.upstream_cluster_version }}
# For K8s cluster to provision with Rancher Manager
K8S_VERSION_TO_PROVISION: v1.26.8+k3s1
K8S_VERSION_TO_PROVISION: ${{ inputs.k8s_version_to_provision}}
# QASE variables
QASE_API_TOKEN: ${{ secrets.qase_api_token }}
QASE_RUN_ID: ${{ inputs.qase_run_id }}
# For Rancher Manager
RANCHER_VERSION: latest/devel/2.7
RANCHER_VERSION: ${{ inputs.rancher_version }}
TIMEOUT_SCALE: 3
steps:
- name: Checkout
Expand All @@ -122,8 +156,7 @@ jobs:
- name: Create ISO image for master pool
env:
EMULATE_TPM: true
#OS_TO_TEST: ${{ inputs.os_to_test }}
OS_TO_TEST: dev
OS_TO_TEST: ${{ inputs.os_to_test }}
POOL: master
run: |
export ISO_BOOT=true
Expand All @@ -137,25 +170,6 @@ jobs:
run: |
export ISO_BOOT=true
cd tests && VM_INDEX=${VM_START} VM_NUMBERS=${VM_END} make e2e-bootstrap-node
# - name: Deploy a node to join Rancher manager
# if: inputs.test_type == 'ui'
# env:
# ISO_BOOT: ${{ inputs.iso_boot }}
# VM_INDEX: 1
# VM_MEM: 8192
# HOST_MEMORY_RESERVED: 49152
# run: |
# cd tests && (
# # Removing 'downloads' is needed to avoid this error during 'make':
# # 'pattern all: open .../elemental/tests/cypress/downloads: permission denied'
# sudo rm -rf cypress/latest/downloads
# make e2e-ui-rancher
# )
#
# - name: Configure Rancher & Libvirt
# if: inputs.test_type == 'cli'
# run: cd tests && make e2e-configure-rancher
# delete-runner:
# if: always() && needs.create-runner.result == 'success' && inputs.destroy_runner == true
# needs: [create-runner, e2e]
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/airgap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import (
var _ = Describe("E2E - Build the airgap archive", Label("prepare-archive"), func() {

It("Execute the script to build the archive", func() {
err := exec.Command("sudo", airgapBuildScript, k8sUpstreamVersion, certManagerVersion, rancherChannel).Run()
err := exec.Command("sudo", airgapBuildScript, k8sUpstreamVersion, certManagerVersion, rancherChannel, k8sVersion).Run()
Expect(err).To(Not(HaveOccurred()))
})
})
Expand Down
3 changes: 2 additions & 1 deletion tests/scripts/build-airgap
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ set -e -x
K3S_UPSTREAM_VERSION=$1
CERT_MANAGER_VERSION=$2
RANCHER_CHANNEL=$3
K3S_DOWNSTREAM_VERSION=$4

# Create directories
mkdir -p /opt/rancher/{k3s_$K3S_UPSTREAM_VERSION,helm} /opt/rancher/images/{cert,rancher,registry,elemental}
Expand Down Expand Up @@ -84,7 +85,7 @@ for i in $(cat rancher/orig_rancher-images.txt|awk -F: '{print $1}'); do
done
# Except for rancher/kubectl
grep 'rancher/kubectl' rancher/orig_rancher-images.txt >> rancher/version_unsorted.txt
grep "rancher/system-agent-installer-k3s:v$K3S_UPSTREAM_VERSION" rancher/orig_rancher-images.txt >> rancher/version_unsorted.txt
grep "rancher/system-agent-installer-k3s:${K3S_DOWNSTREAM_VERSION%+*}" rancher/orig_rancher-images.txt >> rancher/version_unsorted.txt

# Final sort
cat rancher/version_unsorted.txt | sort -u > rancher/rancher-images.txt
Expand Down

0 comments on commit 13ed088

Please sign in to comment.