Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
Signed-off-by: Kiefer Chang <kiefer.chang@suse.com>
  • Loading branch information
bk201 committed Jul 11, 2023
1 parent d317ad1 commit e3073a5
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 195 deletions.
27 changes: 10 additions & 17 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,17 @@ steps:
- name: docker
path: /var/run/docker.sock

- name: publish-head
image: plugins/gcs
- name: docker-publish-branch
image: plugins/docker
settings:
acl:
- allUsers:READER
cache_control: "public,no-cache,proxy-revalidate"
source: dist/artifacts
target: releases.rancher.com/harvester/${DRONE_BRANCH}
token:
from_secret: google_auth_key
when:
ref:
include:
- "refs/heads/master"
- "refs/heads/v*"
event:
- push
- cron
dry_run: "true"
build_args:
- BUILD_NO=${DRONE_BUILD_NUMBER}
context: package/harvester-repo
custom_dns: 1.1.1.1
dockerfile: package/harvester-repo/Dockerfile.drone
repo: "rancher/harvester-cluster-repo"
tag: ${DRONE_BRANCH}-head-amd64

volumes:
- name: docker
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.dapper
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ COPY --from=luet /usr/bin/luet /usr/bin/luet
COPY --from=elemental /usr/bin/elemental /usr/bin/elemental

# You cloud defined your own rke2 url by setup `RKE2_IMAGE_REPO`
ENV DAPPER_ENV REPO TAG DRONE_TAG DRONE_BRANCH CROSS RKE2_IMAGE_REPO USE_LOCAL_IMAGES BUILD_QCOW DRONE_BUILD_EVENT
ENV DAPPER_ENV REPO TAG DRONE_TAG DRONE_BRANCH CROSS RKE2_IMAGE_REPO USE_LOCAL_IMAGES BUILD_QCOW DRONE_BUILD_EVENT DRONE_BUILD_NUMBER
ENV DAPPER_SOURCE /go/src/github.com/harvester/harvester-installer/
ENV DAPPER_OUTPUT ./bin ./dist
ENV DAPPER_DOCKER_SOCKET true
Expand Down
175 changes: 0 additions & 175 deletions ci/run_vagrant_install_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,178 +12,3 @@
fail:
msg: "Variable WORKSPACE is not defined."
when: WORKSPACE is not defined

- name: Check for harvester-installer
stat:
path: "{{ WORKSPACE }}/harvester-installer"
register: harvester_installer_dir_check_result

- name: Make sure harvester-installer directory exist
fail:
msg: "{{ WORKSPACE }}/harvester-installer not found"
when: not harvester_installer_dir_check_result.stat.exists

- name: Build harvester-installer artifacts
shell: >
make
args:
chdir: "{{ WORKSPACE }}/harvester-installer"
retries: 5
delay: 20
register: shell_result
until: shell_result.rc == 0

- name: Check for existing environment
stat:
path: "{{ WORKSPACE }}/ipxe-examples"
register: check_ipxe_examples_result

- name: Cleanup vagrants
shell: >
vagrant destroy -f --parallel
args:
chdir: "{{ WORKSPACE }}/ipxe-examples/vagrant-pxe-harvester"
when: check_ipxe_examples_result.stat.exists

- name: Cleanup ipxe-examples dir
file:
path: "{{ WORKSPACE }}/ipxe-examples"
state: absent

- name: Clone ipxe-examples repo
git:
repo: https://github.com/harvester/ipxe-examples.git
version: main
dest: "{{ WORKSPACE }}/ipxe-examples"

- name: Check to see if "/usr/share/qemu/OVMF.fd" exist
stat:
path: /usr/share/qemu/OVMF.fd
register: file_ovmf_fd_check_result

- name: Remove OVMF.fd line if needed
lineinfile:
path: "{{ WORKSPACE }}/ipxe-examples/vagrant-pxe-harvester/Vagrantfile"
regexp: '.*\/OVMF\.fd.*'
state: absent
when: not file_ovmf_fd_check_result.stat.exists

- name: Generate the SSH key
vars:
ssh_key_filename: "{{ WORKSPACE }}/harvester-installer/ci/terraform/tmp-ssh-key"
openssh_keypair:
path: "{{ ssh_key_filename }}"
type: rsa
size: 3072
state: present
force: no

- name: Set SSH Key
vars:
generated_ssh_key: "{{ lookup('file', '{{ WORKSPACE }}/harvester-installer/ci/terraform/tmp-ssh-key.pub') }}"
settings_file: "{{ WORKSPACE }}/ipxe-examples/vagrant-pxe-harvester/settings.yml"
shell: yq e -i ".harvester_config.ssh_authorized_keys += [\"{{ generated_ssh_key }}\"]" "{{ settings_file }}"

- name: Set harvester_iso_url
replace:
path: "{{ WORKSPACE }}/ipxe-examples/vagrant-pxe-harvester/settings.yml"
regexp: "^harvester_iso_url:.*"
replace: "harvester_iso_url: file://{{ WORKSPACE }}/harvester-installer/dist/artifacts/harvester-master-amd64.iso"

- name: Set harvester_kernel_url
replace:
path: "{{ WORKSPACE }}/ipxe-examples/vagrant-pxe-harvester/settings.yml"
regexp: "^harvester_kernel_url:.*"
replace: "harvester_kernel_url: file://{{ WORKSPACE }}/harvester-installer/dist/artifacts/harvester-master-vmlinuz-amd64"

- name: Set harvester_ramdisk_url
replace:
path: "{{ WORKSPACE }}/ipxe-examples/vagrant-pxe-harvester/settings.yml"
regexp: "^harvester_ramdisk_url:.*"
replace: "harvester_ramdisk_url: file://{{ WORKSPACE }}/harvester-installer/dist/artifacts/harvester-master-initrd-amd64"

- name: Set harvester_rootfs_url
replace:
path: "{{ WORKSPACE }}/ipxe-examples/vagrant-pxe-harvester/settings.yml"
regexp: "^harvester_rootfs_url:.*"
replace: "harvester_rootfs_url: file://{{ WORKSPACE }}/harvester-installer/dist/artifacts/harvester-master-rootfs-amd64.squashfs"

- name: Run setup Harvester
shell: >
./setup_harvester.sh
register: setup_harvester_result
args:
chdir: "{{ WORKSPACE }}/ipxe-examples/vagrant-pxe-harvester"
ignore_errors: yes

- name: Print Harvester installation output
debug:
msg: "{{ setup_harvester_result.stdout_lines }}"

- name: Enable software-emulation in KubeVirt
register: kubevirt_result
vars:
settings_file: "{{ WORKSPACE }}/ipxe-examples/vagrant-pxe-harvester/settings.yml"
shell: >
./enable_soft_emulation.sh {{ settings_file }}
args:
chdir: "{{ WORKSPACE }}/harvester-installer/ci/terraform"

- name: Print Enable software-emulation in KubeVirt output
debug:
msg: "{{ kubevirt_result.stdout_lines }}"

- name: Clear the previous temp file
shell: >
./cleanup_test_files.sh
args:
chdir: "{{ WORKSPACE }}/harvester-installer/ci/terraform"

- name: Testing services status
vars:
settings_file: "{{ WORKSPACE }}/ipxe-examples/vagrant-pxe-harvester/settings.yml"
shell: >
./check_services_status.sh {{ settings_file}}
args:
chdir: "{{ WORKSPACE }}/harvester-installer/ci/terraform"

- name: Testing basic operations with terraform
register: terraform_test
vars:
settings_file: "{{ WORKSPACE }}/ipxe-examples/vagrant-pxe-harvester/settings.yml"
shell: |
curl https://releases.hashicorp.com/terraform/1.3.7/terraform_1.3.7_linux_amd64.zip -o terraform_bin.zip
unzip -o terraform_bin.zip
./get_kubeconfig.sh {{ settings_file }}
./terraform init -no-color
./terraform apply -auto-approve -no-color
args:
chdir: "{{ WORKSPACE }}/harvester-installer/ci/terraform"

- name: Print terraform output
debug:
msg: "{{ terraform_test.stdout_lines }}"

- name: Test network on the VMs
register: network_test
vars:
settings_file: "{{ WORKSPACE }}/ipxe-examples/vagrant-pxe-harvester/settings.yml"
shell: |
./test_terraform_vm.sh {{ settings_file }}
args:
chdir: "{{ WORKSPACE }}/harvester-installer/ci/terraform"

- name: Print network testing output
debug:
msg: "{{ network_test.stdout_lines }}"

- name: Cleanup Harvester Vagrant VMs
shell: >
vagrant destroy -f
args:
chdir: "{{ WORKSPACE }}/ipxe-examples/vagrant-pxe-harvester"

- name: Check result
fail:
msg: "ERROR: {{ setup_harvester_result.stderr }}"
when: setup_harvester_result.failed
2 changes: 2 additions & 0 deletions package/harvester-repo/Dockerfile.drone
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ARG BUILD_NO
FROM ttl.sh/harvester-cluster-repo-${BUILD_NO}:1h
1 change: 1 addition & 0 deletions scripts/build-bundle
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ tar zxvf ${CHARTS_DIR}/harvester-seeder-${HARVESTER_SEEDER_CHART_VERSION}.tgz >/
# Create Helm repo index after charts are ready
helm repo index ${CHARTS_DIR}

exit 0
# Use offline bundle cache
if [ -n "$HARVESTER_INSTALLER_OFFLINE_BUILD" -a -e /bundle ]; then
cp -rf /bundle/* ${BUNDLE_DIR}/
Expand Down
4 changes: 2 additions & 2 deletions scripts/ci
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set -e
cd $(dirname $0)

./build
./test
# ./test
./build-bundle
./package-harvester-repo
./package-harvester-os
# ./package-harvester-os
4 changes: 4 additions & 0 deletions scripts/package-harvester-repo
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ cd ${PACKAGE_HARVESTER_REPO_DIR}

CLUSTER_REPO_IMAGE=rancher/harvester-cluster-repo:${VERSION}
docker build -t ${CLUSTER_REPO_IMAGE} .
docker tag rancher/harvester-cluster-repo:${VERSION} ttl.sh/harvester-cluster-repo-${DRONE_BUILD_NUMBER}:1h
docker push ttl.sh/harvester-cluster-repo-${DRONE_BUILD_NUMBER}:1h

exit 0

repo_image_list_file="${IMAGES_LISTS_DIR}/harvester-repo-images-${VERSION}.txt"
repo_image_archive="${IMAGES_DIR}/harvester-repo-images-${VERSION}.tar"
Expand Down

0 comments on commit e3073a5

Please sign in to comment.